1
yhj
2024-07-24 5e5d945e91568b973faa27d8ab0bcef99fc4a6c5
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
#region
 
using System;
using System.Collections;
using System.Collections.Generic;
using System.Text;
using System.Windows.Forms;
using CSFrameworkV5.Core;
using CSFrameworkV5.Interfaces.InterfaceModels;
using DevExpress.XtraEditors;
 
#endregion
 
namespace CSFrameworkV5.Library
{
    public partial class frmFormConfigDetail : Form
    {
        private int i;
 
        private frmFormConfigDetail()
        {
            InitializeComponent();
        }
 
        private void BindingObject(BaseEdit edit, object o, string fieldName)
        {
            edit.DataBindings.Clear();
            edit.DataBindings.Add("EditValue", o, fieldName);
        }
 
        private void btnBottom_Click(object sender, EventArgs e)
        {
            if (listFields.SelectedIndex < listFields.ItemCount - 1)
                MoveItem(listFields.ItemCount - 1);
        }
 
        private void btnCancel_Click(object sender, EventArgs e)
        {
            Close();
        }
 
        private void btnDown_Click(object sender, EventArgs e)
        {
            i = listFields.SelectedIndex;
            if (i < listFields.ItemCount - 1)
            {
                i++;
                MoveItem(i);
            }
        }
 
        private void btnHideAll_Click(object sender, EventArgs e)
        {
            listFields.UnCheckAll();
        }
 
        private void btnOK_Click(object sender, EventArgs e)
        {
            btnOK.Tag = "OK";
            Close();
        }
 
        private void btnShowAll_Click(object sender, EventArgs e)
        {
            listFields.CheckAll();
        }
 
        private void btnTop_Click(object sender, EventArgs e)
        {
            MoveItem(0);
        }
 
        private void btnUp_Click(object sender, EventArgs e)
        {
            i = listFields.SelectedIndex;
            if (i > 0)
            {
                i--;
                MoveItem(i);
            }
        }
 
        public static void Execute(List<FieldConfig> fields, bool isViewMode)
        {
            var form = new frmFormConfigDetail();
            form.listFields.DisplayMember = "CaptionCustom";
            form.listFields.ValueMember = "FieldName";
            form.listFields.DataSource = fields;
            form.btnOK.Visible = !isViewMode;
            form.panelControl1.Enabled = !isViewMode;
            form.groupControl1.Enabled = !isViewMode;
            form.ShowDialog();
        }
 
        private void frmFormConfigDetail_Load(object sender, EventArgs e)
        {
            //
        }
 
        private void listFields_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (listFields.SelectedItem != null)
            {
                var item = listFields.SelectedItem as FieldConfig;
                ShowConfig(item);
            }
        }
 
        private void MoveItem(int index)
        {
            var item = listFields.SelectedItem as FieldConfig;
            var list = listFields.DataSource as IList;
            list.Remove(item);
            list.Insert(index, item);
            listFields.Refresh();
            listFields.SelectedIndex = index;
        }
 
        private void ShowConfig(FieldConfig item)
        {
            if (string.IsNullOrEmpty(item.CaptionCustom))
                item.CaptionCustom = item.Caption;
 
            BindingObject(txtCustomCaption, item, "CaptionCustom");
            BindingObject(txtDefaultCaption, item, "Caption");
            BindingObject(txtFieldName, item, "FieldName");
            BindingObject(txtNoBlank, item, "NoBlank");
            BindingObject(txtPoint, item, "Point");
            BindingObject(txtReadOnly, item, "ReadOnly");
            BindingObject(txtWidth, item, "Width");
        }
 
        private void txtPoint_EditValueChanged(object sender, EventArgs e)
        {
            var len = (int)txtPoint.Value;
 
            lblExample.Text = "20170808";
            var point = new StringBuilder("");
 
            for (var i = 1; i <= len; i++) point.Append(i.ToStringEx());
 
            if (point.Length > 0)
            {
                lblExample.Text = lblExample.Text + "." + point.ToStringEx();
                lblExample.Refresh();
            }
        }
    }
}