hytos / DTI_PID / SPPIDConverter / ConverterForm.cs @ 30a9ffce
이력 | 보기 | 이력해설 | 다운로드 (26.3 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 | b8e2644e | gaqhf | using Converter.SPPID.Properties; |
19 | using Converter.SPPID.DB; |
||
20 | using Converter.SPPID.Util; |
||
21 | using Converter.SPPID.Form; |
||
22 | using Converter.SPPID.Model; |
||
23 | 96a2080c | gaqhf | |
24 | b8e2644e | gaqhf | namespace Converter.SPPID |
25 | 96a2080c | gaqhf | { |
26 | public partial class ConverterForm : DevExpress.XtraBars.Ribbon.RibbonForm |
||
27 | { |
||
28 | bca86986 | gaqhf | private Dictionary<string, SPPID_Document> _DicDocuments = new Dictionary<string, SPPID_Document>(); |
29 | 4314b3f3 | gaqhf | private List<SPPID_Document> _Documents = new List<SPPID_Document>(); |
30 | public List<SPPID_Document> Documents { get { return _Documents; } } |
||
31 | bca86986 | gaqhf | private DataTable _ConverterDT = new DataTable(); |
32 | private DataTable _SPPIDSymbolPathDT = new DataTable(); |
||
33 | 635a8747 | gaqhf | private DataTable _SPPIDUnitDT = new DataTable(); |
34 | 23eb98bf | gaqhf | private RepositoryItemComboBox templateComboBox; |
35 | |||
36 | bca86986 | gaqhf | |
37 | private DataTable _ID2SymbolDT = new DataTable(); |
||
38 | private DataTable _ID2LineDT = new DataTable(); |
||
39 | private DataTable _ID2AssociationDT = new DataTable(); |
||
40 | private DataTable _ID2LinePropertyDT = new DataTable(); |
||
41 | f1c9dbaa | gaqhf | private DataTable _ID2SymbolTypeDT = new DataTable(); |
42 | |||
43 | bca86986 | gaqhf | |
44 | private List<SymbolMapping> symbolMappings = new List<SymbolMapping>(); |
||
45 | private List<LineMapping> lineMappings = new List<LineMapping>(); |
||
46 | private List<LineNumberMapping> lineNumberMappings = new List<LineNumberMapping>(); |
||
47 | private List<AssociationMapping> associationMappings = new List<AssociationMapping>(); |
||
48 | |||
49 | 96a2080c | gaqhf | public ConverterForm() |
50 | { |
||
51 | InitializeComponent(); |
||
52 | 1278ba59 | gaqhf | |
53 | fab4f207 | gaqhf | CultureInfo culture = CultureInfo.GetCultureInfo("ko"); |
54 | 23eb98bf | gaqhf | Msg.Culture = culture; |
55 | |||
56 | bca86986 | gaqhf | InitUsedDataTable(); |
57 | 1278ba59 | gaqhf | InitGridControl(); |
58 | fab4f207 | gaqhf | InitID2Project(); |
59 | 1278ba59 | gaqhf | } |
60 | |||
61 | f1232880 | gaqhf | #region |
62 | /// <summary> |
||
63 | /// The Activate Event is where the command should show its form |
||
64 | /// if it should be displayed. |
||
65 | /// </summary> |
||
66 | /// <param name="sender">The sender of the event</param> |
||
67 | /// <param name="e">Arguments passed during event</param> |
||
68 | private void commandControl_Activate(object sender, EventArgs e) |
||
69 | { |
||
70 | 5e6ecf05 | gaqhf | Show(); |
71 | //if (ShowDialog() == DialogResult.OK) |
||
72 | //{ |
||
73 | f1232880 | gaqhf | |
74 | 5e6ecf05 | gaqhf | //} |
75 | f1232880 | gaqhf | |
76 | 5e6ecf05 | gaqhf | //foreach (var item in commandControl.Application.RADApplication.ActiveSelectSet) |
77 | //{ |
||
78 | // //MessageBox.Show(item.GetType()); |
||
79 | // int count = ((Ingr.RAD2D.LineStringGeometry2d)((Ingr.RAD2D.DependencyObject)item).GetGeometry()).VertexCount; |
||
80 | // double[] iii = null; |
||
81 | // ((Ingr.RAD2D.LineStringGeometry2d)((Ingr.RAD2D.DependencyObject)item).GetGeometry()).GetVertices(ref count, ref iii); |
||
82 | // for (int i = 0; i < count; i++) |
||
83 | // { |
||
84 | // double x = 0; |
||
85 | // double y = 0; |
||
86 | // ((Ingr.RAD2D.LineStringGeometry2d)((Ingr.RAD2D.DependencyObject)item).GetGeometry()).GetVertex(i + 1, ref x, ref y); |
||
87 | |||
88 | // } |
||
89 | // Ingr.RAD2D.Symbol2d symbol2D; |
||
90 | // //symbol2D.Move |
||
91 | //} |
||
92 | f1232880 | gaqhf | |
93 | //commandControl.Application.RADApplication.Interactive = true; |
||
94 | //Hide(); |
||
95 | //commandControl.Done = true; |
||
96 | } |
||
97 | |||
98 | /// <summary> |
||
99 | /// The Deactivate event is where the command should hide its form if it |
||
100 | /// was displayed. The command should not unload the form here. |
||
101 | /// The command's form should be unloaded in the Class Module Terminate event. |
||
102 | /// </summary> |
||
103 | /// <param name="sender">The sender of the event</param> |
||
104 | /// <param name="e">Arguments passed during event</param> |
||
105 | private void commandControl_Deactivate(object sender, EventArgs e) |
||
106 | { |
||
107 | Hide(); |
||
108 | } |
||
109 | |||
110 | /// <summary> |
||
111 | /// The Initialize event is where the command should perform 1 time |
||
112 | /// initialization, for example it might save a reference to the |
||
113 | /// active document in private global data. |
||
114 | /// </summary> |
||
115 | /// <param name="sender">The sender of the event</param> |
||
116 | /// <param name="e">Arguments passed during event</param> |
||
117 | private void commandControl_Initialize(object sender, EventArgs e) |
||
118 | { |
||
119 | |||
120 | } |
||
121 | |||
122 | /// <summary> |
||
123 | /// The Terminate event is where the command can clean up any command |
||
124 | /// specific allocated resources. |
||
125 | /// </summary> |
||
126 | /// <param name="sender">The sender of the event</param> |
||
127 | /// <param name="e">Arguments passed during event</param> |
||
128 | public void commandControl_Terminate(object sender, EventArgs e) |
||
129 | { |
||
130 | |||
131 | } |
||
132 | |||
133 | /// <summary> |
||
134 | /// The primary form should not simply be unloaded. You should set the |
||
135 | /// Intergraph Command Control Done property to True when you want the |
||
136 | /// form to be unloaded. Then unload the form in the dispose method. |
||
137 | /// </summary> |
||
138 | /// <param name="sender">The sender of the event</param> |
||
139 | /// <param name="e">Arguments passed during event</param> |
||
140 | private void ConverterForm_FormClosing(object sender, FormClosingEventArgs e) |
||
141 | { |
||
142 | Hide(); |
||
143 | commandControl.Done = true; |
||
144 | e.Cancel = true; //Do not let C# close out the form ... Let RAD close it. |
||
145 | } |
||
146 | #endregion |
||
147 | |||
148 | bca86986 | gaqhf | private void InitUsedDataTable() |
149 | 1278ba59 | gaqhf | { |
150 | bca86986 | gaqhf | // Converter Table |
151 | DataColumn col = _ConverterDT.Columns.Add("colDrawingFileName"); |
||
152 | 1278ba59 | gaqhf | col.Caption = "Drawing File Name"; |
153 | bca86986 | gaqhf | col = _ConverterDT.Columns.Add("colDrawingFilePath"); |
154 | 0d8062b2 | gaqhf | col.Caption = "DrawingFilePath"; |
155 | bca86986 | gaqhf | col = _ConverterDT.Columns.Add("colUnit"); |
156 | 1278ba59 | gaqhf | col.Caption = "Unit"; |
157 | bca86986 | gaqhf | col = _ConverterDT.Columns.Add("colTemplate"); |
158 | 1278ba59 | gaqhf | col.Caption = "Template"; |
159 | bca86986 | gaqhf | col = _ConverterDT.Columns.Add("colDrawingNumber"); |
160 | 1278ba59 | gaqhf | col.Caption = "Drawing Number"; |
161 | bca86986 | gaqhf | col = _ConverterDT.Columns.Add("colDrawingName"); |
162 | 1278ba59 | gaqhf | col.Caption = "Drawing Name"; |
163 | bca86986 | gaqhf | col = _ConverterDT.Columns.Add("colStatus"); |
164 | 1278ba59 | gaqhf | col.Caption = "Status"; |
165 | bca86986 | gaqhf | col = _ConverterDT.Columns.Add("colUID"); |
166 | |||
167 | col = _ID2LineDT.Columns.Add("UID"); |
||
168 | col = _ID2LineDT.Columns.Add("Name"); |
||
169 | col.Caption = "Name"; |
||
170 | col = _ID2LineDT.Columns.Add("Type"); |
||
171 | col.Caption = "Type"; |
||
172 | col = _ID2LineDT.Columns.Add("SPPID_SYMBOL_PATH"); |
||
173 | col.Caption = "SPPID Symbol Path"; |
||
174 | col = _ID2LineDT.Columns.Add("Clear"); |
||
175 | col.Caption = ""; |
||
176 | } |
||
177 | |||
178 | private void InitGridControl() |
||
179 | { |
||
180 | #region Converter Page |
||
181 | gridViewConverter.OptionsSelection.MultiSelect = true; |
||
182 | gridViewConverter.OptionsSelection.MultiSelectMode = DevExpress.XtraGrid.Views.Grid.GridMultiSelectMode.CheckBoxRowSelect; |
||
183 | |||
184 | gridControlConverter.DataSource = _ConverterDT; |
||
185 | 1278ba59 | gaqhf | |
186 | templateComboBox = new RepositoryItemComboBox(); |
||
187 | templateComboBox.TextEditStyle = TextEditStyles.DisableTextEditor; |
||
188 | 635a8747 | gaqhf | templateComboBox.EditValueChanged += templateComboBox_EditValueChanged; |
189 | 1278ba59 | gaqhf | gridControlConverter.RepositoryItems.Add(templateComboBox); |
190 | gridViewConverter.Columns["colTemplate"].ColumnEdit = templateComboBox; |
||
191 | |||
192 | 635a8747 | gaqhf | gridViewConverter.Columns["colUnit"].OptionsColumn.AllowEdit = false; |
193 | 1278ba59 | gaqhf | gridViewConverter.Columns["colDrawingFileName"].OptionsColumn.AllowEdit = false; |
194 | gridViewConverter.Columns["colUnit"].OptionsColumn.ReadOnly = true; |
||
195 | gridViewConverter.Columns["colStatus"].OptionsColumn.AllowEdit = false; |
||
196 | 0d8062b2 | gaqhf | gridViewConverter.Columns["colDrawingFilePath"].Visible = false; |
197 | 1278ba59 | gaqhf | gridViewConverter.Columns["colUID"].Visible = false; |
198 | |||
199 | gridViewConverter.BestFitColumns(); |
||
200 | #endregion |
||
201 | } |
||
202 | f1c9dbaa | gaqhf | |
203 | 635a8747 | gaqhf | private void templateComboBox_EditValueChanged(object sender, EventArgs e) |
204 | { |
||
205 | gridViewConverter.CloseEditor(); |
||
206 | gridViewConverter.UpdateCurrentRow(); |
||
207 | } |
||
208 | |||
209 | private void gridViewConverter_RowCellClick(object sender, DevExpress.XtraGrid.Views.Grid.RowCellClickEventArgs e) |
||
210 | { |
||
211 | if (e.Column.Name == "colcolTemplate") |
||
212 | { |
||
213 | gridViewConverter.ShowEditor(); |
||
214 | (gridViewConverter.ActiveEditor as ComboBoxEdit).ShowPopup(); |
||
215 | } |
||
216 | else if (e.Column.Name == "colcolUnit") |
||
217 | { |
||
218 | UnitForm unitForm = new UnitForm(_SPPIDUnitDT); |
||
219 | if (unitForm.ShowDialog() == DialogResult.OK) |
||
220 | { |
||
221 | gridViewConverter.SetRowCellValue(e.RowHandle, e.Column, unitForm.SelectedUnit); |
||
222 | gridViewConverter.CloseEditor(); |
||
223 | gridViewConverter.UpdateCurrentRow(); |
||
224 | } |
||
225 | } |
||
226 | } |
||
227 | 1278ba59 | gaqhf | |
228 | 23eb98bf | gaqhf | private void btnID2Project_ButtonClick(object sender, ButtonPressedEventArgs e) |
229 | { |
||
230 | fab4f207 | gaqhf | xtraFolderBrowserDialog.SelectedPath = btnID2Project.Text; |
231 | |||
232 | 23eb98bf | gaqhf | if (xtraFolderBrowserDialog.ShowDialog() == DialogResult.OK) |
233 | { |
||
234 | fab4f207 | gaqhf | if (xtraFolderBrowserDialog.SelectedPath[xtraFolderBrowserDialog.SelectedPath.Length - 1] == '\\') |
235 | xtraFolderBrowserDialog.SelectedPath = xtraFolderBrowserDialog.SelectedPath.Remove(xtraFolderBrowserDialog.SelectedPath.Length - 1); |
||
236 | Settings.Default.LatestProjectPath = xtraFolderBrowserDialog.SelectedPath; |
||
237 | Settings.Default.Save(); |
||
238 | if (InitID2Project()) |
||
239 | 635a8747 | gaqhf | { |
240 | fab4f207 | gaqhf | MessageBox.Show(Msg.SuccessProjectSelect, Msg.Information, MessageBoxButtons.OK, MessageBoxIcon.Information); |
241 | 635a8747 | gaqhf | } |
242 | fab4f207 | gaqhf | else |
243 | 23eb98bf | gaqhf | MessageBox.Show(Msg.FailProjectSelect, Msg.Warning, MessageBoxButtons.OK, MessageBoxIcon.Warning); |
244 | } |
||
245 | } |
||
246 | |||
247 | fab4f207 | gaqhf | private bool InitID2Project() |
248 | 23eb98bf | gaqhf | { |
249 | ec0c7045 | gaqhf | Project_Info _ProjectInfo = Project_Info.GetInstance(); |
250 | fab4f207 | gaqhf | _ProjectInfo.DefaultPath = Settings.Default.LatestProjectPath; |
251 | if (Project_DB.ConnTestAndCreateTable()) |
||
252 | 23eb98bf | gaqhf | { |
253 | fab4f207 | gaqhf | _ProjectInfo.Enable = true; |
254 | 171142c5 | gaqhf | btnID2Project.Text = _ProjectInfo.DefaultPath; |
255 | 23eb98bf | gaqhf | labelID2ProjectName.Text = _ProjectInfo.Name; |
256 | labelID2ProjectName.AppearanceItemCaption.ForeColor = Color.Blue; |
||
257 | labelID2ProjectStatus.Text = Msg.ConnectionSuccessful; |
||
258 | labelID2ProjectStatus.AppearanceItemCaption.ForeColor = Color.Blue; |
||
259 | fab4f207 | gaqhf | layoutControlGroupSPPIDDB.Visibility = DevExpress.XtraLayout.Utils.LayoutVisibility.Always; |
260 | layoutControlGroupItemMapping.Visibility = DevExpress.XtraLayout.Utils.LayoutVisibility.Always; |
||
261 | 23eb98bf | gaqhf | } |
262 | else |
||
263 | { |
||
264 | fab4f207 | gaqhf | _ProjectInfo.Enable = false; |
265 | 23eb98bf | gaqhf | btnID2Project.Text = ""; |
266 | labelID2ProjectName.Text = " "; |
||
267 | labelID2ProjectName.AppearanceItemCaption.ForeColor = Color.Red; |
||
268 | labelID2ProjectStatus.Text = Msg.ConnectionFail; |
||
269 | labelID2ProjectStatus.AppearanceItemCaption.ForeColor = Color.Red; |
||
270 | fab4f207 | gaqhf | layoutControlGroupSPPIDDB.Visibility = DevExpress.XtraLayout.Utils.LayoutVisibility.Never; |
271 | layoutControlGroupItemMapping.Visibility = DevExpress.XtraLayout.Utils.LayoutVisibility.Never; |
||
272 | bca86986 | gaqhf | } |
273 | fab4f207 | gaqhf | |
274 | bca86986 | gaqhf | InitMapping(); |
275 | InitSPPIDDB(); |
||
276 | |||
277 | return _ProjectInfo.Enable; |
||
278 | } |
||
279 | |||
280 | private void InitMapping() |
||
281 | { |
||
282 | Project_Info _ProjectInfo = Project_Info.GetInstance(); |
||
283 | if (_ProjectInfo.Enable) |
||
284 | { |
||
285 | InitID2Symbol(); |
||
286 | InitID2Line(); |
||
287 | InitID2LineNumber(); |
||
288 | InitID2Association(); |
||
289 | e00e891d | gaqhf | |
290 | InitETCSetting(); |
||
291 | } |
||
292 | } |
||
293 | fbdb9f2a | gaqhf | |
294 | e00e891d | gaqhf | private void InitETCSetting() |
295 | { |
||
296 | Project_Info _ProjectInfo = Project_Info.GetInstance(); |
||
297 | if (_ProjectInfo.Enable) |
||
298 | { |
||
299 | DataTable dt = Project_DB.SelectETCSetting(); |
||
300 | if (dt.Columns.Count > 0 && dt.Rows.Count > 0) |
||
301 | SPPIDUtil.ConvertToETCSetting(dt.Rows[0][0].ToString()); |
||
302 | else |
||
303 | SPPID_DBInfo.Clear(); |
||
304 | bca86986 | gaqhf | } |
305 | } |
||
306 | |||
307 | private void InitID2Symbol() |
||
308 | { |
||
309 | using (DataTable symbolDT = Project_DB.SelectProjectSymbol()) |
||
310 | { |
||
311 | symbolMappings.Clear(); |
||
312 | _ID2SymbolDT = symbolDT; |
||
313 | _ID2SymbolDT.Columns.Add("Clear"); |
||
314 | _ID2SymbolDT.Columns["Clear"].Caption = ""; |
||
315 | foreach (DataRow row in symbolDT.Rows) |
||
316 | { |
||
317 | symbolMappings.Add(new SymbolMapping() |
||
318 | { |
||
319 | UID = row["UID"] == null ? "" : row["UID"].ToString(), |
||
320 | SYMBOLNAME = row["Name"] == null ? "" : row["Name"].ToString(), |
||
321 | SPPIDSYMBOLNAME = row["SPPID_SYMBOL_PATH"] == null ? "" : row["SPPID_SYMBOL_PATH"].ToString(), |
||
322 | }); |
||
323 | } |
||
324 | } |
||
325 | } |
||
326 | |||
327 | private void InitID2Line() |
||
328 | { |
||
329 | using (DataTable lineTypes = Project_DB.SelectProjectLine()) |
||
330 | { |
||
331 | lineMappings.Clear(); |
||
332 | _ID2LineDT.Rows.Clear(); |
||
333 | foreach (DataRow row in lineTypes.Rows) |
||
334 | { |
||
335 | DataRow newRow = _ID2LineDT.NewRow(); |
||
336 | newRow["UID"] = row["UID"] == null ? "" : row["UID"].ToString(); |
||
337 | newRow["Name"] = row["Name"] == null ? "" : row["Name"].ToString(); |
||
338 | newRow["Type"] = "Line"; |
||
339 | newRow["SPPID_SYMBOL_PATH"] = row["SPPID_SYMBOL_PATH"] == null ? "" : row["SPPID_SYMBOL_PATH"].ToString(); |
||
340 | _ID2LineDT.Rows.Add(newRow); |
||
341 | |||
342 | lineMappings.Add(new LineMapping() |
||
343 | { |
||
344 | UID = row["UID"] == null ? "" : row["UID"].ToString(), |
||
345 | LINENAME = row["Name"] == null ? "" : row["Name"].ToString(), |
||
346 | SPPIDSYMBOLNAME = row["SPPID_SYMBOL_PATH"] == null ? "" : row["SPPID_SYMBOL_PATH"].ToString(), |
||
347 | }); |
||
348 | } |
||
349 | } |
||
350 | } |
||
351 | |||
352 | private void InitID2LineNumber() |
||
353 | { |
||
354 | using (DataTable linePropertiesDT = Project_DB.SelectProjectLineProperties()) |
||
355 | { |
||
356 | lineNumberMappings.Clear(); |
||
357 | _ID2LinePropertyDT = linePropertiesDT; |
||
358 | _ID2LinePropertyDT.Columns.Add("Type"); |
||
359 | foreach (DataRow row in linePropertiesDT.Rows) |
||
360 | { |
||
361 | row["Type"] = "Line Property"; |
||
362 | lineNumberMappings.Add(new LineNumberMapping() |
||
363 | { |
||
364 | UID = row["UID"] == null ? "" : row["UID"].ToString(), |
||
365 | DisplayName = row["DisplayName"] == null ? "" : row["DisplayName"].ToString(), |
||
366 | SPPIDATTRIBUTENAME = row["SPPID_ATTRIBUTE"] == null ? "" : row["SPPID_ATTRIBUTE"].ToString(), |
||
367 | SPPIDSYMBOLNAME = row["SPPID_SYMBOL_PATH"] == null ? "" : row["SPPID_SYMBOL_PATH"].ToString() |
||
368 | }); |
||
369 | } |
||
370 | } |
||
371 | } |
||
372 | |||
373 | private void InitID2Association() |
||
374 | { |
||
375 | using (DataTable associationDT = Project_DB.SelectProjectAssociation()) |
||
376 | { |
||
377 | associationMappings.Clear(); |
||
378 | _ID2AssociationDT = associationDT; |
||
379 | _ID2AssociationDT.Columns.Add("Clear"); |
||
380 | _ID2AssociationDT.Columns["Clear"].Caption = ""; |
||
381 | foreach (DataRow row in associationDT.Rows) |
||
382 | { |
||
383 | associationMappings.Add(new AssociationMapping() |
||
384 | { |
||
385 | UID = row["UID"] == null ? "" : row["UID"].ToString(), |
||
386 | DisplayAttribute = row["DisplayAttribute"] == null ? "" : row["DisplayAttribute"].ToString(), |
||
387 | Type = row["Type"] == null ? "" : row["Type"].ToString(), |
||
388 | SPPIDATTRIBUTENAME = row["SPPID_ATTRIBUTE"] == null ? "" : row["SPPID_ATTRIBUTE"].ToString(), |
||
389 | SPPIDSYMBOLNAME = row["SPPID_SYMBOL_PATH"] == null ? "" : row["SPPID_SYMBOL_PATH"].ToString() |
||
390 | }); |
||
391 | } |
||
392 | 23eb98bf | gaqhf | } |
393 | } |
||
394 | |||
395 | fab4f207 | gaqhf | private void InitSPPIDDB() |
396 | 23eb98bf | gaqhf | { |
397 | ec0c7045 | gaqhf | Project_Info _ProjectInfo = Project_Info.GetInstance(); |
398 | fab4f207 | gaqhf | if (_ProjectInfo.Enable) |
399 | { |
||
400 | DataTable dt = Project_DB.SelectSPPID_DB_INFO(); |
||
401 | ec0c7045 | gaqhf | if (dt.Columns.Count > 0 && dt.Rows.Count > 0) |
402 | SPPIDUtil.ConvertToSPPIDInfo(dt.Rows[0][0].ToString()); |
||
403 | else |
||
404 | SPPID_DBInfo.Clear(); |
||
405 | fab4f207 | gaqhf | } |
406 | ec0c7045 | gaqhf | |
407 | 635a8747 | gaqhf | templateComboBox.Items.Clear(); |
408 | ec0c7045 | gaqhf | SPPID_DBInfo _SPPIDInfo = SPPID_DBInfo.GetInstance(); |
409 | 23eb98bf | gaqhf | if (_SPPIDInfo.Enable) |
410 | { |
||
411 | labelSPPIDPlantName.Text = _SPPIDInfo.SelectedPlant; |
||
412 | labelSPPIDPlantName.AppearanceItemCaption.ForeColor = Color.Blue; |
||
413 | labelSPPIDDBStatus.Text = Msg.ConnectionSuccessful; |
||
414 | labelSPPIDDBStatus.AppearanceItemCaption.ForeColor = Color.Blue; |
||
415 | 635a8747 | gaqhf | |
416 | string TemplatePath = SPPID_DB.GetPlantPID_T_OPTIONSETTING_Value("PID Template Path"); |
||
417 | if (!string.IsNullOrEmpty(TemplatePath)) |
||
418 | templateComboBox.Items.AddRange(Directory.GetFiles(TemplatePath, "*.pid").ToList().Select(filePath => Path.GetFileName(filePath)).ToList()); |
||
419 | |||
420 | _SPPIDUnitDT = SPPID_DB.GetUnitTree(); |
||
421 | |||
422 | layoutControlGroupAutoConverter.Enabled = true; |
||
423 | 23eb98bf | gaqhf | } |
424 | else |
||
425 | { |
||
426 | labelSPPIDPlantName.Text = " "; |
||
427 | labelSPPIDPlantName.AppearanceItemCaption.ForeColor = Color.Red; |
||
428 | labelSPPIDDBStatus.Text = Msg.ConnectionFail; |
||
429 | labelSPPIDDBStatus.AppearanceItemCaption.ForeColor = Color.Red; |
||
430 | bca86986 | gaqhf | |
431 | 635a8747 | gaqhf | layoutControlGroupAutoConverter.Enabled = false; |
432 | 23eb98bf | gaqhf | } |
433 | bca86986 | gaqhf | |
434 | 635a8747 | gaqhf | _DicDocuments.Clear(); |
435 | _ConverterDT.Rows.Clear(); |
||
436 | bca86986 | gaqhf | InitSPPIDSymbolTreeTable(); |
437 | 23eb98bf | gaqhf | } |
438 | |||
439 | bca86986 | gaqhf | private void InitSPPIDSymbolTreeTable() |
440 | 23eb98bf | gaqhf | { |
441 | bca86986 | gaqhf | SPPID_DBInfo _SPPIDInfo = SPPID_DBInfo.GetInstance(); |
442 | |||
443 | _SPPIDSymbolPathDT = new DataTable(); |
||
444 | _SPPIDSymbolPathDT.Columns.Add("ID"); |
||
445 | _SPPIDSymbolPathDT.Columns.Add("Parent"); |
||
446 | _SPPIDSymbolPathDT.Columns.Add("Name"); |
||
447 | _SPPIDSymbolPathDT.Columns.Add("FullPath"); |
||
448 | |||
449 | if (_SPPIDInfo.Enable) |
||
450 | 23eb98bf | gaqhf | { |
451 | bca86986 | gaqhf | string symbolPath = SPPID_DB.GetPlantPID_T_OPTIONSETTING_Value("Catalog Explorer root path"); |
452 | DirectoryInfo info = new DirectoryInfo(symbolPath); |
||
453 | _SPPIDSymbolPathDT.Rows.Add(new object[] { "0", "-1", info.Name }); |
||
454 | loop(info, "0", symbolPath); |
||
455 | 23eb98bf | gaqhf | } |
456 | bca86986 | gaqhf | } |
457 | 23eb98bf | gaqhf | |
458 | bca86986 | gaqhf | private void loop(DirectoryInfo parentInfo, string parentUID, string defaultPath) |
459 | { |
||
460 | DirectoryInfo[] infos = parentInfo.GetDirectories(); |
||
461 | foreach (DirectoryInfo info in infos) |
||
462 | { |
||
463 | string uid = Guid.NewGuid().ToString(); |
||
464 | _SPPIDSymbolPathDT.Rows.Add(new object[] { uid, parentUID, info.Name }); |
||
465 | loop(info, uid, defaultPath); |
||
466 | |||
467 | FileInfo[] files = info.GetFiles("*.sym"); |
||
468 | foreach (FileInfo fileInfo in files) |
||
469 | { |
||
470 | _SPPIDSymbolPathDT.Rows.Add(new object[] { Guid.NewGuid().ToString(), uid, fileInfo.Name, fileInfo.FullName.Replace(defaultPath, "") }); |
||
471 | } |
||
472 | } |
||
473 | 23eb98bf | gaqhf | } |
474 | |||
475 | 1278ba59 | gaqhf | private void btnLoadFile_Click(object sender, EventArgs e) |
476 | { |
||
477 | ec0c7045 | gaqhf | Project_Info _ProjectInfo = Project_Info.GetInstance(); |
478 | 23eb98bf | gaqhf | if (!_ProjectInfo.Enable) |
479 | { |
||
480 | MessageBox.Show(Msg.PleaseSetID2ProjectInfo, Msg.Warning, MessageBoxButtons.OK, MessageBoxIcon.Warning); |
||
481 | return; |
||
482 | } |
||
483 | 1278ba59 | gaqhf | |
484 | 171142c5 | gaqhf | xtraOpenFileDialog.InitialDirectory = _ProjectInfo.TempDirPath; |
485 | 23eb98bf | gaqhf | if (xtraOpenFileDialog.ShowDialog() == DialogResult.OK) |
486 | 1278ba59 | gaqhf | { |
487 | 23eb98bf | gaqhf | foreach (string fileName in xtraOpenFileDialog.FileNames) |
488 | 1278ba59 | gaqhf | { |
489 | bca86986 | gaqhf | SPPID_Document document = new SPPID_Document(fileName); |
490 | 4314b3f3 | gaqhf | |
491 | bca86986 | gaqhf | DataRow[] rows = _ConverterDT.Select(string.Format("colDrawingFilePath = '{0}'", fileName)); |
492 | 0d8062b2 | gaqhf | DataRow row; |
493 | if (rows.Length == 0) |
||
494 | { |
||
495 | bca86986 | gaqhf | row = _ConverterDT.NewRow(); |
496 | 0d8062b2 | gaqhf | row["colDrawingFileName"] = Path.GetFileNameWithoutExtension(fileName); |
497 | row["colDrawingFilePath"] = fileName; |
||
498 | row["colDrawingNumber"] = document.DWGNAME; |
||
499 | row["colDrawingName"] = document.DWGNAME; |
||
500 | if (document.Enable) |
||
501 | row["colStatus"] = "Ready"; |
||
502 | else |
||
503 | row["colStatus"] = "Error"; |
||
504 | row["colUID"] = ""; |
||
505 | bca86986 | gaqhf | _ConverterDT.Rows.Add(row); |
506 | 0d8062b2 | gaqhf | } |
507 | if (!_DicDocuments.ContainsKey(fileName)) |
||
508 | _DicDocuments.Add(fileName, null); |
||
509 | |||
510 | _DicDocuments[fileName] = document; |
||
511 | 1278ba59 | gaqhf | } |
512 | } |
||
513 | f6d90b6e | gaqhf | } |
514 | 1278ba59 | gaqhf | |
515 | private void btnRun_Click(object sender, EventArgs e) |
||
516 | { |
||
517 | 5dfb8a24 | gaqhf | #if DEBUG |
518 | 30a9ffce | gaqhf | //SPPID_Document document = new SPPID_Document(@"Z:\HanKyouHo\temp\Isocynates\Temp\11111.xml"); |
519 | SPPID_Document document = new SPPID_Document(@"Z:\HanKyouHo\temp\Isocynates\Temp\zIsocynates-325_Page75.xml"); |
||
520 | 5dfb8a24 | gaqhf | document.SymbolMappings = symbolMappings; |
521 | document.LineMappings = lineMappings; |
||
522 | document.LineNumberMappings = lineNumberMappings; |
||
523 | document.AssociationMappings = associationMappings; |
||
524 | document.ETCSetting = ETCSetting.GetInstance(); |
||
525 | f1c9dbaa | gaqhf | |
526 | 5dfb8a24 | gaqhf | document.SetSPPIDInfo(); |
527 | 4314b3f3 | gaqhf | |
528 | 8aa6f2db | gaqhf | if (document.SetSPPIDMapping() && document.Enable) |
529 | 4314b3f3 | gaqhf | { |
530 | 5e6ecf05 | gaqhf | AutoModeling modeling = new AutoModeling(document, commandControl.Application.RADApplication); |
531 | 5dfb8a24 | gaqhf | modeling.Run(); |
532 | 4314b3f3 | gaqhf | } |
533 | |||
534 | 5dfb8a24 | gaqhf | return; |
535 | #endif |
||
536 | |||
537 | //_Documents.Clear(); |
||
538 | |||
539 | //foreach (int rowHandle in gridViewConverter.GetSelectedRows()) |
||
540 | //{ |
||
541 | // string _FilePath = gridViewConverter.GetRowCellDisplayText(rowHandle, "colDrawingFilePath"); |
||
542 | // string _Unit = gridViewConverter.GetRowCellDisplayText(rowHandle, "colUnit"); |
||
543 | // string _Template = gridViewConverter.GetRowCellDisplayText(rowHandle, "colTemplate"); |
||
544 | // string _DrawingNumber = gridViewConverter.GetRowCellDisplayText(rowHandle, "colDrawingNumber"); |
||
545 | // string _DrawingName = gridViewConverter.GetRowCellDisplayText(rowHandle, "colDrawingName"); |
||
546 | // SPPID_Document document = _DicDocuments[_FilePath]; |
||
547 | // document.Unit = _Unit; |
||
548 | // document.Template = _Template; |
||
549 | // document.DrawingNumber = _DrawingNumber; |
||
550 | // document.DrawingName = _DrawingName; |
||
551 | // _Documents.Add(document); |
||
552 | //} |
||
553 | |||
554 | 1278ba59 | gaqhf | DialogResult = DialogResult.OK; |
555 | 96a2080c | gaqhf | } |
556 | 23eb98bf | gaqhf | |
557 | private void btnSPPIDDB_Click(object sender, EventArgs e) |
||
558 | { |
||
559 | SPPID_DB_SettingForm form = new SPPID_DB_SettingForm(); |
||
560 | if (form.ShowDialog() == DialogResult.OK) |
||
561 | fab4f207 | gaqhf | InitSPPIDDB(); |
562 | 23eb98bf | gaqhf | } |
563 | df4559fc | gaqhf | |
564 | private void btnItemMapping_Click(object sender, EventArgs e) |
||
565 | { |
||
566 | ec0c7045 | gaqhf | Project_Info _ProjectInfo = Project_Info.GetInstance(); |
567 | df4559fc | gaqhf | if (!_ProjectInfo.Enable) |
568 | { |
||
569 | MessageBox.Show(Msg.PleaseSetID2ProjectInfo, Msg.Warning, MessageBoxButtons.OK, MessageBoxIcon.Warning); |
||
570 | return; |
||
571 | } |
||
572 | |||
573 | bca86986 | gaqhf | MappingForm form = new MappingForm(_ID2SymbolDT,_SPPIDSymbolPathDT, _ID2LineDT, _ID2LinePropertyDT, _ID2AssociationDT); |
574 | df4559fc | gaqhf | form.ShowDialog(); |
575 | bca86986 | gaqhf | InitMapping(); |
576 | df4559fc | gaqhf | } |
577 | 4314b3f3 | gaqhf | private List<int> prevSelectedList = new List<int>(); |
578 | |||
579 | private void gridViewConverter_SelectionChanged(object sender, DevExpress.Data.SelectionChangedEventArgs e) |
||
580 | { |
||
581 | if (e.Action == CollectionChangeAction.Add) |
||
582 | { |
||
583 | string _Unit = gridViewConverter.GetRowCellDisplayText(e.ControllerRow, "colUnit"); |
||
584 | string _Template = gridViewConverter.GetRowCellDisplayText(e.ControllerRow, "colTemplate"); |
||
585 | |||
586 | if (string.IsNullOrEmpty(_Unit) || string.IsNullOrEmpty(_Template)) |
||
587 | gridViewConverter.UnselectRow(e.ControllerRow); |
||
588 | } |
||
589 | else if (e.Action == CollectionChangeAction.Refresh) |
||
590 | { |
||
591 | foreach (int rowHandle in gridViewConverter.GetSelectedRows()) |
||
592 | { |
||
593 | string _Unit = gridViewConverter.GetRowCellDisplayText(rowHandle, "colUnit"); |
||
594 | string _Template = gridViewConverter.GetRowCellDisplayText(rowHandle, "colTemplate"); |
||
595 | |||
596 | if (string.IsNullOrEmpty(_Unit) || string.IsNullOrEmpty(_Template)) |
||
597 | gridViewConverter.UnselectRow(rowHandle); |
||
598 | } |
||
599 | |||
600 | List<int> selectedRowHandleList = gridViewConverter.GetSelectedRows().ToList(); |
||
601 | var firstNotSecond = prevSelectedList.Except(selectedRowHandleList).ToList(); |
||
602 | var secondNotFirst = selectedRowHandleList.Except(prevSelectedList).ToList(); |
||
603 | 635a8747 | gaqhf | |
604 | 4314b3f3 | gaqhf | if (!firstNotSecond.Any() && !secondNotFirst.Any()) |
605 | { |
||
606 | this.gridViewConverter.SelectionChanged -= new DevExpress.Data.SelectionChangedEventHandler(this.gridViewConverter_SelectionChanged); |
||
607 | gridViewConverter.ClearSelection(); |
||
608 | this.gridViewConverter.SelectionChanged += new DevExpress.Data.SelectionChangedEventHandler(this.gridViewConverter_SelectionChanged); |
||
609 | } |
||
610 | } |
||
611 | |||
612 | prevSelectedList = gridViewConverter.GetSelectedRows().ToList(); |
||
613 | } |
||
614 | 96a2080c | gaqhf | } |
615 | } |