hytos / DTI_PID / SPPIDConverter / ConverterForm.cs @ cfda1fed
이력 | 보기 | 이력해설 | 다운로드 (22.1 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 |
private void InitETCSetting() |
204 |
{ |
205 |
Project_Info _ProjectInfo = Project_Info.GetInstance(); |
206 |
if (_ProjectInfo.Enable) |
207 |
{ |
208 |
DataTable dt = Project_DB.SelectETCSetting(); |
209 |
if (dt.Columns.Count > 0 && dt.Rows.Count > 0) |
210 |
SPPIDUtil.ConvertToETCSetting(dt.Rows[0][0].ToString()); |
211 |
else |
212 |
SPPID_DBInfo.Clear(); |
213 |
} |
214 |
} |
215 |
|
216 |
private void InitID2Symbol() |
217 |
{ |
218 |
using (DataTable symbolDT = Project_DB.SelectProjectSymbol()) |
219 |
{ |
220 |
symbolMappings.Clear(); |
221 |
_ID2SymbolDT = symbolDT; |
222 |
_ID2SymbolDT.Columns.Add("Clear"); |
223 |
_ID2SymbolDT.Columns["Clear"].Caption = ""; |
224 |
foreach (DataRow row in symbolDT.Rows) |
225 |
{ |
226 |
symbolMappings.Add(new SymbolMapping() |
227 |
{ |
228 |
UID = row["UID"] == null ? "" : row["UID"].ToString(), |
229 |
SYMBOLNAME = row["Name"] == null ? "" : row["Name"].ToString(), |
230 |
SPPIDSYMBOLNAME = row["SPPID_SYMBOL_PATH"] == null ? "" : row["SPPID_SYMBOL_PATH"].ToString(), |
231 |
}); |
232 |
} |
233 |
} |
234 |
} |
235 |
|
236 |
private void InitID2Line() |
237 |
{ |
238 |
using (DataTable lineTypes = Project_DB.SelectProjectLine()) |
239 |
{ |
240 |
lineMappings.Clear(); |
241 |
_ID2LineDT.Rows.Clear(); |
242 |
foreach (DataRow row in lineTypes.Rows) |
243 |
{ |
244 |
DataRow newRow = _ID2LineDT.NewRow(); |
245 |
newRow["UID"] = row["UID"] == null ? "" : row["UID"].ToString(); |
246 |
newRow["Name"] = row["Name"] == null ? "" : row["Name"].ToString(); |
247 |
newRow["Type"] = "Line"; |
248 |
newRow["SPPID_SYMBOL_PATH"] = row["SPPID_SYMBOL_PATH"] == null ? "" : row["SPPID_SYMBOL_PATH"].ToString(); |
249 |
_ID2LineDT.Rows.Add(newRow); |
250 |
|
251 |
lineMappings.Add(new LineMapping() |
252 |
{ |
253 |
UID = row["UID"] == null ? "" : row["UID"].ToString(), |
254 |
LINENAME = row["Name"] == null ? "" : row["Name"].ToString(), |
255 |
SPPIDSYMBOLNAME = row["SPPID_SYMBOL_PATH"] == null ? "" : row["SPPID_SYMBOL_PATH"].ToString(), |
256 |
}); |
257 |
} |
258 |
} |
259 |
} |
260 |
|
261 |
private void InitID2LineNumber() |
262 |
{ |
263 |
using (DataTable linePropertiesDT = Project_DB.SelectProjectLineProperties()) |
264 |
{ |
265 |
lineNumberMappings.Clear(); |
266 |
_ID2LinePropertyDT = linePropertiesDT; |
267 |
_ID2LinePropertyDT.Columns.Add("Type"); |
268 |
foreach (DataRow row in linePropertiesDT.Rows) |
269 |
{ |
270 |
row["Type"] = "Line Property"; |
271 |
lineNumberMappings.Add(new LineNumberMapping() |
272 |
{ |
273 |
UID = row["UID"] == null ? "" : row["UID"].ToString(), |
274 |
DisplayName = row["DisplayName"] == null ? "" : row["DisplayName"].ToString(), |
275 |
SPPIDATTRIBUTENAME = row["SPPID_ATTRIBUTE"] == null ? "" : row["SPPID_ATTRIBUTE"].ToString(), |
276 |
SPPIDSYMBOLNAME = row["SPPID_SYMBOL_PATH"] == null ? "" : row["SPPID_SYMBOL_PATH"].ToString() |
277 |
}); |
278 |
} |
279 |
} |
280 |
} |
281 |
|
282 |
private void InitID2Association() |
283 |
{ |
284 |
using (DataTable associationDT = Project_DB.SelectProjectAssociation()) |
285 |
{ |
286 |
associationMappings.Clear(); |
287 |
_ID2AssociationDT = associationDT; |
288 |
_ID2AssociationDT.Columns.Add("Clear"); |
289 |
_ID2AssociationDT.Columns["Clear"].Caption = ""; |
290 |
foreach (DataRow row in associationDT.Rows) |
291 |
{ |
292 |
associationMappings.Add(new AssociationMapping() |
293 |
{ |
294 |
UID = row["UID"] == null ? "" : row["UID"].ToString(), |
295 |
DisplayAttribute = row["DisplayAttribute"] == null ? "" : row["DisplayAttribute"].ToString(), |
296 |
Type = row["Type"] == null ? "" : row["Type"].ToString(), |
297 |
SPPIDATTRIBUTENAME = row["SPPID_ATTRIBUTE"] == null ? "" : row["SPPID_ATTRIBUTE"].ToString(), |
298 |
SPPIDSYMBOLNAME = row["SPPID_SYMBOL_PATH"] == null ? "" : row["SPPID_SYMBOL_PATH"].ToString() |
299 |
}); |
300 |
} |
301 |
} |
302 |
} |
303 |
|
304 |
private void InitSPPIDDB() |
305 |
{ |
306 |
Project_Info _ProjectInfo = Project_Info.GetInstance(); |
307 |
if (_ProjectInfo.Enable) |
308 |
{ |
309 |
DataTable dt = Project_DB.SelectSPPID_DB_INFO(); |
310 |
if (dt.Columns.Count > 0 && dt.Rows.Count > 0) |
311 |
SPPIDUtil.ConvertToSPPIDInfo(dt.Rows[0][0].ToString()); |
312 |
else |
313 |
SPPID_DBInfo.Clear(); |
314 |
} |
315 |
|
316 |
templateComboBox.Items.Clear(); |
317 |
SPPID_DBInfo _SPPIDInfo = SPPID_DBInfo.GetInstance(); |
318 |
if (_SPPIDInfo.Enable) |
319 |
{ |
320 |
labelSPPIDPlantName.Text = _SPPIDInfo.SelectedPlant; |
321 |
labelSPPIDPlantName.AppearanceItemCaption.ForeColor = Color.Blue; |
322 |
labelSPPIDDBStatus.Text = Msg.ConnectionSuccessful; |
323 |
labelSPPIDDBStatus.AppearanceItemCaption.ForeColor = Color.Blue; |
324 |
|
325 |
string TemplatePath = SPPID_DB.GetPlantPID_T_OPTIONSETTING_Value("PID Template Path"); |
326 |
if (!string.IsNullOrEmpty(TemplatePath)) |
327 |
templateComboBox.Items.AddRange(Directory.GetFiles(TemplatePath, "*.pid").ToList().Select(filePath => Path.GetFileName(filePath)).ToList()); |
328 |
|
329 |
_SPPIDUnitDT = SPPID_DB.GetUnitTree(); |
330 |
|
331 |
layoutControlGroupAutoConverter.Enabled = true; |
332 |
} |
333 |
else |
334 |
{ |
335 |
labelSPPIDPlantName.Text = " "; |
336 |
labelSPPIDPlantName.AppearanceItemCaption.ForeColor = Color.Red; |
337 |
labelSPPIDDBStatus.Text = Msg.ConnectionFail; |
338 |
labelSPPIDDBStatus.AppearanceItemCaption.ForeColor = Color.Red; |
339 |
|
340 |
layoutControlGroupAutoConverter.Enabled = false; |
341 |
} |
342 |
|
343 |
_DicDocuments.Clear(); |
344 |
_ConverterDT.Rows.Clear(); |
345 |
InitSPPIDSymbolTreeTable(); |
346 |
} |
347 |
|
348 |
private void InitSPPIDSymbolTreeTable() |
349 |
{ |
350 |
SPPID_DBInfo _SPPIDInfo = SPPID_DBInfo.GetInstance(); |
351 |
|
352 |
_SPPIDSymbolPathDT = new DataTable(); |
353 |
_SPPIDSymbolPathDT.Columns.Add("ID"); |
354 |
_SPPIDSymbolPathDT.Columns.Add("Parent"); |
355 |
_SPPIDSymbolPathDT.Columns.Add("Name"); |
356 |
_SPPIDSymbolPathDT.Columns.Add("FullPath"); |
357 |
|
358 |
if (_SPPIDInfo.Enable) |
359 |
{ |
360 |
string symbolPath = SPPID_DB.GetPlantPID_T_OPTIONSETTING_Value("Catalog Explorer root path"); |
361 |
DirectoryInfo info = new DirectoryInfo(symbolPath); |
362 |
_SPPIDSymbolPathDT.Rows.Add(new object[] { "0", "-1", info.Name }); |
363 |
loop(info, "0", symbolPath); |
364 |
} |
365 |
} |
366 |
|
367 |
private void loop(DirectoryInfo parentInfo, string parentUID, string defaultPath) |
368 |
{ |
369 |
DirectoryInfo[] infos = parentInfo.GetDirectories(); |
370 |
foreach (DirectoryInfo info in infos) |
371 |
{ |
372 |
string uid = Guid.NewGuid().ToString(); |
373 |
_SPPIDSymbolPathDT.Rows.Add(new object[] { uid, parentUID, info.Name }); |
374 |
loop(info, uid, defaultPath); |
375 |
|
376 |
FileInfo[] files = info.GetFiles("*.sym"); |
377 |
foreach (FileInfo fileInfo in files) |
378 |
{ |
379 |
_SPPIDSymbolPathDT.Rows.Add(new object[] { Guid.NewGuid().ToString(), uid, fileInfo.Name, fileInfo.FullName.Replace(defaultPath, "") }); |
380 |
} |
381 |
} |
382 |
} |
383 |
|
384 |
private void btnLoadFile_Click(object sender, EventArgs e) |
385 |
{ |
386 |
Project_Info _ProjectInfo = Project_Info.GetInstance(); |
387 |
if (!_ProjectInfo.Enable) |
388 |
{ |
389 |
MessageBox.Show(Msg.PleaseSetID2ProjectInfo, Msg.Warning, MessageBoxButtons.OK, MessageBoxIcon.Warning); |
390 |
return; |
391 |
} |
392 |
|
393 |
xtraOpenFileDialog.InitialDirectory = _ProjectInfo.TempDirPath; |
394 |
if (xtraOpenFileDialog.ShowDialog() == DialogResult.OK) |
395 |
{ |
396 |
foreach (string fileName in xtraOpenFileDialog.FileNames) |
397 |
{ |
398 |
SPPID_Document document = new SPPID_Document(fileName); |
399 |
document.SymbolMappings = symbolMappings; |
400 |
document.LineMappings = lineMappings; |
401 |
document.LineNumberMappings = lineNumberMappings; |
402 |
document.AssociationMappings = associationMappings; |
403 |
|
404 |
DataRow[] rows = _ConverterDT.Select(string.Format("colDrawingFilePath = '{0}'", fileName)); |
405 |
DataRow row; |
406 |
if (rows.Length == 0) |
407 |
{ |
408 |
row = _ConverterDT.NewRow(); |
409 |
row["colDrawingFileName"] = Path.GetFileNameWithoutExtension(fileName); |
410 |
row["colDrawingFilePath"] = fileName; |
411 |
row["colDrawingNumber"] = document.DWGNAME; |
412 |
row["colDrawingName"] = document.DWGNAME; |
413 |
if (document.Enable) |
414 |
row["colStatus"] = "Ready"; |
415 |
else |
416 |
row["colStatus"] = "Error"; |
417 |
row["colUID"] = ""; |
418 |
_ConverterDT.Rows.Add(row); |
419 |
} |
420 |
if (!_DicDocuments.ContainsKey(fileName)) |
421 |
_DicDocuments.Add(fileName, null); |
422 |
|
423 |
_DicDocuments[fileName] = document; |
424 |
} |
425 |
} |
426 |
} |
427 |
|
428 |
private void btnRun_Click(object sender, EventArgs e) |
429 |
{ |
430 |
_Documents.Clear(); |
431 |
|
432 |
foreach (int rowHandle in gridViewConverter.GetSelectedRows()) |
433 |
{ |
434 |
string _FilePath = gridViewConverter.GetRowCellDisplayText(rowHandle, "colDrawingFilePath"); |
435 |
string _Unit = gridViewConverter.GetRowCellDisplayText(rowHandle, "colUnit"); |
436 |
string _Template = gridViewConverter.GetRowCellDisplayText(rowHandle, "colTemplate"); |
437 |
string _DrawingNumber = gridViewConverter.GetRowCellDisplayText(rowHandle, "colDrawingNumber"); |
438 |
string _DrawingName = gridViewConverter.GetRowCellDisplayText(rowHandle, "colDrawingName"); |
439 |
SPPID_Document document = _DicDocuments[_FilePath]; |
440 |
document.Unit = _Unit; |
441 |
document.Template = _Template; |
442 |
document.DrawingNumber = _DrawingNumber; |
443 |
document.DrawingName = _DrawingName; |
444 |
_Documents.Add(document); |
445 |
} |
446 |
|
447 |
DialogResult = DialogResult.OK; |
448 |
} |
449 |
|
450 |
private void btnSPPIDDB_Click(object sender, EventArgs e) |
451 |
{ |
452 |
SPPID_DB_SettingForm form = new SPPID_DB_SettingForm(); |
453 |
if (form.ShowDialog() == DialogResult.OK) |
454 |
InitSPPIDDB(); |
455 |
} |
456 |
|
457 |
private void btnItemMapping_Click(object sender, EventArgs e) |
458 |
{ |
459 |
Project_Info _ProjectInfo = Project_Info.GetInstance(); |
460 |
if (!_ProjectInfo.Enable) |
461 |
{ |
462 |
MessageBox.Show(Msg.PleaseSetID2ProjectInfo, Msg.Warning, MessageBoxButtons.OK, MessageBoxIcon.Warning); |
463 |
return; |
464 |
} |
465 |
|
466 |
MappingForm form = new MappingForm(_ID2SymbolDT,_SPPIDSymbolPathDT, _ID2LineDT, _ID2LinePropertyDT, _ID2AssociationDT); |
467 |
form.ShowDialog(); |
468 |
InitMapping(); |
469 |
} |
470 |
private List<int> prevSelectedList = new List<int>(); |
471 |
|
472 |
private void gridViewConverter_SelectionChanged(object sender, DevExpress.Data.SelectionChangedEventArgs e) |
473 |
{ |
474 |
if (e.Action == CollectionChangeAction.Add) |
475 |
{ |
476 |
string _Unit = gridViewConverter.GetRowCellDisplayText(e.ControllerRow, "colUnit"); |
477 |
string _Template = gridViewConverter.GetRowCellDisplayText(e.ControllerRow, "colTemplate"); |
478 |
|
479 |
if (string.IsNullOrEmpty(_Unit) || string.IsNullOrEmpty(_Template)) |
480 |
gridViewConverter.UnselectRow(e.ControllerRow); |
481 |
} |
482 |
else if (e.Action == CollectionChangeAction.Refresh) |
483 |
{ |
484 |
foreach (int rowHandle in gridViewConverter.GetSelectedRows()) |
485 |
{ |
486 |
string _Unit = gridViewConverter.GetRowCellDisplayText(rowHandle, "colUnit"); |
487 |
string _Template = gridViewConverter.GetRowCellDisplayText(rowHandle, "colTemplate"); |
488 |
|
489 |
if (string.IsNullOrEmpty(_Unit) || string.IsNullOrEmpty(_Template)) |
490 |
gridViewConverter.UnselectRow(rowHandle); |
491 |
} |
492 |
|
493 |
List<int> selectedRowHandleList = gridViewConverter.GetSelectedRows().ToList(); |
494 |
var firstNotSecond = prevSelectedList.Except(selectedRowHandleList).ToList(); |
495 |
var secondNotFirst = selectedRowHandleList.Except(prevSelectedList).ToList(); |
496 |
|
497 |
if (!firstNotSecond.Any() && !secondNotFirst.Any()) |
498 |
{ |
499 |
this.gridViewConverter.SelectionChanged -= new DevExpress.Data.SelectionChangedEventHandler(this.gridViewConverter_SelectionChanged); |
500 |
gridViewConverter.ClearSelection(); |
501 |
this.gridViewConverter.SelectionChanged += new DevExpress.Data.SelectionChangedEventHandler(this.gridViewConverter_SelectionChanged); |
502 |
} |
503 |
} |
504 |
|
505 |
prevSelectedList = gridViewConverter.GetSelectedRows().ToList(); |
506 |
} |
507 |
} |
508 |
} |