프로젝트

일반

사용자정보

통계
| 브랜치(Branch): | 개정판:

hytos / DTI_PID / SPPIDConverter / ConverterForm.cs @ 4d2571ab

이력 | 보기 | 이력해설 | 다운로드 (24.6 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
        private DataTable _ID2SymbolTable = new DataTable();
45

    
46

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    
191
            InitMapping();
192
            InitSPPIDDB();
193

    
194
            return _ProjectInfo.Enable;
195
        }
196

    
197
        private void InitMapping()
198
        {
199
            Project_Info _ProjectInfo = Project_Info.GetInstance();
200
            if (_ProjectInfo.Enable)
201
            {
202
                if (_ID2SymbolTable != null)
203
                {
204
                    _ID2SymbolTable.Dispose();
205
                    _ID2SymbolTable = null;
206
                }
207
                _ID2SymbolTable = Project_DB.SelectID2SymbolTable();
208
                InitID2Symbol();
209
                InitID2Line();
210
                InitID2LineNumber();
211
                InitID2Attribute();
212

    
213
                InitETCSetting();
214
            }
215
        }
216

    
217
        private void InitETCSetting()
218
        {
219
            Project_Info _ProjectInfo = Project_Info.GetInstance();
220
            if (_ProjectInfo.Enable)
221
            {
222
                DataTable dt = Project_DB.SelectSetting();
223
                foreach (DataRow item in dt.Rows)
224
                {
225
                    string settingType = item["SettingType"].ToString();
226
                    if (settingType == "ETCSetting")
227
                        SPPIDUtil.ConvertToETCSetting(item["JsonString"].ToString());
228
                    else if (settingType == "GridSetting")
229
                        SPPIDUtil.ConvertToGridSetting(item["JsonString"].ToString());
230
                }
231
            }
232
        }
233

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

    
253
                MergeID2ChildSymbol();
254
            }
255
        }
256

    
257
        private void MergeID2ChildSymbol()
258
        {
259
            using (DataTable childSymbolDT = Project_DB.SelectProjectChildSymbol())
260
            {
261
                childSymbolMappings.Clear();
262
                _ID2ChildSymbolDT = childSymbolDT;
263
                _ID2ChildSymbolDT.Columns.Add("Clear");
264
                _ID2ChildSymbolDT.Columns["Clear"].Caption = "";
265
                foreach (DataRow row in childSymbolDT.Rows)
266
                {
267
                    childSymbolMappings.Add(new ChildSymbolMapping()
268
                    {
269
                        UID = row["UID"] == null ? "" : row["UID"].ToString(),
270
                        SYMBOLNAME = row["Name"] == null ? "" : row["Name"].ToString(),
271
                        SPPIDSYMBOLNAME = row["SPPID_SYMBOL_PATH"] == null ? "" : row["SPPID_SYMBOL_PATH"].ToString(),
272
                    });
273
                }
274

    
275
                _ID2SymbolDT.Merge(_ID2ChildSymbolDT);
276
            }
277
        }
278

    
279
        private void InitID2Line()
280
        {
281
            using (DataTable lineTypes = Project_DB.SelectProjectLine())
282
            {
283
                lineMappings.Clear();
284
                _ID2LineDT.Rows.Clear();
285
                foreach (DataRow row in lineTypes.Rows)
286
                {
287
                    DataRow newRow = _ID2LineDT.NewRow();
288
                    newRow["UID"] = row["UID"] == null ? "" : row["UID"].ToString();
289
                    newRow["Name"] = row["Name"] == null ? "" : row["Name"].ToString();
290
                    newRow["Type"] = "Line";
291
                    newRow["SPPID_SYMBOL_PATH"] = row["SPPID_SYMBOL_PATH"] == null ? "" : row["SPPID_SYMBOL_PATH"].ToString();
292
                    _ID2LineDT.Rows.Add(newRow);
293

    
294
                    lineMappings.Add(new LineMapping()
295
                    {
296
                        UID = row["UID"] == null ? "" : row["UID"].ToString(),
297
                        LINENAME = row["Name"] == null ? "" : row["Name"].ToString(),
298
                        SPPIDSYMBOLNAME = row["SPPID_SYMBOL_PATH"] == null ? "" : row["SPPID_SYMBOL_PATH"].ToString(),
299
                    });
300
                }
301
            }
302
        }
303

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

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

    
349
        private void InitSPPIDDB()
