hytos / DTI_PID / SPPIDConverter_AutoModeling / ConverterForm.cs @ b18dc619
이력 | 보기 | 이력해설 | 다운로드 (9.08 KB)
1 | 96a2080c | gaqhf | using System; |
---|---|---|---|
2 | using System.Collections.Generic; |
||
3 | using System.ComponentModel; |
||
4 | using System.Data; |
||
5 | using System.Drawing; |
||
6 | using System.Linq; |
||
7 | using System.Text; |
||
8 | using System.Threading.Tasks; |
||
9 | using System.Windows.Forms; |
||
10 | using Microsoft.VisualBasic; |
||
11 | 23eb98bf | gaqhf | using Converter.BaseModel; |
12 | 1278ba59 | gaqhf | using DevExpress.XtraEditors.Repository; |
13 | using DevExpress.XtraEditors.Controls; |
||
14 | using DevExpress.XtraEditors; |
||
15 | 23eb98bf | gaqhf | using System.Globalization; |
16 | using System.Threading; |
||
17 | using System.IO; |
||
18 | using Converter.SPPID.AutoModeling.Properties; |
||
19 | using Converter.SPPID.AutoModeling.DB; |
||
20 | using Converter.SPPID.AutoModeling.Util; |
||
21 | using Converter.SPPID.AutoModeling.Form; |
||
22 | 96a2080c | gaqhf | |
23 | namespace Converter.SPPID.AutoModeling |
||
24 | { |
||
25 | public partial class ConverterForm : DevExpress.XtraBars.Ribbon.RibbonForm |
||
26 | { |
||
27 | 23eb98bf | gaqhf | private DataTable converterDT = new DataTable(); |
28 | private RepositoryItemComboBox templateComboBox; |
||
29 | |||
30 | ProjectInfo _ProjectInfo = ProjectInfo.GetInstance(); |
||
31 | 2e1e3c12 | gaqhf | SPPID_DBInfo _SPPIDInfo = SPPID_DBInfo.GetInstance(); |
32 | 1278ba59 | gaqhf | |
33 | 96a2080c | gaqhf | public ConverterForm() |
34 | { |
||
35 | InitializeComponent(); |
||
36 | 1278ba59 | gaqhf | |
37 | 23eb98bf | gaqhf | CultureInfo culture = CultureInfo.GetCultureInfo("en"); |
38 | Msg.Culture = culture; |
||
39 | |||
40 | 1278ba59 | gaqhf | //Color color = Color.FromArgb(67, 117, 219); |
41 | //layoutControlGroupAutoConverter.AppearanceGroup.BorderColor = color; |
||
42 | //layoutControlGroupAutoConverter.AllowBorderColorBlending = true; |
||
43 | //layoutControlGroupSPPIDDB.AppearanceGroup.BorderColor = color; |
||
44 | //layoutControlGroupSPPIDDB.AllowBorderColorBlending = true; |
||
45 | //layoutControlGroupID2Project.AppearanceGroup.BorderColor = color; |
||
46 | //layoutControlGroupID2Project.AllowBorderColorBlending = true; |
||
47 | //layoutControlGroupItemMapping.AppearanceGroup.BorderColor = color; |
||
48 | //layoutControlGroupItemMapping.AllowBorderColorBlending = true; |
||
49 | 23eb98bf | gaqhf | |
50 | SPPIDUtil.ReadSPPIDInfo(); |
||
51 | SPPIDUtil.ReadID2ProjectInfo(); |
||
52 | |||
53 | 1278ba59 | gaqhf | InitGridControl(); |
54 | 23eb98bf | gaqhf | SetID2ProjectUI(); |
55 | SetSPPIDDBUI(); |
||
56 | 1278ba59 | gaqhf | } |
57 | |||
58 | private void InitGridControl() |
||
59 | { |
||
60 | #region Converter Page |
||
61 | gridViewConverter.OptionsSelection.MultiSelect = true; |
||
62 | gridViewConverter.OptionsSelection.MultiSelectMode = DevExpress.XtraGrid.Views.Grid.GridMultiSelectMode.CheckBoxRowSelect; |
||
63 | |||
64 | DataColumn col = converterDT.Columns.Add("colDrawingFileName"); |
||
65 | col.Caption = "Drawing File Name"; |
||
66 | col = converterDT.Columns.Add("colUnit"); |
||
67 | col.Caption = "Unit"; |
||
68 | col = converterDT.Columns.Add("colTemplate"); |
||
69 | col.Caption = "Template"; |
||
70 | col = converterDT.Columns.Add("colDrawingNumber"); |
||
71 | col.Caption = "Drawing Number"; |
||
72 | col = converterDT.Columns.Add("colDrawingName"); |
||
73 | col.Caption = "Drawing Name"; |
||
74 | col = converterDT.Columns.Add("colStatus"); |
||
75 | col.Caption = "Status"; |
||
76 | col = converterDT.Columns.Add("colUID"); |
||
77 | gridControlConverter.DataSource = converterDT; |
||
78 | |||
79 | templateComboBox = new RepositoryItemComboBox(); |
||
80 | templateComboBox.TextEditStyle = TextEditStyles.DisableTextEditor; |
||
81 | gridControlConverter.RepositoryItems.Add(templateComboBox); |
||
82 | gridViewConverter.Columns["colTemplate"].ColumnEdit = templateComboBox; |
||
83 | |||
84 | RepositoryItemButtonEdit unitButton = new RepositoryItemButtonEdit(); |
||
85 | unitButton.ButtonClick += UnitButton_ButtonClick; |
||
86 | unitButton.TextEditStyle = DevExpress.XtraEditors.Controls.TextEditStyles.DisableTextEditor; |
||
87 | gridControlConverter.RepositoryItems.Add(unitButton); |
||
88 | gridViewConverter.Columns["colUnit"].ColumnEdit = unitButton; |
||
89 | |||
90 | gridViewConverter.Columns["colDrawingFileName"].OptionsColumn.AllowEdit = false; |
||
91 | gridViewConverter.Columns["colUnit"].OptionsColumn.ReadOnly = true; |
||
92 | gridViewConverter.Columns["colStatus"].OptionsColumn.AllowEdit = false; |
||
93 | gridViewConverter.Columns["colUID"].Visible = false; |
||
94 | |||
95 | gridViewConverter.BestFitColumns(); |
||
96 | #endregion |
||
97 | } |
||
98 | |||
99 | 23eb98bf | gaqhf | private void btnID2Project_ButtonClick(object sender, ButtonPressedEventArgs e) |
100 | { |
||
101 | if (xtraFolderBrowserDialog.ShowDialog() == DialogResult.OK) |
||
102 | { |
||
103 | bool result = false; |
||
104 | string dirPath = xtraFolderBrowserDialog.SelectedPath; |
||
105 | if (IsID2Project(dirPath)) |
||
106 | { |
||
107 | _ProjectInfo.Path = dirPath; |
||
108 | _ProjectInfo.Enable = true; |
||
109 | if (SPPIDUtil.SaveID2ProjectInfo()) |
||
110 | { |
||
111 | result = true; |
||
112 | SetID2ProjectUI(); |
||
113 | MessageBox.Show(Msg.SuccessProjectSelect, Msg.Information, MessageBoxButtons.OK, MessageBoxIcon.Information); |
||
114 | } |
||
115 | } |
||
116 | |||
117 | if (!result) |
||
118 | { |
||
119 | _ProjectInfo.Enable = false; |
||
120 | SetID2ProjectUI(); |
||
121 | MessageBox.Show(Msg.FailProjectSelect, Msg.Warning, MessageBoxButtons.OK, MessageBoxIcon.Warning); |
||
122 | } |
||
123 | } |
||
124 | } |
||
125 | |||
126 | private void SetID2ProjectUI() |
||
127 | { |
||
128 | if (_ProjectInfo.Enable) |
||
129 | { |
||
130 | btnID2Project.Text = _ProjectInfo.Path; |
||
131 | labelID2ProjectName.Text = _ProjectInfo.Name; |
||
132 | labelID2ProjectName.AppearanceItemCaption.ForeColor = Color.Blue; |
||
133 | labelID2ProjectStatus.Text = Msg.ConnectionSuccessful; |
||
134 | labelID2ProjectStatus.AppearanceItemCaption.ForeColor = Color.Blue; |
||
135 | } |
||
136 | else |
||
137 | { |
||
138 | btnID2Project.Text = ""; |
||
139 | labelID2ProjectName.Text = " "; |
||
140 | labelID2ProjectName.AppearanceItemCaption.ForeColor = Color.Red; |
||
141 | labelID2ProjectStatus.Text = Msg.ConnectionFail; |
||
142 | labelID2ProjectStatus.AppearanceItemCaption.ForeColor = Color.Red; |
||
143 | } |
||
144 | } |
||
145 | |||
146 | private void SetSPPIDDBUI() |
||
147 | { |
||
148 | if (_SPPIDInfo.Enable) |
||
149 | { |
||
150 | labelSPPIDPlantName.Text = _SPPIDInfo.SelectedPlant; |
||
151 | labelSPPIDPlantName.AppearanceItemCaption.ForeColor = Color.Blue; |
||
152 | labelSPPIDDBStatus.Text = Msg.ConnectionSuccessful; |
||
153 | labelSPPIDDBStatus.AppearanceItemCaption.ForeColor = Color.Blue; |
||
154 | } |
||
155 | else |
||
156 | { |
||
157 | labelSPPIDPlantName.Text = " "; |
||
158 | labelSPPIDPlantName.AppearanceItemCaption.ForeColor = Color.Red; |
||
159 | labelSPPIDDBStatus.Text = Msg.ConnectionFail; |
||
160 | labelSPPIDDBStatus.AppearanceItemCaption.ForeColor = Color.Red; |
||
161 | } |
||
162 | } |
||
163 | |||
164 | private bool IsID2Project(string path) |
||
165 | { |
||
166 | bool result = false; |
||
167 | string[] directories = Directory.GetDirectories(path, "*", SearchOption.TopDirectoryOnly); |
||
168 | for (int i = 0; i < directories.Length; i++) |
||
169 | directories[i] = Path.GetFileName(directories[i]); |
||
170 | List<string> dirList = directories.ToList(); |
||
171 | |||
172 | if (dirList.Contains("db") && |
||
173 | dirList.Contains("Temp") && |
||
174 | dirList.Contains("image")) |
||
175 | { |
||
176 | result = true; |
||
177 | } |
||
178 | |||
179 | return result; |
||
180 | } |
||
181 | |||
182 | 1278ba59 | gaqhf | private void UnitButton_ButtonClick(object sender, ButtonPressedEventArgs e) |
183 | { |
||
184 | //UnitForm unitForm = new UnitForm(dUnit); |
||
185 | //if (unitForm.ShowDialog() == DialogResult.OK) |
||
186 | //{ |
||
187 | // ButtonEdit button = sender as ButtonEdit; |
||
188 | // button.EditValue = unitForm.SelectedUnit; |
||
189 | // gridViewConverter.CloseEditor(); |
||
190 | // gridViewConverter.UpdateCurrentRow(); |
||
191 | // gridViewConverter.BestFitColumns(); |
||
192 | //} |
||
193 | } |
||
194 | |||
195 | private void btnLoadFile_Click(object sender, EventArgs e) |
||
196 | { |
||
197 | 23eb98bf | gaqhf | if (!_ProjectInfo.Enable) |
198 | { |
||
199 | MessageBox.Show(Msg.PleaseSetID2ProjectInfo, Msg.Warning, MessageBoxButtons.OK, MessageBoxIcon.Warning); |
||
200 | return; |
||
201 | } |
||
202 | 1278ba59 | gaqhf | |
203 | 23eb98bf | gaqhf | xtraOpenFileDialog.InitialDirectory = _ProjectInfo.Path + @"\temp"; |
204 | if (xtraOpenFileDialog.ShowDialog() == DialogResult.OK) |
||
205 | 1278ba59 | gaqhf | { |
206 | 23eb98bf | gaqhf | foreach (string fileName in xtraOpenFileDialog.FileNames) |
207 | 1278ba59 | gaqhf | { |
208 | |||
209 | } |
||
210 | } |
||
211 | } |
||
212 | |||
213 | private void btnRun_Click(object sender, EventArgs e) |
||
214 | { |
||
215 | DialogResult = DialogResult.OK; |
||
216 | 96a2080c | gaqhf | } |
217 | 23eb98bf | gaqhf | |
218 | private void btnSPPIDDB_Click(object sender, EventArgs e) |
||
219 | { |
||
220 | SPPID_DB_SettingForm form = new SPPID_DB_SettingForm(); |
||
221 | if (form.ShowDialog() == DialogResult.OK) |
||
222 | SetSPPIDDBUI(); |
||
223 | } |
||
224 | df4559fc | gaqhf | |
225 | private void btnItemMapping_Click(object sender, EventArgs e) |
||
226 | { |
||
227 | if (!_ProjectInfo.Enable) |
||
228 | { |
||
229 | MessageBox.Show(Msg.PleaseSetID2ProjectInfo, Msg.Warning, MessageBoxButtons.OK, MessageBoxIcon.Warning); |
||
230 | return; |
||
231 | } |
||
232 | |||
233 | MappingForm form = new MappingForm(); |
||
234 | form.ShowDialog(); |
||
235 | } |
||
236 | 96a2080c | gaqhf | } |
237 | } |