hytos / DTI_PID / SPPIDConverter / ConverterForm.cs @ 1b261371
이력 | 보기 | 이력해설 | 다운로드 (23.2 KB)
1 |
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 |
using Converter.BaseModel; |
12 |
using DevExpress.XtraEditors.Repository; |
13 |
using DevExpress.XtraEditors.Controls; |
14 |
using DevExpress.XtraEditors; |
15 |
using System.Globalization; |
16 |
using System.Threading; |
17 |
using System.IO; |
18 |
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 |
|
24 |
namespace Converter.SPPID |
25 |
{ |
26 |
public partial class ConverterForm : DevExpress.XtraBars.Ribbon.RibbonForm |
27 |
{ |
28 |
private Dictionary<string, SPPID_Document> _DicDocuments = new Dictionary<string, SPPID_Document>(); |
29 |
private List<SPPID_Document> _Documents = new List<SPPID_Document>(); |
30 |
public List<SPPID_Document> Documents { get { return _Documents; } } |
31 |
private DataTable _ConverterDT = new DataTable(); |
32 |
private DataTable _SPPIDSymbolPathDT = new DataTable(); |
33 |
private DataTable _SPPIDUnitDT = new DataTable(); |
34 |
private RepositoryItemComboBox templateComboBox; |
35 |
|
36 |
|
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 |
|
42 |
private List<SymbolMapping> symbolMappings = new List<SymbolMapping>(); |
43 |
private List<LineMapping> lineMappings = new List<LineMapping>(); |
44 |
private List<LineNumberMapping> lineNumberMappings = new List<LineNumberMapping>(); |
45 |
private List<AssociationMapping> associationMappings = new List<AssociationMapping>(); |
46 |
|
47 |
public ConverterForm() |
48 |
{ |
49 |
InitializeComponent(); |
50 |
|
51 |
CultureInfo culture = CultureInfo.GetCultureInfo("ko"); |
52 |
Msg.Culture = culture; |
53 |
|
54 |
InitUsedDataTable(); |
55 |
InitGridControl(); |
56 |
InitID2Project(); |
57 |
} |
58 |
|
59 |
private void InitUsedDataTable() |
60 |
{ |
61 |
// Converter Table |
62 |
DataColumn col = _ConverterDT.Columns.Add("colDrawingFileName"); |
63 |
col.Caption = "Drawing File Name"; |
64 |
col = _ConverterDT.Columns.Add("colDrawingFilePath"); |
65 |
col.Caption = "DrawingFilePath"; |
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 |
|
78 |
col = _ID2LineDT.Columns.Add("UID"); |
79 |
col = _ID2LineDT.Columns.Add("Name"); |
80 |
col.Caption = "Name"; |
81 |
col = _ID2LineDT.Columns.Add("Type"); |
82 |
col.Caption = "Type"; |
83 |
col = _ID2LineDT.Columns.Add("SPPID_SYMBOL_PATH"); |
84 |
col.Caption = "SPPID Symbol Path"; |
85 |
col = _ID2LineDT.Columns.Add("Clear"); |
86 |
col.Caption = ""; |
87 |
} |
88 |
|
89 |
private void InitGridControl() |
90 |
{ |
91 |
#region Converter Page |
92 |
gridViewConverter.OptionsSelection.MultiSelect = true; |
93 |
gridViewConverter.OptionsSelection.MultiSelectMode = DevExpress.XtraGrid.Views.Grid.GridMultiSelectMode.CheckBoxRowSelect; |
94 |
|
95 |
gridControlConverter.DataSource = _ConverterDT; |
96 |
|
97 |
templateComboBox = new RepositoryItemComboBox(); |
98 |
templateComboBox.TextEditStyle = TextEditStyles.DisableTextEditor; |
99 |
templateComboBox.EditValueChanged += templateComboBox_EditValueChanged; |
100 |
gridControlConverter.RepositoryItems.Add(templateComboBox); |
101 |
gridViewConverter.Columns["colTemplate"].ColumnEdit = templateComboBox; |
102 |
|
103 |
gridViewConverter.Columns["colUnit"].OptionsColumn.AllowEdit = false; |
104 |
gridViewConverter.Columns["colDrawingFileName"].OptionsColumn.AllowEdit = false; |
105 |
gridViewConverter.Columns["colUnit"].OptionsColumn.ReadOnly = true; |
106 |
gridViewConverter.Columns["colStatus"].OptionsColumn.AllowEdit = false; |
107 |
gridViewConverter.Columns["colDrawingFilePath"].Visible = false; |
108 |
gridViewConverter.Columns["colUID"].Visible = false; |
109 |
|
110 |
gridViewConverter.BestFitColumns(); |
111 |
#endregion |
112 |
} |
113 |
private void templateComboBox_EditValueChanged(object sender, EventArgs e) |
114 |
{ |
115 |
gridViewConverter.CloseEditor(); |
116 |
gridViewConverter.UpdateCurrentRow(); |
117 |
} |
118 |
|
119 |
private void gridViewConverter_RowCellClick(object sender, DevExpress.XtraGrid.Views.Grid.RowCellClickEventArgs e) |
120 |
{ |
121 |
if (e.Column.Name == "colcolTemplate") |
122 |
{ |
123 |
gridViewConverter.ShowEditor(); |
124 |
(gridViewConverter.ActiveEditor as ComboBoxEdit).ShowPopup(); |
125 |
} |
126 |
else if (e.Column.Name == "colcolUnit") |
127 |
{ |
128 |
UnitForm unitForm = new UnitForm(_SPPIDUnitDT); |
129 |
if (unitForm.ShowDialog() == DialogResult.OK) |
130 |
{ |
131 |
gridViewConverter.SetRowCellValue(e.RowHandle, e.Column, unitForm.SelectedUnit); |
132 |
gridViewConverter.CloseEditor(); |
133 |
gridViewConverter.UpdateCurrentRow(); |
134 |
} |
135 |
} |
136 |
} |
137 |
|
138 |
private void btnID2Project_ButtonClick(object sender, ButtonPressedEventArgs e) |
139 |
{ |
140 |
xtraFolderBrowserDialog.SelectedPath = btnID2Project.Text; |
141 |
|
142 |
if (xtraFolderBrowserDialog.ShowDialog() == DialogResult.OK) |
143 |
{ |
144 |
if (xtraFolderBrowserDialog.SelectedPath[xtraFolderBrowserDialog.SelectedPath.Length - 1] == '\\') |
145 |
xtraFolderBrowserDialog.SelectedPath = xtraFolderBrowserDialog.SelectedPath.Remove(xtraFolderBrowserDialog.SelectedPath.Length - 1); |
146 |
Settings.Default.LatestProjectPath = xtraFolderBrowserDialog.SelectedPath; |
147 |
Settings.Default.Save(); |
148 |
if (InitID2Project()) |
149 |
{ |
150 |
MessageBox.Show(Msg.SuccessProjectSelect, Msg.Information, MessageBoxButtons.OK, MessageBoxIcon.Information); |
151 |
} |
152 |
else |
153 |
MessageBox.Show(Msg.FailProjectSelect, Msg.Warning, MessageBoxButtons.OK, MessageBoxIcon.Warning); |
154 |
} |
155 |
} |
156 |
|
157 |
private bool InitID2Project() |
158 |
{ |
159 |
Project_Info _ProjectInfo = Project_Info.GetInstance(); |
160 |
_ProjectInfo.DefaultPath = Settings.Default.LatestProjectPath; |
161 |
if (Project_DB.ConnTestAndCreateTable()) |
162 |
{ |
163 |
_ProjectInfo.Enable = true; |
164 |
btnID2Project.Text = _ProjectInfo.DefaultPath; |
165 |
labelID2ProjectName.Text = _ProjectInfo.Name; |
166 |
labelID2ProjectName.AppearanceItemCaption.ForeColor = Color.Blue; |
167 |
labelID2ProjectStatus.Text = Msg.ConnectionSuccessful; |
168 |
labelID2ProjectStatus.AppearanceItemCaption.ForeColor = Color.Blue; |
169 |
layoutControlGroupSPPIDDB.Visibility = DevExpress.XtraLayout.Utils.LayoutVisibility.Always; |
170 |
layoutControlGroupItemMapping.Visibility = DevExpress.XtraLayout.Utils.LayoutVisibility.Always; |
171 |
} |
172 |
else |
173 |
{ |
174 |
_ProjectInfo.Enable = false; |
175 |
btnID2Project.Text = ""; |
176 |
labelID2ProjectName.Text = " "; |
177 |
labelID2ProjectName.AppearanceItemCaption.ForeColor = Color.Red; |
178 |
labelID2ProjectStatus.Text = Msg.ConnectionFail; |
179 |
labelID2ProjectStatus.AppearanceItemCaption.ForeColor = Color.Red; |
180 |
layoutControlGroupSPPIDDB.Visibility = DevExpress.XtraLayout.Utils.LayoutVisibility.Never; |
181 |
layoutControlGroupItemMapping.Visibility = DevExpress.XtraLayout.Utils.LayoutVisibility.Never; |
182 |
} |
183 |
|
184 |
InitMapping(); |
185 |
InitSPPIDDB(); |
186 |
|
187 |
return _ProjectInfo.Enable; |
188 |
} |
189 |
|
190 |
private void InitMapping() |
191 |
{ |
192 |
Project_Info _ProjectInfo = Project_Info.GetInstance(); |
193 |
if (_ProjectInfo.Enable) |
194 |
{ |
195 |
InitID2Symbol(); |
196 |
InitID2Line(); |
197 |
InitID2LineNumber(); |
198 |
InitID2Association(); |
199 |
|
200 |
InitETCSetting(); |
201 |
} |
202 |
} |
203 |
|
204 |
private void InitETCSetting() |
205 |
{ |
206 |
Project_Info _ProjectInfo = Project_Info.GetInstance(); |
207 |
if (_ProjectInfo.Enable) |
208 |
{ |
209 |
DataTable dt = Project_DB.SelectETCSetting(); |
210 |
if (dt.Columns.Count > 0 && dt.Rows.Count > 0) |
211 |
SPPIDUtil.ConvertToETCSetting(dt.Rows[0][0].ToString()); |
212 |
else |
213 |
SPPID_DBInfo.Clear(); |
214 |
} |
215 |
} |
216 |
|
217 |
private void InitID2Symbol() |
218 |
{ |
219 |
using (DataTable symbolDT = Project_DB.SelectProjectSymbol()) |
220 |
{ |
221 |
symbolMappings.Clear(); |
222 |
_ID2SymbolDT = symbolDT; |
223 |
_ID2SymbolDT.Columns.Add("Clear"); |
224 |
_ID2SymbolDT.Columns["Clear"].Caption = ""; |
225 |
foreach (DataRow row in symbolDT.Rows) |
226 |
{ |
227 |
symbolMappings.Add(new SymbolMapping() |
228 |
{ |
229 |
UID = row["UID"] == null ? "" : row["UID"].ToString(), |
230 |
SYMBOLNAME = row["Name"] == null ? "" : row["Name"].ToString(), |
231 |
SPPIDSYMBOLNAME = row["SPPID_SYMBOL_PATH"] == null ? "" : row["SPPID_SYMBOL_PATH"].ToString(), |
232 |
}); |
233 |
} |
234 |
} |
235 |
} |
236 |
|
237 |
private void InitID2Line() |
238 |
{ |
239 |
using (DataTable lineTypes = Project_DB.SelectProjectLine()) |
240 |
{ |
241 |
lineMappings.Clear(); |
242 |
_ID2LineDT.Rows.Clear(); |
243 |
foreach (DataRow row in lineTypes.Rows) |
244 |
{ |
245 |
DataRow newRow = _ID2LineDT.NewRow(); |
246 |
newRow["UID"] = row["UID"] == null ? "" : row["UID"].ToString(); |
247 |
newRow["Name"] = row["Name"] == null ? "" : row["Name"].ToString(); |
248 |
newRow["Type"] = "Line"; |
249 |
newRow["SPPID_SYMBOL_PATH"] = row["SPPID_SYMBOL_PATH"] == null ? "" : row["SPPID_SYMBOL_PATH"].ToString(); |
250 |
_ID2LineDT.Rows.Add(newRow); |
251 |
|
252 |
lineMappings.Add(new LineMapping() |
253 |
{ |
254 |
UID = row["UID"] == null ? "" : row["UID"].ToString(), |
255 |
LINENAME = row["Name"] == null ? "" : row["Name"].ToString(), |
256 |
SPPIDSYMBOLNAME = row["SPPID_SYMBOL_PATH"] == null ? "" : row["SPPID_SYMBOL_PATH"].ToString(), |
257 |
}); |
258 |
} |
259 |
} |
260 |
} |
261 |
|
262 |
private void InitID2LineNumber() |
263 |
{ |
264 |
using (DataTable linePropertiesDT = Project_DB.SelectProjectLineProperties()) |
265 |
{ |
266 |
lineNumberMappings.Clear(); |
267 |
_ID2LinePropertyDT = linePropertiesDT; |
268 |
_ID2LinePropertyDT.Columns.Add("Type"); |
269 |
foreach (DataRow row in linePropertiesDT.Rows) |
270 |
{ |
271 |
row["Type"] = "Line Property"; |
272 |
lineNumberMappings.Add(new LineNumberMapping() |
273 |
{ |
274 |
UID = row["UID"] == null ? "" : row["UID"].ToString(), |
275 |
DisplayName = row["DisplayName"] == null ? "" : row["DisplayName"].ToString(), |
276 |
SPPIDATTRIBUTENAME = row["SPPID_ATTRIBUTE"] == null ? "" : row["SPPID_ATTRIBUTE"].ToString(), |
277 |
SPPIDSYMBOLNAME = row["SPPID_SYMBOL_PATH"] == null ? "" : row["SPPID_SYMBOL_PATH"].ToString() |
278 |
}); |
279 |
} |
280 |
} |
281 |
} |
282 |
|
283 |
private void InitID2Association() |
284 |
{ |
285 |
using (DataTable associationDT = Project_DB.SelectProjectAssociation()) |
286 |
{ |
287 |
associationMappings.Clear(); |
288 |
_ID2AssociationDT = associationDT; |
289 |
_ID2AssociationDT.Columns.Add("Clear"); |
290 |
_ID2AssociationDT.Columns["Clear"].Caption = ""; |
291 |
foreach (DataRow row in associationDT.Rows) |
292 |
{ |
293 |
associationMappings.Add(new AssociationMapping() |
294 |
{ |
295 |
UID = row["UID"] == null ? "" : row["UID"].ToString(), |
296 |
DisplayAttribute = row["DisplayAttribute"] == null ? "" : row["DisplayAttribute"].ToString(), |
297 |
Type = row["Type"] == null ? "" : row["Type"].ToString(), |
298 |
SPPIDATTRIBUTENAME = row["SPPID_ATTRIBUTE"] == null ? "" : row["SPPID_ATTRIBUTE"].ToString(), |
299 |
SPPIDSYMBOLNAME = row["SPPID_SYMBOL_PATH"] == null ? "" : row["SPPID_SYMBOL_PATH"].ToString() |
300 |
}); |
301 |
} |
302 |
} |
303 |
} |
304 |
|
305 |
private void InitSPPIDDB() |
306 |
{ |
307 |
Project_Info _ProjectInfo = Project_Info.GetInstance(); |
308 |
if (_ProjectInfo.Enable) |
309 |
{ |
310 |
DataTable dt = Project_DB.SelectSPPID_DB_INFO(); |
311 |
if (dt.Columns.Count > 0 && dt.Rows.Count > 0) |
312 |
SPPIDUtil.ConvertToSPPIDInfo(dt.Rows[0][0].ToString()); |
313 |
else |
314 |
SPPID_DBInfo.Clear(); |
315 |
} |
316 |
|
317 |
templateComboBox.Items.Clear(); |
318 |
SPPID_DBInfo _SPPIDInfo = SPPID_DBInfo.GetInstance(); |
319 |
if (_SPPIDInfo.Enable) |
320 |
{ |
321 |
labelSPPIDPlantName.Text = _SPPIDInfo.SelectedPlant; |
322 |
labelSPPIDPlantName.AppearanceItemCaption.ForeColor = Color.Blue; |
323 |
labelSPPIDDBStatus.Text = Msg.ConnectionSuccessful; |
324 |
labelSPPIDDBStatus.AppearanceItemCaption.ForeColor = Color.Blue; |
325 |
|
326 |
string TemplatePath = SPPID_DB.GetPlantPID_T_OPTIONSETTING_Value("PID Template Path"); |
327 |
if (!string.IsNullOrEmpty(TemplatePath)) |
328 |
templateComboBox.Items.AddRange(Directory.GetFiles(TemplatePath, "*.pid").ToList().Select(filePath => Path.GetFileName(filePath)).ToList()); |
329 |
|
330 |
_SPPIDUnitDT = SPPID_DB.GetUnitTree(); |
331 |
|
332 |
layoutControlGroupAutoConverter.Enabled = true; |
333 |
} |
334 |
else |
335 |
{ |
336 |
labelSPPIDPlantName.Text = " "; |
337 |
labelSPPIDPlantName.AppearanceItemCaption.ForeColor = Color.Red; |
338 |
labelSPPIDDBStatus.Text = Msg.ConnectionFail; |
339 |
labelSPPIDDBStatus.AppearanceItemCaption.ForeColor = Color.Red; |
340 |
|
341 |
layoutControlGroupAutoConverter.Enabled = false; |
342 |
} |
343 |
|
344 |
_DicDocuments.Clear(); |
345 |
_ConverterDT.Rows.Clear(); |
346 |
InitSPPIDSymbolTreeTable(); |
347 |
} |
348 |
|
349 |
private void InitSPPIDSymbolTreeTable() |
350 |
{ |
351 |
SPPID_DBInfo _SPPIDInfo = SPPID_DBInfo.GetInstance(); |
352 |
|
353 |
_SPPIDSymbolPathDT = new DataTable(); |
354 |
_SPPIDSymbolPathDT.Columns.Add("ID"); |
355 |
_SPPIDSymbolPathDT.Columns.Add("Parent"); |
356 |
_SPPIDSymbolPathDT.Columns.Add("Name"); |
357 |
_SPPIDSymbolPathDT.Columns.Add("FullPath"); |
358 |
|
359 |
if (_SPPIDInfo.Enable) |
360 |
{ |
361 |
string symbolPath = SPPID_DB.GetPlantPID_T_OPTIONSETTING_Value("Catalog Explorer root path"); |
362 |
DirectoryInfo info = new DirectoryInfo(symbolPath); |
363 |
_SPPIDSymbolPathDT.Rows.Add(new object[] { "0", "-1", info.Name }); |
364 |
loop(info, "0", symbolPath); |
365 |
} |
366 |
} |
367 |
|
368 |
private void loop(DirectoryInfo parentInfo, string parentUID, string defaultPath) |
369 |
{ |
370 |
DirectoryInfo[] infos = parentInfo.GetDirectories(); |
371 |
foreach (DirectoryInfo info in infos) |
372 |
{ |
373 |
string uid = Guid.NewGuid().ToString(); |
374 |
_SPPIDSymbolPathDT.Rows.Add(new object[] { uid, parentUID, info.Name }); |
375 |
loop(info, uid, defaultPath); |
376 |
|
377 |
FileInfo[] files = info.GetFiles("*.sym"); |
378 |
foreach (FileInfo fileInfo in files) |
379 |
{ |
380 |
_SPPIDSymbolPathDT.Rows.Add(new object[] { Guid.NewGuid().ToString(), uid, fileInfo.Name, fileInfo.FullName.Replace(defaultPath, "") }); |
381 |
} |
382 |
} |
383 |
} |
384 |
|
385 |
private void btnLoadFile_Click(object sender, EventArgs e) |
386 |
{ |
387 |
Project_Info _ProjectInfo = Project_Info.GetInstance(); |
388 |
if (!_ProjectInfo.Enable) |
389 |
{ |
390 |
MessageBox.Show(Msg.PleaseSetID2ProjectInfo, Msg.Warning, MessageBoxButtons.OK, MessageBoxIcon.Warning); |
391 |
return; |
392 |
} |
393 |
|
394 |
xtraOpenFileDialog.InitialDirectory = _ProjectInfo.TempDirPath; |
395 |
if (xtraOpenFileDialog.ShowDialog() == DialogResult.OK) |
396 |
{ |
397 |
foreach (string fileName in xtraOpenFileDialog.FileNames) |
398 |
{ |
399 |
SPPID_Document document = new SPPID_Document(fileName); |
400 |
|
401 |
DataRow[] rows = _ConverterDT.Select(string.Format("colDrawingFilePath = '{0}'", fileName)); |
402 |
DataRow row; |
403 |
if (rows.Length == 0) |
404 |
{ |
405 |
row = _ConverterDT.NewRow(); |
406 |
row["colDrawingFileName"] = Path.GetFileNameWithoutExtension(fileName); |
407 |
row["colDrawingFilePath"] = fileName; |
408 |
row["colDrawingNumber"] = document.DWGNAME; |
409 |
row["colDrawingName"] = document.DWGNAME; |
410 |
if (document.Enable) |
411 |
row["colStatus"] = "Ready"; |
412 |
else |
413 |
row["colStatus"] = "Error"; |
414 |
row["colUID"] = ""; |
415 |
_ConverterDT.Rows.Add(row); |
416 |
} |
417 |
if (!_DicDocuments.ContainsKey(fileName)) |
418 |
_DicDocuments.Add(fileName, null); |
419 |
|
420 |
_DicDocuments[fileName] = document; |
421 |
} |
422 |
} |
423 |
} |
424 |
|
425 |
private void btnRun_Click(object sender, EventArgs e) |
426 |
{ |
427 |
#if DEBUG |
428 |
SPPID_Document document = new SPPID_Document(@"Z:\HanKyouHo\temp\Isocynates\Temp\zIsocynates-325_Page75.xml"); |
429 |
document.SymbolMappings = symbolMappings; |
430 |
document.LineMappings = lineMappings; |
431 |
document.LineNumberMappings = lineNumberMappings; |
432 |
document.AssociationMappings = associationMappings; |
433 |
document.ETCSetting = ETCSetting.GetInstance(); |
434 |
document.SetSPPIDInfo(); |
435 |
|
436 |
if (document.SetSPPIDMapping()) |
437 |
{ |
438 |
AutoModeling modeling = new AutoModeling(document); |
439 |
modeling.Run(); |
440 |
} |
441 |
|
442 |
return; |
443 |
#endif |
444 |
|
445 |
//_Documents.Clear(); |
446 |
|
447 |
//foreach (int rowHandle in gridViewConverter.GetSelectedRows()) |
448 |
//{ |
449 |
// string _FilePath = gridViewConverter.GetRowCellDisplayText(rowHandle, "colDrawingFilePath"); |
450 |
// string _Unit = gridViewConverter.GetRowCellDisplayText(rowHandle, "colUnit"); |
451 |
// string _Template = gridViewConverter.GetRowCellDisplayText(rowHandle, "colTemplate"); |
452 |
// string _DrawingNumber = gridViewConverter.GetRowCellDisplayText(rowHandle, "colDrawingNumber"); |
453 |
// string _DrawingName = gridViewConverter.GetRowCellDisplayText(rowHandle, "colDrawingName"); |
454 |
// SPPID_Document document = _DicDocuments[_FilePath]; |
455 |
// document.Unit = _Unit; |
456 |
// document.Template = _Template; |
457 |
// document.DrawingNumber = _DrawingNumber; |
458 |
// document.DrawingName = _DrawingName; |
459 |
// _Documents.Add(document); |
460 |
//} |
461 |
|
462 |
DialogResult = DialogResult.OK; |
463 |
} |
464 |
|
465 |
private void btnSPPIDDB_Click(object sender, EventArgs e) |
466 |
{ |
467 |
SPPID_DB_SettingForm form = new SPPID_DB_SettingForm(); |
468 |
if (form.ShowDialog() == DialogResult.OK) |
469 |
InitSPPIDDB(); |
470 |
} |
471 |
|
472 |
private void btnItemMapping_Click(object sender, EventArgs e) |
473 |
{ |
474 |
#if DEBUG |
475 |
SPPID_Document document = new SPPID_Document(@"Z:\HanKyouHo\temp\Isocynates\Temp\zIsocynates-325_Page75.xml"); |
476 |
document.SymbolMappings = symbolMappings; |
477 |
document.LineMappings = lineMappings; |
478 |
document.LineNumberMappings = lineNumberMappings; |
479 |
document.AssociationMappings = associationMappings; |
480 |
document.ETCSetting = ETCSetting.GetInstance(); |
481 |
document.SetSPPIDInfo(); |
482 |
|
483 |
if (document.SetSPPIDMapping()) |
484 |
{ |
485 |
AutoModeling modeling = new AutoModeling(document); |
486 |
modeling.Run(); |
487 |
} |
488 |
|
489 |
return; |
490 |
#endif |
491 |
|
492 |
Project_Info _ProjectInfo = Project_Info.GetInstance(); |
493 |
if (!_ProjectInfo.Enable) |
494 |
{ |
495 |
MessageBox.Show(Msg.PleaseSetID2ProjectInfo, Msg.Warning, MessageBoxButtons.OK, MessageBoxIcon.Warning); |
496 |
return; |
497 |
} |
498 |
|
499 |
MappingForm form = new MappingForm(_ID2SymbolDT,_SPPIDSymbolPathDT, _ID2LineDT, _ID2LinePropertyDT, _ID2AssociationDT); |
500 |
form.ShowDialog(); |
501 |
InitMapping(); |
502 |
} |
503 |
private List<int> prevSelectedList = new List<int>(); |
504 |
|
505 |
private void gridViewConverter_SelectionChanged(object sender, DevExpress.Data.SelectionChangedEventArgs e) |
506 |
{ |
507 |
if (e.Action == CollectionChangeAction.Add) |
508 |
{ |
509 |
string _Unit = gridViewConverter.GetRowCellDisplayText(e.ControllerRow, "colUnit"); |
510 |
string _Template = gridViewConverter.GetRowCellDisplayText(e.ControllerRow, "colTemplate"); |
511 |
|
512 |
if (string.IsNullOrEmpty(_Unit) || string.IsNullOrEmpty(_Template)) |
513 |
gridViewConverter.UnselectRow(e.ControllerRow); |
514 |
} |
515 |
else if (e.Action == CollectionChangeAction.Refresh) |
516 |
{ |
517 |
foreach (int rowHandle in gridViewConverter.GetSelectedRows()) |
518 |
{ |
519 |
string _Unit = gridViewConverter.GetRowCellDisplayText(rowHandle, "colUnit"); |
520 |
string _Template = gridViewConverter.GetRowCellDisplayText(rowHandle, "colTemplate"); |
521 |
|
522 |
if (string.IsNullOrEmpty(_Unit) || string.IsNullOrEmpty(_Template)) |
523 |
gridViewConverter.UnselectRow(rowHandle); |
524 |
} |
525 |
|
526 |
List<int> selectedRowHandleList = gridViewConverter.GetSelectedRows().ToList(); |
527 |
var firstNotSecond = prevSelectedList.Except(selectedRowHandleList).ToList(); |
528 |
var secondNotFirst = selectedRowHandleList.Except(prevSelectedList).ToList(); |
529 |
|
530 |
if (!firstNotSecond.Any() && !secondNotFirst.Any()) |
531 |
{ |
532 |
this.gridViewConverter.SelectionChanged -= new DevExpress.Data.SelectionChangedEventHandler(this.gridViewConverter_SelectionChanged); |
533 |
gridViewConverter.ClearSelection(); |
534 |
this.gridViewConverter.SelectionChanged += new DevExpress.Data.SelectionChangedEventHandler(this.gridViewConverter_SelectionChanged); |
535 |
} |
536 |
} |
537 |
|
538 |
prevSelectedList = gridViewConverter.GetSelectedRows().ToList(); |
539 |
} |
540 |
} |
541 |
} |