350
        {
351
            Project_Info _ProjectInfo = Project_Info.GetInstance();
352
            if (_ProjectInfo.Enable)
353
            {
354
                DataTable dt = Project_DB.SelectSPPID_DB_INFO();
355
                if (dt.Columns.Count > 0 && dt.Rows.Count > 0)
356
                    SPPIDUtil.ConvertToSPPIDInfo(dt.Rows[0][0].ToString());
357
                else
358
                    SPPID_DBInfo.Clear();
359
            }
360

    
361
            templateComboBox.Items.Clear();
362
            SPPID_DBInfo _SPPIDInfo = SPPID_DBInfo.GetInstance();
363
            if (_SPPIDInfo.Enable)
364
            {
365
                labelSPPIDPlantName.Text = _SPPIDInfo.SelectedPlant;
366
                labelSPPIDPlantName.AppearanceItemCaption.ForeColor = Color.Blue;
367
                labelSPPIDDBStatus.Text = Msg.ConnectionSuccessful;
368
                labelSPPIDDBStatus.AppearanceItemCaption.ForeColor = Color.Blue;
369

    
370
                string TemplatePath = SPPID_DB.GetPlantPID_T_OPTIONSETTING_Value("PID Template Path");
371
                if (!string.IsNullOrEmpty(TemplatePath))
372
                    templateComboBox.Items.AddRange(Directory.GetFiles(TemplatePath, "*.pid").ToList().Select(filePath => Path.GetFileName(filePath)).ToList());
373

    
374
                _SPPIDUnitDT = SPPID_DB.GetUnitTree();
375

    
376
                layoutControlGroupAutoConverter.Enabled = true;
377
            }
378
            else
379
            {
380
                labelSPPIDPlantName.Text = " ";
381
                labelSPPIDPlantName.AppearanceItemCaption.ForeColor = Color.Red;
382
                labelSPPIDDBStatus.Text = Msg.ConnectionFail;
383
                labelSPPIDDBStatus.AppearanceItemCaption.ForeColor = Color.Red;
384

    
385
                layoutControlGroupAutoConverter.Enabled = false;
386
            }
387

    
388
            _DicDocuments.Clear();
389
            _ConverterDT.Rows.Clear();
390
            InitSPPIDSymbolTreeTable();
391
        }
392

    
393
        private void InitSPPIDSymbolTreeTable()
394
        {
395
            SPPID_DBInfo _SPPIDInfo = SPPID_DBInfo.GetInstance();
396

    
397
            try
398
            {
399
                _SPPIDSymbolPathDT = new DataTable();
400
                _SPPIDSymbolPathDT.Columns.Add("ID");
401
                _SPPIDSymbolPathDT.Columns.Add("Parent");
402
                _SPPIDSymbolPathDT.Columns.Add("Name");
403
                _SPPIDSymbolPathDT.Columns.Add("FullPath");
404

    
405
                if (_SPPIDInfo.Enable)
406
                {
407
                    string symbolPath = SPPID_DB.GetPlantPID_T_OPTIONSETTING_Value("Catalog Explorer root path");
408
                    DirectoryInfo info = new DirectoryInfo(symbolPath);
409
                    _SPPIDSymbolPathDT.Rows.Add(new object[] { "0", "-1", info.Name });
410
                    loop(info, "0", symbolPath);
411
                }
412
            }
413
            catch (Exception ex)
414
            {
415
                MessageBox.Show(ex.Message + "\r\n" + ex.StackTrace);
416
            }
417
        }
418

    
419
        private void loop(DirectoryInfo parentInfo, string parentUID, string defaultPath)
420
        {
421
            DirectoryInfo[] infos = parentInfo.GetDirectories();
422
            foreach (DirectoryInfo info in infos)
423
            {
424
                string uid = Guid.NewGuid().ToString();
425
                _SPPIDSymbolPathDT.Rows.Add(new object[] { uid, parentUID, info.Name });
426
                loop(info, uid, defaultPath);
427

    
428
                FileInfo[] files = info.GetFiles("*.sym");
429
                foreach (FileInfo fileInfo in files)
430
                {
431
                    _SPPIDSymbolPathDT.Rows.Add(new object[] { Guid.NewGuid().ToString(), uid, fileInfo.Name, fileInfo.FullName.Replace(defaultPath, "") });
432
                }
433
            }
434
        }
435

    
436
        private void btnLoadFile_Click(object sender, EventArgs e)
437
        {
438
            Project_Info _ProjectInfo = Project_Info.GetInstance();
439
            if (!_ProjectInfo.Enable)
440
            {
441
                MessageBox.Show(Msg.PleaseSetID2ProjectInfo, Msg.Warning, MessageBoxButtons.OK, MessageBoxIcon.Warning);
442
                return;
443
            }
444

    
445
            xtraOpenFileDialog.InitialDirectory = _ProjectInfo.TempDirPath;
446
            if (xtraOpenFileDialog.ShowDialog() == DialogResult.OK)
447
            {
448
                foreach (string fileName in xtraOpenFileDialog.FileNames)
449
                {
450
                    SPPID_Document document = new SPPID_Document(fileName);
451

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

    
471
                    _DicDocuments[fileName] = document;
472
                }
473
            }
474
        }
475

    
476
        private void btnRun_Click(object sender, EventArgs e)
