프로젝트

일반

사용자정보

통계
| 개정판:

hytos / DTI_PID / SPPIDConverter / ConverterForm.cs @ 06b40010

이력 | 보기 | 이력해설 | 다운로드 (24.3 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 DevExpress.XtraEditors.Repository;
12
using DevExpress.XtraEditors.Controls;
13
using DevExpress.XtraEditors;
14
using System.Globalization;
15
using System.Threading;
16
using System.IO;
17
using Ingr.RAD2D;
18
using Converter.BaseModel;
19
using Converter.SPPID.Properties;
20
using Converter.SPPID.DB;
21
using Converter.SPPID.Util;
22
using Converter.SPPID.Form;
23
using Converter.SPPID.Model;
24

    
25
namespace Converter.SPPID
26
{
27
    public partial class ConverterForm : DevExpress.XtraBars.Ribbon.RibbonForm
28
    {
29
        private Dictionary<string, SPPID_Document> _DicDocuments = new Dictionary<string, SPPID_Document>();
30
        private List<SPPID_Document> _Documents = new List<SPPID_Document>();
31
        public List<SPPID_Document> Documents { get { return _Documents; } }
32
        private DataTable _ConverterDT = new DataTable();
33
        private DataTable _SPPIDSymbolPathDT = new DataTable();
34
        private DataTable _SPPIDUnitDT = new DataTable();
35
        private RepositoryItemComboBox templateComboBox;
36

    
37

    
38
        private DataTable _ID2SymbolDT = new DataTable();
39
        private DataTable _ID2ChildSymbolDT = new DataTable();
40
        private DataTable _ID2LineDT = new DataTable();
41
        private DataTable _ID2AttributeDT = new DataTable();
42
        private DataTable _ID2LinePropertyDT = new DataTable();
43
        private DataTable _ID2SymbolTypeDT = new DataTable();
44

    
45

    
46
        private List<SymbolMapping> symbolMappings = new List<SymbolMapping>();
47
        private List<ChildSymbolMapping> childSymbolMappings = new List<ChildSymbolMapping>();
48
        private List<LineMapping> lineMappings = new List<LineMapping>();
49
        private List<LineNumberMapping> lineNumberMappings = new List<LineNumberMapping>();
50
        private List<AttributeMapping> attributeMappings = new List<AttributeMapping>();
51

    
52
        public ConverterForm()
53
        {
54
            InitializeComponent();
55

    
56
            CultureInfo culture = CultureInfo.GetCultureInfo("ko");
57
            Msg.Culture = culture;
58

    
59
            InitUsedDataTable();
60
            InitGridControl();
61
            InitID2Project();
62
        }
63

    
64
        private void InitUsedDataTable()
65
        {
66
            // Converter Table
67
            DataColumn col = _ConverterDT.Columns.Add("colDrawingFileName");
68
            col.Caption = "Drawing File Name";
69
            col = _ConverterDT.Columns.Add("colDrawingFilePath");
70
            col.Caption = "DrawingFilePath";
71
            col = _ConverterDT.Columns.Add("colUnit");
72
            col.Caption = "Unit";
73
            col = _ConverterDT.Columns.Add("colTemplate");
74
            col.Caption = "Template";
75
            col = _ConverterDT.Columns.Add("colDrawingNumber");
76
            col.Caption = "Drawing Number";
77
            col = _ConverterDT.Columns.Add("colDrawingName");
78
            col.Caption = "Drawing Name";
79
            col = _ConverterDT.Columns.Add("colStatus");
80
            col.Caption = "Status";
81
            col = _ConverterDT.Columns.Add("colUID");
82

    
83
            col = _ID2LineDT.Columns.Add("UID");
84
            col = _ID2LineDT.Columns.Add("Name");
85
            col.Caption = "Name";
86
            col = _ID2LineDT.Columns.Add("Type");
87
            col.Caption = "Type";
88
            col = _ID2LineDT.Columns.Add("SPPID_SYMBOL_PATH");
89
            col.Caption = "SPPID Symbol Path";
90
            col = _ID2LineDT.Columns.Add("Clear");
91
            col.Caption = "";
92
        }
93

    
94
        private void InitGridControl()
95
        {
96
            #region Converter Page
97
            gridViewConverter.OptionsSelection.MultiSelect = true;
98
            gridViewConverter.OptionsSelection.MultiSelectMode = DevExpress.XtraGrid.Views.Grid.GridMultiSelectMode.CheckBoxRowSelect;
99
            
100
            gridControlConverter.DataSource = _ConverterDT;
101

    
102
            templateComboBox = new RepositoryItemComboBox();
103
            templateComboBox.TextEditStyle = TextEditStyles.DisableTextEditor;
104
            templateComboBox.EditValueChanged += templateComboBox_EditValueChanged;
105
            gridControlConverter.RepositoryItems.Add(templateComboBox);
106
            gridViewConverter.Columns["colTemplate"].ColumnEdit = templateComboBox;
107

    
108
            gridViewConverter.Columns["colUnit"].OptionsColumn.AllowEdit = false;
109
            gridViewConverter.Columns["colDrawingFileName"].OptionsColumn.AllowEdit = false;
110
            gridViewConverter.Columns["colUnit"].OptionsColumn.ReadOnly = true;
111
            gridViewConverter.Columns["colStatus"].OptionsColumn.AllowEdit = false;
112
            gridViewConverter.Columns["colDrawingFilePath"].Visible = false;
113
            gridViewConverter.Columns["colUID"].Visible = false;
114

    
115
            gridViewConverter.BestFitColumns();
116
            #endregion
117
        }
118

    
119
        private void templateComboBox_EditValueChanged(object sender, EventArgs e)
120
        {
121
            gridViewConverter.CloseEditor();
122
            gridViewConverter.UpdateCurrentRow();
123
        }
124

    
125
        private void gridViewConverter_RowCellClick(object sender, DevExpress.XtraGrid.Views.Grid.RowCellClickEventArgs e)
126
        {
127
            if (e.Column.Name == "colcolTemplate")
128
            {
129
                gridViewConverter.ShowEditor();
130
                (gridViewConverter.ActiveEditor as ComboBoxEdit).ShowPopup();
131
            }
132
            else if (e.Column.Name == "colcolUnit")
133
            {
134
                UnitForm unitForm = new UnitForm(_SPPIDUnitDT);
135
                if (unitForm.ShowDialog() == DialogResult.OK)
136
                {
137
                    gridViewConverter.SetRowCellValue(e.RowHandle, e.Column, unitForm.SelectedUnit);
138
                    gridViewConverter.CloseEditor();
139
                    gridViewConverter.UpdateCurrentRow();
140
                }
141
            }
142
        }
143

    
144
        private void btnID2Project_ButtonClick(object sender, ButtonPressedEventArgs e)
145
        {
146
            xtraFolderBrowserDialog.SelectedPath = btnID2Project.Text;
147

    
148
            if (xtraFolderBrowserDialog.ShowDialog() == DialogResult.OK)
149
            {
150
                if (xtraFolderBrowserDialog.SelectedPath[xtraFolderBrowserDialog.SelectedPath.Length - 1] == '\\')
151
                    xtraFolderBrowserDialog.SelectedPath = xtraFolderBrowserDialog.SelectedPath.Remove(xtraFolderBrowserDialog.SelectedPath.Length - 1);
152
                Settings.Default.LatestProjectPath = xtraFolderBrowserDialog.SelectedPath;
153
                Settings.Default.Save();
154
                if (InitID2Project())
155
                {
156
                    MessageBox.Show(Msg.SuccessProjectSelect, Msg.Information, MessageBoxButtons.OK, MessageBoxIcon.Information);
157
                }
158
                else
159
                    MessageBox.Show(Msg.FailProjectSelect, Msg.Warning, MessageBoxButtons.OK, MessageBoxIcon.Warning);
160
            }
161
        }
162

    
163
        private bool InitID2Project()
164
        {
165
            Project_Info _ProjectInfo = Project_Info.GetInstance();
166
            _ProjectInfo.DefaultPath = Settings.Default.LatestProjectPath;
167
            if (Project_DB.ConnTestAndCreateTable())
168
            {
169
                _ProjectInfo.Enable = true;
170
                btnID2Project.Text = _ProjectInfo.DefaultPath;
171
                labelID2ProjectName.Text = _ProjectInfo.Name;
172
                labelID2ProjectName.AppearanceItemCaption.ForeColor = Color.Blue;
173
                labelID2ProjectStatus.Text = Msg.ConnectionSuccessful;
174
                labelID2ProjectStatus.AppearanceItemCaption.ForeColor = Color.Blue;
175
                layoutControlGroupSPPIDDB.Visibility = DevExpress.XtraLayout.Utils.LayoutVisibility.Always;
176
                layoutControlGroupItemMapping.Visibility = DevExpress.XtraLayout.Utils.LayoutVisibility.Always;
177
            }
178
            else
179
            {
180
                _ProjectInfo.Enable = false;
181
                btnID2Project.Text = "";
182
                labelID2ProjectName.Text = " ";
183
                labelID2ProjectName.AppearanceItemCaption.ForeColor = Color.Red;
184
                labelID2ProjectStatus.Text = Msg.ConnectionFail;
185
                labelID2ProjectStatus.AppearanceItemCaption.ForeColor = Color.Red;
186
                layoutControlGroupSPPIDDB.Visibility = DevExpress.XtraLayout.Utils.LayoutVisibility.Never;
187
                layoutControlGroupItemMapping.Visibility = DevExpress.XtraLayout.Utils.LayoutVisibility.Never;
188
            }
189

    
190
            InitMapping();
191
            InitSPPIDDB();
192

    
193
            return _ProjectInfo.Enable;
194
        }
195

    
196
        private void InitMapping()
197
        {
198
            Project_Info _ProjectInfo = Project_Info.GetInstance();
199
            if (_ProjectInfo.Enable)
200
            {
201
                InitID2Symbol();
202
                InitID2Line();
203
                InitID2LineNumber();
204
                InitID2Attribute();
205

    
206
                InitETCSetting();
207
            }
208
        }
209

    
210
        private void InitETCSetting()
211
        {
212
            Project_Info _ProjectInfo = Project_Info.GetInstance();
213
            if (_ProjectInfo.Enable)
214
            {
215
                DataTable dt = Project_DB.SelectSetting();
216
                foreach (DataRow item in dt.Rows)
217
                {
218
                    string settingType = item["SettingType"].ToString();
219
                    if (settingType == "ETCSetting")
220
                        SPPIDUtil.ConvertToETCSetting(item["JsonString"].ToString());
221
                    else if (settingType == "GridSetting")
222
                        SPPIDUtil.ConvertToGridSetting(item["JsonString"].ToString());
223
                }
224
            }
225
        }
226

    
227
        private void InitID2Symbol()
228
        {
229
            using (DataTable symbolDT = Project_DB.SelectProjectSymbol())
230
            {
231
                symbolMappings.Clear();
232
                _ID2SymbolDT = symbolDT;
233
                _ID2SymbolDT.Columns.Add("Clear");
234
                _ID2SymbolDT.Columns["Clear"].Caption = "";
235
                foreach (DataRow row in symbolDT.Rows)
236
                {
237
                    symbolMappings.Add(new SymbolMapping()
238
                    {
239
                        UID = row["UID"] == null ? "" : row["UID"].ToString(),
240
                        SYMBOLNAME = row["Name"] == null ? "" : row["Name"].ToString(),
241
                        SPPIDSYMBOLNAME = row["SPPID_SYMBOL_PATH"] == null ? "" : row["SPPID_SYMBOL_PATH"].ToString(),
242
                        LEADERLINE = DBNull.Value.Equals(row["LEADERLINE"]) ? false : (bool)row["LEADERLINE"]
243
                    });
244
                }
245

    
246
                MergeID2ChildSymbol();
247
            }
248
        }
249

    
250
        private void MergeID2ChildSymbol()
251
        {
252
            using (DataTable childSymbolDT = Project_DB.SelectProjectChildSymbol())
253
            {
254
                childSymbolMappings.Clear();
255
                _ID2ChildSymbolDT = childSymbolDT;
256
                _ID2ChildSymbolDT.Columns.Add("Clear");
257
                _ID2ChildSymbolDT.Columns["Clear"].Caption = "";
258
                foreach (DataRow row in childSymbolDT.Rows)
259
                {
260
                    childSymbolMappings.Add(new ChildSymbolMapping()
261
                    {
262
                        UID = row["UID"] == null ? "" : row["UID"].ToString(),
263
                        SYMBOLNAME = row["Name"] == null ? "" : row["Name"].ToString(),
264
                        SPPIDSYMBOLNAME = row["SPPID_SYMBOL_PATH"] == null ? "" : row["SPPID_SYMBOL_PATH"].ToString(),
265
                    });
266
                }
267

    
268
                _ID2SymbolDT.Merge(_ID2ChildSymbolDT);
269
            }
270
        }
271

    
272
        private void InitID2Line()
273
        {
274
            using (DataTable lineTypes = Project_DB.SelectProjectLine())
275
            {
276
                lineMappings.Clear();
277
                _ID2LineDT.Rows.Clear();
278
                foreach (DataRow row in lineTypes.Rows)
279
                {
280
                    DataRow newRow = _ID2LineDT.NewRow();
281
                    newRow["UID"] = row["UID"] == null ? "" : row["UID"].ToString();
282
                    newRow["Name"] = row["Name"] == null ? "" : row["Name"].ToString();
283
                    newRow["Type"] = "Line";
284
                    newRow["SPPID_SYMBOL_PATH"] = row["SPPID_SYMBOL_PATH"] == null ? "" : row["SPPID_SYMBOL_PATH"].ToString();
285
                    _ID2LineDT.Rows.Add(newRow);
286

    
287
                    lineMappings.Add(new LineMapping()
288
                    {
289
                        UID = row["UID"] == null ? "" : row["UID"].ToString(),
290
                        LINENAME = row["Name"] == null ? "" : row["Name"].ToString(),
291
                        SPPIDSYMBOLNAME = row["SPPID_SYMBOL_PATH"] == null ? "" : row["SPPID_SYMBOL_PATH"].ToString(),
292
                    });
293
                }
294
            }
295
        }
296

    
297
        private void InitID2LineNumber()
298
        {
299
            using (DataTable linePropertiesDT = Project_DB.SelectProjectLineProperties())
300
            {
301
                lineNumberMappings.Clear();
302
                _ID2LinePropertyDT = linePropertiesDT;
303
                _ID2LinePropertyDT.Columns.Add("Type");
304
                foreach (DataRow row in linePropertiesDT.Rows)
305
                {
306
                    row["Type"] = "Line Property";
307
                    lineNumberMappings.Add(new LineNumberMapping()
308
                    {
309
                        UID = row["UID"] == null ? "" : row["UID"].ToString(),
310
                        DisplayName = row["DisplayName"] == null ? "" : row["DisplayName"].ToString(),
311
                        SPPIDATTRIBUTENAME = row["SPPID_ATTRIBUTE"] == null ? "" : row["SPPID_ATTRIBUTE"].ToString(),
312
                        SPPIDSYMBOLNAME = row["SPPID_SYMBOL_PATH"] == null ? "" : row["SPPID_SYMBOL_PATH"].ToString()
313
                    });
314
                }
315
            }
316
        }
317

    
318
        private void InitID2Attribute()
319
        {
320
            using (DataTable attributeDT = Project_DB.SelectProjectAttribute())
321
            {
322
                attributeMappings.Clear();
323
                _ID2AttributeDT = attributeDT;
324
                _ID2AttributeDT.Columns.Add("Clear");
325
                _ID2AttributeDT.Columns["Clear"].Caption = "";
326
                foreach (DataRow row in attributeDT.Rows)
327
                {
328
                    attributeMappings.Add(new AttributeMapping()
329
                    {
330
                        UID = row["UID"] == null ? "" : row["UID"].ToString(),
331
                        DisplayAttribute = row["DisplayAttribute"] == null ? "" : row["DisplayAttribute"].ToString(),
332
                        Type = row["Type"] == null ? "" : row["Type"].ToString(),
333
                        SPPIDATTRIBUTENAME = row["SPPID_ATTRIBUTE"] == null ? "" : row["SPPID_ATTRIBUTE"].ToString(),
334
                        SPPIDSYMBOLNAME = row["SPPID_SYMBOL_PATH"] == null ? "" : row["SPPID_SYMBOL_PATH"].ToString(),
335
                        Location = DBNull.Value.Equals(row["LOCATION"]) ? Model.Location.None : (Location)row["LOCATION"],
336
                        LeaderLine = DBNull.Value.Equals(row["LEADERLINE"]) ? false : (bool)row["LEADERLINE"]
337
                    });
338
                }
339
            }
340
        }
341

    
342
        private void InitSPPIDDB()
343
        {
344
            Project_Info _ProjectInfo = Project_Info.GetInstance();
345
            if (_ProjectInfo.Enable)
346
            {
347
                DataTable dt = Project_DB.SelectSPPID_DB_INFO();
348
                if (dt.Columns.Count > 0 && dt.Rows.Count > 0)
349
                    SPPIDUtil.ConvertToSPPIDInfo(dt.Rows[0][0].ToString());
350
                else
351
                    SPPID_DBInfo.Clear();
352
            }
353

    
354
            templateComboBox.Items.Clear();
355
            SPPID_DBInfo _SPPIDInfo = SPPID_DBInfo.GetInstance();
356
            if (_SPPIDInfo.Enable)
357
            {
358
                labelSPPIDPlantName.Text = _SPPIDInfo.SelectedPlant;
359
                labelSPPIDPlantName.AppearanceItemCaption.ForeColor = Color.Blue;
360
                labelSPPIDDBStatus.Text = Msg.ConnectionSuccessful;
361
                labelSPPIDDBStatus.AppearanceItemCaption.ForeColor = Color.Blue;
362

    
363
                string TemplatePath = SPPID_DB.GetPlantPID_T_OPTIONSETTING_Value("PID Template Path");
364
                if (!string.IsNullOrEmpty(TemplatePath))
365
                    templateComboBox.Items.AddRange(Directory.GetFiles(TemplatePath, "*.pid").ToList().Select(filePath => Path.GetFileName(filePath)).ToList());
366

    
367
                _SPPIDUnitDT = SPPID_DB.GetUnitTree();
368

    
369
                layoutControlGroupAutoConverter.Enabled = true;
370
            }
371
            else
372
            {
373
                labelSPPIDPlantName.Text = " ";
374
                labelSPPIDPlantName.AppearanceItemCaption.ForeColor = Color.Red;
375
                labelSPPIDDBStatus.Text = Msg.ConnectionFail;
376
                labelSPPIDDBStatus.AppearanceItemCaption.ForeColor = Color.Red;
377

    
378
                layoutControlGroupAutoConverter.Enabled = false;
379
            }
380

    
381
            _DicDocuments.Clear();
382
            _ConverterDT.Rows.Clear();
383
            InitSPPIDSymbolTreeTable();
384
        }
385

    
386
        private void InitSPPIDSymbolTreeTable()
387
        {
388
            SPPID_DBInfo _SPPIDInfo = SPPID_DBInfo.GetInstance();
389

    
390
            try
391
            {
392
                _SPPIDSymbolPathDT = new DataTable();
393
                _SPPIDSymbolPathDT.Columns.Add("ID");
394
                _SPPIDSymbolPathDT.Columns.Add("Parent");
395
                _SPPIDSymbolPathDT.Columns.Add("Name");
396
                _SPPIDSymbolPathDT.Columns.Add("FullPath");
397

    
398
                if (_SPPIDInfo.Enable)
399
                {
400
                    string symbolPath = SPPID_DB.GetPlantPID_T_OPTIONSETTING_Value("Catalog Explorer root path");
401
                    DirectoryInfo info = new DirectoryInfo(symbolPath);
402
                    _SPPIDSymbolPathDT.Rows.Add(new object[] { "0", "-1", info.Name });
403
                    loop(info, "0", symbolPath);
404
                }
405
            }
406
            catch (Exception ex)
407
            {
408
                MessageBox.Show(ex.Message + "\r\n" + ex.StackTrace);
409
            }
410
        }
411

    
412
        private void loop(DirectoryInfo parentInfo, string parentUID, string defaultPath)
413
        {
414
            DirectoryInfo[] infos = parentInfo.GetDirectories();
415
            foreach (DirectoryInfo info in infos)
416
            {
417
                string uid = Guid.NewGuid().ToString();
418
                _SPPIDSymbolPathDT.Rows.Add(new object[] { uid, parentUID, info.Name });
419
                loop(info, uid, defaultPath);
420

    
421
                FileInfo[] files = info.GetFiles("*.sym");
422
                foreach (FileInfo fileInfo in files)
423
                {
424
                    _SPPIDSymbolPathDT.Rows.Add(new object[] { Guid.NewGuid().ToString(), uid, fileInfo.Name, fileInfo.FullName.Replace(defaultPath, "") });
425
                }
426
            }
427
        }
428

    
429
        private void btnLoadFile_Click(object sender, EventArgs e)
430
        {
431
            Project_Info _ProjectInfo = Project_Info.GetInstance();
432
            if (!_ProjectInfo.Enable)
433
            {
434
                MessageBox.Show(Msg.PleaseSetID2ProjectInfo, Msg.Warning, MessageBoxButtons.OK, MessageBoxIcon.Warning);
435
                return;
436
            }
437

    
438
            xtraOpenFileDialog.InitialDirectory = _ProjectInfo.TempDirPath;
439
            if (xtraOpenFileDialog.ShowDialog() == DialogResult.OK)
440
            {
441
                foreach (string fileName in xtraOpenFileDialog.FileNames)
442
                {
443
                    SPPID_Document document = new SPPID_Document(fileName);
444

    
445
                    DataRow[] rows = _ConverterDT.Select(string.Format("colDrawingFilePath = '{0}'", fileName));
446
                    DataRow row;
447
                    if (rows.Length == 0)
448
                    {
449
                        row = _ConverterDT.NewRow();
450
                        row["colDrawingFileName"] = Path.GetFileNameWithoutExtension(fileName);
451
                        row["colDrawingFilePath"] = fileName;
452
                        row["colDrawingNumber"] = document.DWGNAME;
453
                        row["colDrawingName"] = document.DWGNAME;
454
                        if (document.Enable)
455
                            row["colStatus"] = "Ready";
456
                        else
457
                            row["colStatus"] = "Error";
458
                        row["colUID"] = "";
459
                        _ConverterDT.Rows.Add(row);
460
                    }
461
                    if (!_DicDocuments.ContainsKey(fileName))
462
                        _DicDocuments.Add(fileName, null);
463

    
464
                    _DicDocuments[fileName] = document;
465
                }
466
            }
467
        }
468

    
469
        private void btnRun_Click(object sender, EventArgs e)
470
        {
471
            _Documents.Clear();
472
            foreach (int rowHandle in gridViewConverter.GetSelectedRows())
473
            {
474
                string _FilePath = gridViewConverter.GetRowCellDisplayText(rowHandle, "colDrawingFilePath");
475
                string _Unit = gridViewConverter.GetRowCellDisplayText(rowHandle, "colUnit");
476
                string _Template = gridViewConverter.GetRowCellDisplayText(rowHandle, "colTemplate");
477
                string _DrawingNumber = gridViewConverter.GetRowCellDisplayText(rowHandle, "colDrawingNumber");
478
                string _DrawingName = gridViewConverter.GetRowCellDisplayText(rowHandle, "colDrawingName");
479
                SPPID_Document document = _DicDocuments[_FilePath];
480
                document.Unit = _Unit;
481
                document.Template = _Template;
482
                document.DrawingNumber = _DrawingNumber;
483
                document.DrawingName = _DrawingName;
484

    
485
                document.SymbolMappings = symbolMappings;
486
                document.ChildSymbolMappings = childSymbolMappings;
487
                document.LineMappings = lineMappings;
488
                document.LineNumberMappings = lineNumberMappings;
489
                document.AttributeMappings = attributeMappings;
490
                document.ETCSetting = ETCSetting.GetInstance();
491
                document.SetSPPIDInfo();
492

    
493
                if (document.SetSPPIDMapping() && document.Enable)
494
                    _Documents.Add(document);
495
            }
496

    
497
            DialogResult = DialogResult.OK;
498
        }
499

    
500
        private void btnSPPIDDB_Click(object sender, EventArgs e)
501
        {
502
            SPPID_DB_SettingForm form = new SPPID_DB_SettingForm();
503
            if (form.ShowDialog() == DialogResult.OK)
504
                InitSPPIDDB();
505
        }
506

    
507
        private void btnItemMapping_Click(object sender, EventArgs e)
508
        {
509
            Project_Info _ProjectInfo = Project_Info.GetInstance();
510
            if (!_ProjectInfo.Enable)
511
            {
512
                MessageBox.Show(Msg.PleaseSetID2ProjectInfo, Msg.Warning, MessageBoxButtons.OK, MessageBoxIcon.Warning);
513
                return;
514
            }
515

    
516
            MappingForm form = new MappingForm(_ID2SymbolDT,_SPPIDSymbolPathDT, _ID2LineDT, _ID2LinePropertyDT, _ID2AttributeDT);
517
            form.ShowDialog();
518
            InitMapping();
519
        }
520
        private List<int> prevSelectedList = new List<int>();
521

    
522
        private void gridViewConverter_SelectionChanged(object sender, DevExpress.Data.SelectionChangedEventArgs e)
523
        {
524
            if (e.Action == CollectionChangeAction.Add)
525
            {
526
                string _Unit = gridViewConverter.GetRowCellDisplayText(e.ControllerRow, "colUnit");
527
                string _Template = gridViewConverter.GetRowCellDisplayText(e.ControllerRow, "colTemplate");
528

    
529
                if (string.IsNullOrEmpty(_Unit) || string.IsNullOrEmpty(_Template))
530
                    gridViewConverter.UnselectRow(e.ControllerRow);
531
            }
532
            else if (e.Action == CollectionChangeAction.Refresh)
533
            {
534
                foreach (int rowHandle in gridViewConverter.GetSelectedRows())
535
                {
536
                    string _Unit = gridViewConverter.GetRowCellDisplayText(rowHandle, "colUnit");
537
                    string _Template = gridViewConverter.GetRowCellDisplayText(rowHandle, "colTemplate");
538

    
539
                    if (string.IsNullOrEmpty(_Unit) || string.IsNullOrEmpty(_Template))
540
                        gridViewConverter.UnselectRow(rowHandle);
541
                }
542

    
543
                List<int> selectedRowHandleList = gridViewConverter.GetSelectedRows().ToList();
544
                var firstNotSecond = prevSelectedList.Except(selectedRowHandleList).ToList();
545
                var secondNotFirst = selectedRowHandleList.Except(prevSelectedList).ToList();
546

    
547
                if (!firstNotSecond.Any() && !secondNotFirst.Any())
548
                {
549
                    this.gridViewConverter.SelectionChanged -= new DevExpress.Data.SelectionChangedEventHandler(this.gridViewConverter_SelectionChanged);
550
                    gridViewConverter.ClearSelection();
551
                    this.gridViewConverter.SelectionChanged += new DevExpress.Data.SelectionChangedEventHandler(this.gridViewConverter_SelectionChanged);
552
                }
553
            }
554

    
555
            prevSelectedList = gridViewConverter.GetSelectedRows().ToList();
556
        }
557
    }
558
}
클립보드 이미지 추가 (최대 크기: 500 MB)