477
        {
478
            _Documents.Clear();
479
            foreach (int rowHandle in gridViewConverter.GetSelectedRows())
480
            {
481
                string _FilePath = gridViewConverter.GetRowCellDisplayText(rowHandle, "colDrawingFilePath");
482
                string _Unit = gridViewConverter.GetRowCellDisplayText(rowHandle, "colUnit");
483
                string _Template = gridViewConverter.GetRowCellDisplayText(rowHandle, "colTemplate");
484
                string _DrawingNumber = gridViewConverter.GetRowCellDisplayText(rowHandle, "colDrawingNumber");
485
                string _DrawingName = gridViewConverter.GetRowCellDisplayText(rowHandle, "colDrawingName");
486
                SPPID_Document document = _DicDocuments[_FilePath];
487
                document.Unit = _Unit;
488
                document.Template = _Template;
489
                document.DrawingNumber = _DrawingNumber;
490
                document.DrawingName = _DrawingName;
491

    
492
                document.SymbolTable = _ID2SymbolTable;
493
                document.SymbolMappings = symbolMappings;
494
                document.ChildSymbolMappings = childSymbolMappings;
495
                document.LineMappings = lineMappings;
496
                document.LineNumberMappings = lineNumberMappings;
497
                document.AttributeMappings = attributeMappings;
498
                document.ETCSetting = ETCSetting.GetInstance();
499
                document.SetSPPIDInfo();
500

    
501
                if (document.SetSPPIDMapping() && document.Enable)
502
                    _Documents.Add(document);
503
            }
504

    
505
            DialogResult = DialogResult.OK;
506
        }
507

    
508
        private void btnSPPIDDB_Click(object sender, EventArgs e)
509
        {
510
            SPPID_DB_SettingForm form = new SPPID_DB_SettingForm();
511
            if (form.ShowDialog() == DialogResult.OK)
512
                InitSPPIDDB();
513
        }
514

    
515
        private void btnItemMapping_Click(object sender, EventArgs e)
516
        {
517
            Project_Info _ProjectInfo = Project_Info.GetInstance();
518
            if (!_ProjectInfo.Enable)
519
            {
520
                MessageBox.Show(Msg.PleaseSetID2ProjectInfo, Msg.Warning, MessageBoxButtons.OK, MessageBoxIcon.Warning);
521
                return;
522
            }
523

    
524
            MappingForm form = new MappingForm(_ID2SymbolDT,_SPPIDSymbolPathDT, _ID2LineDT, _ID2LinePropertyDT, _ID2AttributeDT);
525
            form.ShowDialog();
526
            InitMapping();
527
        }
528
        private List<int> prevSelectedList = new List<int>();
529

    
530
        private void gridViewConverter_SelectionChanged(object sender, DevExpress.Data.SelectionChangedEventArgs e)
531
        {
532
            if (e.Action == CollectionChangeAction.Add)
533
            {
534
                string _Unit = gridViewConverter.GetRowCellDisplayText(e.ControllerRow, "colUnit");
535
                string _Template = gridViewConverter.GetRowCellDisplayText(e.ControllerRow, "colTemplate");
536

    
537
                if (string.IsNullOrEmpty(_Unit) || string.IsNullOrEmpty(_Template))
538
                    gridViewConverter.UnselectRow(e.ControllerRow);
539
            }
540
            else if (e.Action == CollectionChangeAction.Refresh)
541
            {
542
                foreach (int rowHandle in gridViewConverter.GetSelectedRows())
543
                {
544
                    string _Unit = gridViewConverter.GetRowCellDisplayText(rowHandle, "colUnit");
545
                    string _Template = gridViewConverter.GetRowCellDisplayText(rowHandle, "colTemplate");
546

    
547
                    if (string.IsNullOrEmpty(_Unit) || string.IsNullOrEmpty(_Template))
548
                        gridViewConverter.UnselectRow(rowHandle);
549
                }
550

    
551
                List<int> selectedRowHandleList = gridViewConverter.GetSelectedRows().ToList();
552
                var firstNotSecond = prevSelectedList.Except(selectedRowHandleList).ToList();
553
                var secondNotFirst = selectedRowHandleList.Except(prevSelectedList).ToList();
554

    
555
                if (!firstNotSecond.Any() && !secondNotFirst.Any())
556
                {
557
                    this.gridViewConverter.SelectionChanged -= new DevExpress.Data.SelectionChangedEventHandler(this.gridViewConverter_SelectionChanged);
558
                    gridViewConverter.ClearSelection();
559
                    this.gridViewConverter.SelectionChanged += new DevExpress.Data.SelectionChangedEventHandler(this.gridViewConverter_SelectionChanged);
560
                }
561
            }
562

    
563
            prevSelectedList = gridViewConverter.GetSelectedRows().ToList();
564
        }
565
    }
566
}
클립보드 이미지 추가 (최대 크기: 500 MB)