프로젝트

일반

사용자정보

통계
| 개정판:

hytos / DTI_PID / SPPIDConverter / ConverterForm.cs @ f1232880

이력 | 보기 | 이력해설 | 다운로드 (26.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
        private DataTable _ID2SymbolTypeDT = new DataTable();
42

    
43

    
44
        private List<SymbolMapping> symbolMappings = new List<SymbolMapping>();
45
        private List<LineMapping> lineMappings = new List<LineMapping>();
46
        private List<LineNumberMapping> lineNumberMappings = new List<LineNumberMapping>();
47
        private List<AssociationMapping> associationMappings = new List<AssociationMapping>();
48

    
49
        public ConverterForm()
50
        {
51
            InitializeComponent();
52

    
53
            CultureInfo culture = CultureInfo.GetCultureInfo("ko");
54
            Msg.Culture = culture;
55

    
56
            InitUsedDataTable();
57
            InitGridControl();
58
            InitID2Project();
59
        }
60

    
61
        #region
62
        /// <summary>
63
        /// The Activate Event is where the command should show its form
64
        /// if it should be displayed.
65
        /// </summary>
66
        /// <param name="sender">The sender of the event</param>
67
        /// <param name="e">Arguments passed during event</param>
68
        private void commandControl_Activate(object sender, EventArgs e)
69
        {
70
            if (ShowDialog() == DialogResult.OK)
71
            {
72

    
73
            }
74

    
75
            foreach (var item in commandControl.Application.RADApplication.ActiveSelectSet)
76
            {
77
                //MessageBox.Show(item.GetType());
78
                int count = ((Ingr.RAD2D.LineStringGeometry2d)((Ingr.RAD2D.DependencyObject)item).GetGeometry()).VertexCount;
79
                double[] iii = null;
80
                ((Ingr.RAD2D.LineStringGeometry2d)((Ingr.RAD2D.DependencyObject)item).GetGeometry()).GetVertices(ref count, ref iii);
81
                for (int i = 0; i < count; i++)
82
                {
83
                    double x = 0;
84
                    double y = 0;
85
                    ((Ingr.RAD2D.LineStringGeometry2d)((Ingr.RAD2D.DependencyObject)item).GetGeometry()).GetVertex(i + 1, ref x, ref y);
86

    
87
                }
88
                Ingr.RAD2D.Symbol2d symbol2D;
89
                //symbol2D.Move
90
            }
91

    
92
            //commandControl.Application.RADApplication.Interactive = true;
93
            //Hide();
94
            //commandControl.Done = true;
95
        }
96

    
97
        /// <summary>
98
        /// The Deactivate event is where the command should hide its form if it
99
        /// was displayed.  The command should not unload the form here.
100
        /// The command's form should be unloaded in the Class Module Terminate event.
101
        /// </summary>
102
        /// <param name="sender">The sender of the event</param>
103
        /// <param name="e">Arguments passed during event</param>
104
        private void commandControl_Deactivate(object sender, EventArgs e)
105
        {
106
            Hide();
107
        }
108

    
109
        /// <summary>
110
        /// The Initialize event is where the command should perform 1 time 
111
        /// initialization, for example it might save a reference to the 
112
        /// active document in private global data.
113
        /// </summary>
114
        /// <param name="sender">The sender of the event</param>
115
        /// <param name="e">Arguments passed during event</param>
116
        private void commandControl_Initialize(object sender, EventArgs e)
117
        {
118

    
119
        }
120

    
121
        /// <summary>
122
        /// The Terminate event is where the command can clean up any command
123
        /// specific allocated resources.
124
        /// </summary>
125
        /// <param name="sender">The sender of the event</param>
126
        /// <param name="e">Arguments passed during event</param>
127
        public void commandControl_Terminate(object sender, EventArgs e)
128
        {
129

    
130
        }
131

    
132
        /// <summary>
133
        /// The primary form should not simply be unloaded. You should set the
134
        /// Intergraph Command Control Done property to True when you want the 
135
        /// form to be unloaded. Then unload the form in the dispose method.
136
        /// </summary>
137
        /// <param name="sender">The sender of the event</param>
138
        /// <param name="e">Arguments passed during event</param>
139
        private void ConverterForm_FormClosing(object sender, FormClosingEventArgs e)
140
        {
141
            Hide();
142
            commandControl.Done = true;
143
            e.Cancel = true; //Do not let C# close out the form ... Let RAD close it.
144
        }
145
        #endregion
146

    
147
        private void InitUsedDataTable()
148
        {
149
            // Converter Table
150
            DataColumn col = _ConverterDT.Columns.Add("colDrawingFileName");
151
            col.Caption = "Drawing File Name";
152
            col = _ConverterDT.Columns.Add("colDrawingFilePath");
153
            col.Caption = "DrawingFilePath";
154
            col = _ConverterDT.Columns.Add("colUnit");
155
            col.Caption = "Unit";
156
            col = _ConverterDT.Columns.Add("colTemplate");
157
            col.Caption = "Template";
158
            col = _ConverterDT.Columns.Add("colDrawingNumber");
159
            col.Caption = "Drawing Number";
160
            col = _ConverterDT.Columns.Add("colDrawingName");
161
            col.Caption = "Drawing Name";
162
            col = _ConverterDT.Columns.Add("colStatus");
163
            col.Caption = "Status";
164
            col = _ConverterDT.Columns.Add("colUID");
165

    
166
            col = _ID2LineDT.Columns.Add("UID");
167
            col = _ID2LineDT.Columns.Add("Name");
168
            col.Caption = "Name";
169
            col = _ID2LineDT.Columns.Add("Type");
170
            col.Caption = "Type";
171
            col = _ID2LineDT.Columns.Add("SPPID_SYMBOL_PATH");
172
            col.Caption = "SPPID Symbol Path";
173
            col = _ID2LineDT.Columns.Add("Clear");
174
            col.Caption = "";
175
        }
176

    
177
        private void InitGridControl()
178
        {
179
            #region Converter Page
180
            gridViewConverter.OptionsSelection.MultiSelect = true;
181
            gridViewConverter.OptionsSelection.MultiSelectMode = DevExpress.XtraGrid.Views.Grid.GridMultiSelectMode.CheckBoxRowSelect;
182
            
183
            gridControlConverter.DataSource = _ConverterDT;
184

    
185
            templateComboBox = new RepositoryItemComboBox();
186
            templateComboBox.TextEditStyle = TextEditStyles.DisableTextEditor;
187
            templateComboBox.EditValueChanged += templateComboBox_EditValueChanged;
188
            gridControlConverter.RepositoryItems.Add(templateComboBox);
189
            gridViewConverter.Columns["colTemplate"].ColumnEdit = templateComboBox;
190

    
191
            gridViewConverter.Columns["colUnit"].OptionsColumn.AllowEdit = false;
192
            gridViewConverter.Columns["colDrawingFileName"].OptionsColumn.AllowEdit = false;
193
            gridViewConverter.Columns["colUnit"].OptionsColumn.ReadOnly = true;
194
            gridViewConverter.Columns["colStatus"].OptionsColumn.AllowEdit = false;
195
            gridViewConverter.Columns["colDrawingFilePath"].Visible = false;
196
            gridViewConverter.Columns["colUID"].Visible = false;
197

    
198
            gridViewConverter.BestFitColumns();
199
            #endregion
200
        }
201

    
202
        private void templateComboBox_EditValueChanged(object sender, EventArgs e)
203
        {
204
            gridViewConverter.CloseEditor();
205
            gridViewConverter.UpdateCurrentRow();
206
        }
207

    
208
        private void gridViewConverter_RowCellClick(object sender, DevExpress.XtraGrid.Views.Grid.RowCellClickEventArgs e)
209
        {
210
            if (e.Column.Name == "colcolTemplate")
211
            {
212
                gridViewConverter.ShowEditor();
213
                (gridViewConverter.ActiveEditor as ComboBoxEdit).ShowPopup();
214
            }
215
            else if (e.Column.Name == "colcolUnit")
216
            {
217
                UnitForm unitForm = new UnitForm(_SPPIDUnitDT);
218
                if (unitForm.ShowDialog() == DialogResult.OK)
219
                {
220
                    gridViewConverter.SetRowCellValue(e.RowHandle, e.Column, unitForm.SelectedUnit);
221
                    gridViewConverter.CloseEditor();
222
                    gridViewConverter.UpdateCurrentRow();
223
                }
224
            }
225
        }
226

    
227
        private void btnID2Project_ButtonClick(object sender, ButtonPressedEventArgs e)
228
        {
229
            xtraFolderBrowserDialog.SelectedPath = btnID2Project.Text;
230

    
231
            if (xtraFolderBrowserDialog.ShowDialog() == DialogResult.OK)
232
            {
233
                if (xtraFolderBrowserDialog.SelectedPath[xtraFolderBrowserDialog.SelectedPath.Length - 1] == '\\')
234
                    xtraFolderBrowserDialog.SelectedPath = xtraFolderBrowserDialog.SelectedPath.Remove(xtraFolderBrowserDialog.SelectedPath.Length - 1);
235
                Settings.Default.LatestProjectPath = xtraFolderBrowserDialog.SelectedPath;
236
                Settings.Default.Save();
237
                if (InitID2Project())
238
                {
239
                    MessageBox.Show(Msg.SuccessProjectSelect, Msg.Information, MessageBoxButtons.OK, MessageBoxIcon.Information);
240
                }
241
                else
242
                    MessageBox.Show(Msg.FailProjectSelect, Msg.Warning, MessageBoxButtons.OK, MessageBoxIcon.Warning);
243
            }
244
        }
245

    
246
        private bool InitID2Project()
247
        {
248
            Project_Info _ProjectInfo = Project_Info.GetInstance();
249
            _ProjectInfo.DefaultPath = Settings.Default.LatestProjectPath;
250
            if (Project_DB.ConnTestAndCreateTable())
251
            {
252
                _ProjectInfo.Enable = true;
253
                btnID2Project.Text = _ProjectInfo.DefaultPath;
254
                labelID2ProjectName.Text = _ProjectInfo.Name;
255
                labelID2ProjectName.AppearanceItemCaption.ForeColor = Color.Blue;
256
                labelID2ProjectStatus.Text = Msg.ConnectionSuccessful;
257
                labelID2ProjectStatus.AppearanceItemCaption.ForeColor = Color.Blue;
258
                layoutControlGroupSPPIDDB.Visibility = DevExpress.XtraLayout.Utils.LayoutVisibility.Always;
259
                layoutControlGroupItemMapping.Visibility = DevExpress.XtraLayout.Utils.LayoutVisibility.Always;
260
            }
261
            else
262
            {
263
                _ProjectInfo.Enable = false;
264
                btnID2Project.Text = "";
265
                labelID2ProjectName.Text = " ";
266
                labelID2ProjectName.AppearanceItemCaption.ForeColor = Color.Red;
267
                labelID2ProjectStatus.Text = Msg.ConnectionFail;
268
                labelID2ProjectStatus.AppearanceItemCaption.ForeColor = Color.Red;
269
                layoutControlGroupSPPIDDB.Visibility = DevExpress.XtraLayout.Utils.LayoutVisibility.Never;
270
                layoutControlGroupItemMapping.Visibility = DevExpress.XtraLayout.Utils.LayoutVisibility.Never;
271
            }
272

    
273
            InitMapping();
274
            InitSPPIDDB();
275

    
276
            return _ProjectInfo.Enable;
277
        }
278

    
279
        private void InitMapping()
280
        {
281
            Project_Info _ProjectInfo = Project_Info.GetInstance();
282
            if (_ProjectInfo.Enable)
283
            {
284
                InitID2Symbol();
285
                InitID2Line();
286
                InitID2LineNumber();
287
                InitID2Association();
288

    
289
                InitETCSetting();
290
            }
291
        }
292

    
293
        private void InitETCSetting()
294
        {
295
            Project_Info _ProjectInfo = Project_Info.GetInstance();
296
            if (_ProjectInfo.Enable)
297
            {
298
                DataTable dt = Project_DB.SelectETCSetting();
299
                if (dt.Columns.Count > 0 && dt.Rows.Count > 0)
300
                    SPPIDUtil.ConvertToETCSetting(dt.Rows[0][0].ToString());
301
                else
302
                    SPPID_DBInfo.Clear();
303
            }
304
        }
305

    
306
        private void InitID2Symbol()
307
        {
308
            using (DataTable symbolDT = Project_DB.SelectProjectSymbol())
309
            {
310
                symbolMappings.Clear();
311
                _ID2SymbolDT = symbolDT;
312
                _ID2SymbolDT.Columns.Add("Clear");
313
                _ID2SymbolDT.Columns["Clear"].Caption = "";
314
                foreach (DataRow row in symbolDT.Rows)
315
                {
316
                    symbolMappings.Add(new SymbolMapping()
317
                    {
318
                        UID = row["UID"] == null ? "" : row["UID"].ToString(),
319
                        SYMBOLNAME = row["Name"] == null ? "" : row["Name"].ToString(),
320
                        SPPIDSYMBOLNAME = row["SPPID_SYMBOL_PATH"] == null ? "" : row["SPPID_SYMBOL_PATH"].ToString(),
321
                    });
322
                }
323
            }
324
        }
325

    
326
        private void InitID2Line()
327
        {
328
            using (DataTable lineTypes = Project_DB.SelectProjectLine())
329
            {
330
                lineMappings.Clear();
331
                _ID2LineDT.Rows.Clear();
332
                foreach (DataRow row in lineTypes.Rows)
333
                {
334
                    DataRow newRow = _ID2LineDT.NewRow();
335
                    newRow["UID"] = row["UID"] == null ? "" : row["UID"].ToString();
336
                    newRow["Name"] = row["Name"] == null ? "" : row["Name"].ToString();
337
                    newRow["Type"] = "Line";
338
                    newRow["SPPID_SYMBOL_PATH"] = row["SPPID_SYMBOL_PATH"] == null ? "" : row["SPPID_SYMBOL_PATH"].ToString();
339
                    _ID2LineDT.Rows.Add(newRow);
340

    
341
                    lineMappings.Add(new LineMapping()
342
                    {
343
                        UID = row["UID"] == null ? "" : row["UID"].ToString(),
344
                        LINENAME = row["Name"] == null ? "" : row["Name"].ToString(),
345
                        SPPIDSYMBOLNAME = row["SPPID_SYMBOL_PATH"] == null ? "" : row["SPPID_SYMBOL_PATH"].ToString(),
346
                    });
347
                }
348
            }
349
        }
350

    
351
        private void InitID2LineNumber()
352
        {
353
            using (DataTable linePropertiesDT = Project_DB.SelectProjectLineProperties())
354
            {
355
                lineNumberMappings.Clear();
356
                _ID2LinePropertyDT = linePropertiesDT;
357
                _ID2LinePropertyDT.Columns.Add("Type");
358
                foreach (DataRow row in linePropertiesDT.Rows)
359
                {
360
                    row["Type"] = "Line Property";
361
                    lineNumberMappings.Add(new LineNumberMapping()
362
                    {
363
                        UID = row["UID"] == null ? "" : row["UID"].ToString(),
364
                        DisplayName = row["DisplayName"] == null ? "" : row["DisplayName"].ToString(),
365
                        SPPIDATTRIBUTENAME = row["SPPID_ATTRIBUTE"] == null ? "" : row["SPPID_ATTRIBUTE"].ToString(),
366
                        SPPIDSYMBOLNAME = row["SPPID_SYMBOL_PATH"] == null ? "" : row["SPPID_SYMBOL_PATH"].ToString()
367
                    });
368
                }
369
            }
370
        }
371

    
372
        private void InitID2Association()
373
        {
374
            using (DataTable associationDT = Project_DB.SelectProjectAssociation())
375
            {
376
                associationMappings.Clear();
377
                _ID2AssociationDT = associationDT;
378
                _ID2AssociationDT.Columns.Add("Clear");
379
                _ID2AssociationDT.Columns["Clear"].Caption = "";
380
                foreach (DataRow row in associationDT.Rows)
381
                {
382
                    associationMappings.Add(new AssociationMapping()
383
                    {
384
                        UID = row["UID"] == null ? "" : row["UID"].ToString(),
385
                        DisplayAttribute = row["DisplayAttribute"] == null ? "" : row["DisplayAttribute"].ToString(),
386
                        Type = row["Type"] == null ? "" : row["Type"].ToString(),
387
                        SPPIDATTRIBUTENAME = row["SPPID_ATTRIBUTE"] == null ? "" : row["SPPID_ATTRIBUTE"].ToString(),
388
                        SPPIDSYMBOLNAME = row["SPPID_SYMBOL_PATH"] == null ? "" : row["SPPID_SYMBOL_PATH"].ToString()
389
                    });
390
                }
391
            }
392
        }
393

    
394
        private void InitSPPIDDB()
395
        {
396
            Project_Info _ProjectInfo = Project_Info.GetInstance();
397
            if (_ProjectInfo.Enable)
398
            {
399
                DataTable dt = Project_DB.SelectSPPID_DB_INFO();
400
                if (dt.Columns.Count > 0 && dt.Rows.Count > 0)
401
                    SPPIDUtil.ConvertToSPPIDInfo(dt.Rows[0][0].ToString());
402
                else
403
                    SPPID_DBInfo.Clear();
404
            }
405

    
406
            templateComboBox.Items.Clear();
407
            SPPID_DBInfo _SPPIDInfo = SPPID_DBInfo.GetInstance();
408
            if (_SPPIDInfo.Enable)
409
            {
410
                labelSPPIDPlantName.Text = _SPPIDInfo.SelectedPlant;
411
                labelSPPIDPlantName.AppearanceItemCaption.ForeColor = Color.Blue;
412
                labelSPPIDDBStatus.Text = Msg.ConnectionSuccessful;
413
                labelSPPIDDBStatus.AppearanceItemCaption.ForeColor = Color.Blue;
414

    
415
                string TemplatePath = SPPID_DB.GetPlantPID_T_OPTIONSETTING_Value("PID Template Path");
416
                if (!string.IsNullOrEmpty(TemplatePath))
417
                    templateComboBox.Items.AddRange(Directory.GetFiles(TemplatePath, "*.pid").ToList().Select(filePath => Path.GetFileName(filePath)).ToList());
418

    
419
                _SPPIDUnitDT = SPPID_DB.GetUnitTree();
420

    
421
                layoutControlGroupAutoConverter.Enabled = true;
422
            }
423
            else
424
            {
425
                labelSPPIDPlantName.Text = " ";
426
                labelSPPIDPlantName.AppearanceItemCaption.ForeColor = Color.Red;
427
                labelSPPIDDBStatus.Text = Msg.ConnectionFail;
428
                labelSPPIDDBStatus.AppearanceItemCaption.ForeColor = Color.Red;
429

    
430
                layoutControlGroupAutoConverter.Enabled = false;
431
            }
432

    
433
            _DicDocuments.Clear();
434
            _ConverterDT.Rows.Clear();
435
            InitSPPIDSymbolTreeTable();
436
        }
437

    
438
        private void InitSPPIDSymbolTreeTable()
439
        {
440
            SPPID_DBInfo _SPPIDInfo = SPPID_DBInfo.GetInstance();
441

    
442
            _SPPIDSymbolPathDT = new DataTable();
443
            _SPPIDSymbolPathDT.Columns.Add("ID");
444
            _SPPIDSymbolPathDT.Columns.Add("Parent");
445
            _SPPIDSymbolPathDT.Columns.Add("Name");
446
            _SPPIDSymbolPathDT.Columns.Add("FullPath");
447

    
448
            if (_SPPIDInfo.Enable)
449
            {
450
                string symbolPath = SPPID_DB.GetPlantPID_T_OPTIONSETTING_Value("Catalog Explorer root path");
451
                DirectoryInfo info = new DirectoryInfo(symbolPath);
452
                _SPPIDSymbolPathDT.Rows.Add(new object[] { "0", "-1", info.Name });
453
                loop(info, "0", symbolPath);
454
            }
455
        }
456

    
457
        private void loop(DirectoryInfo parentInfo, string parentUID, string defaultPath)
458
        {
459
            DirectoryInfo[] infos = parentInfo.GetDirectories();
460
            foreach (DirectoryInfo info in infos)
461
            {
462
                string uid = Guid.NewGuid().ToString();
463
                _SPPIDSymbolPathDT.Rows.Add(new object[] { uid, parentUID, info.Name });
464
                loop(info, uid, defaultPath);
465

    
466
                FileInfo[] files = info.GetFiles("*.sym");
467
                foreach (FileInfo fileInfo in files)
468
                {
469
                    _SPPIDSymbolPathDT.Rows.Add(new object[] { Guid.NewGuid().ToString(), uid, fileInfo.Name, fileInfo.FullName.Replace(defaultPath, "") });
470
                }
471
            }
472
        }
473

    
474
        private void btnLoadFile_Click(object sender, EventArgs e)
475
        {
476
            Project_Info _ProjectInfo = Project_Info.GetInstance();
477
            if (!_ProjectInfo.Enable)
478
            {
479
                MessageBox.Show(Msg.PleaseSetID2ProjectInfo, Msg.Warning, MessageBoxButtons.OK, MessageBoxIcon.Warning);
480
                return;
481
            }
482

    
483
            xtraOpenFileDialog.InitialDirectory = _ProjectInfo.TempDirPath;
484
            if (xtraOpenFileDialog.ShowDialog() == DialogResult.OK)
485
            {
486
                foreach (string fileName in xtraOpenFileDialog.FileNames)
487
                {
488
                    SPPID_Document document = new SPPID_Document(fileName);
489

    
490
                    DataRow[] rows = _ConverterDT.Select(string.Format("colDrawingFilePath = '{0}'", fileName));
491
                    DataRow row;
492
                    if (rows.Length == 0)
493
                    {
494
                        row = _ConverterDT.NewRow();
495
                        row["colDrawingFileName"] = Path.GetFileNameWithoutExtension(fileName);
496
                        row["colDrawingFilePath"] = fileName;
497
                        row["colDrawingNumber"] = document.DWGNAME;
498
                        row["colDrawingName"] = document.DWGNAME;
499
                        if (document.Enable)
500
                            row["colStatus"] = "Ready";
501
                        else
502
                            row["colStatus"] = "Error";
503
                        row["colUID"] = "";
504
                        _ConverterDT.Rows.Add(row);
505
                    }
506
                    if (!_DicDocuments.ContainsKey(fileName))
507
                        _DicDocuments.Add(fileName, null);
508

    
509
                    _DicDocuments[fileName] = document;
510
                }
511
            }
512
        } 
513

    
514
        private void btnRun_Click(object sender, EventArgs e)
515
        {
516
#if DEBUG
517
            //SPPID_Document document = new SPPID_Document(@"Z:\HanKyouHo\temp\Isocynates\Temp\11111.xml");
518
            SPPID_Document document = new SPPID_Document(@"Z:\HanKyouHo\temp\Isocynates\Temp\zIsocynates-325_Page75.xml");
519
            document.SymbolMappings = symbolMappings;
520
            document.LineMappings = lineMappings;
521
            document.LineNumberMappings = lineNumberMappings;
522
            document.AssociationMappings = associationMappings;
523
            document.ETCSetting = ETCSetting.GetInstance();
524

    
525
            document.SetSPPIDInfo();
526

    
527
            if (document.SetSPPIDMapping() && document.Enable)
528
            {
529
                AutoModeling modeling = new AutoModeling(document);
530
                modeling.Run();
531
            }
532

    
533
            return;
534
#endif
535

    
536
            //_Documents.Clear();
537

    
538
            //foreach (int rowHandle in gridViewConverter.GetSelectedRows())
539
            //{
540
            //    string _FilePath = gridViewConverter.GetRowCellDisplayText(rowHandle, "colDrawingFilePath");
541
            //    string _Unit = gridViewConverter.GetRowCellDisplayText(rowHandle, "colUnit");
542
            //    string _Template = gridViewConverter.GetRowCellDisplayText(rowHandle, "colTemplate");
543
            //    string _DrawingNumber = gridViewConverter.GetRowCellDisplayText(rowHandle, "colDrawingNumber");
544
            //    string _DrawingName = gridViewConverter.GetRowCellDisplayText(rowHandle, "colDrawingName");
545
            //    SPPID_Document document = _DicDocuments[_FilePath];
546
            //    document.Unit = _Unit;
547
            //    document.Template = _Template;
548
            //    document.DrawingNumber = _DrawingNumber;
549
            //    document.DrawingName = _DrawingName;
550
            //    _Documents.Add(document);
551
            //}
552

    
553
            DialogResult = DialogResult.OK;
554
        }
555

    
556
        private void btnSPPIDDB_Click(object sender, EventArgs e)
557
        {
558
            SPPID_DB_SettingForm form = new SPPID_DB_SettingForm();
559
            if (form.ShowDialog() == DialogResult.OK)
560
                InitSPPIDDB();
561
        }
562

    
563
        private void btnItemMapping_Click(object sender, EventArgs e)
564
        {
565
            Project_Info _ProjectInfo = Project_Info.GetInstance();
566
            if (!_ProjectInfo.Enable)
567
            {
568
                MessageBox.Show(Msg.PleaseSetID2ProjectInfo, Msg.Warning, MessageBoxButtons.OK, MessageBoxIcon.Warning);
569
                return;
570
            }
571

    
572
            MappingForm form = new MappingForm(_ID2SymbolDT,_SPPIDSymbolPathDT, _ID2LineDT, _ID2LinePropertyDT, _ID2AssociationDT);
573
            form.ShowDialog();
574
            InitMapping();
575
        }
576
        private List<int> prevSelectedList = new List<int>();
577

    
578
        private void gridViewConverter_SelectionChanged(object sender, DevExpress.Data.SelectionChangedEventArgs e)
579
        {
580
            if (e.Action == CollectionChangeAction.Add)
581
            {
582
                string _Unit = gridViewConverter.GetRowCellDisplayText(e.ControllerRow, "colUnit");
583
                string _Template = gridViewConverter.GetRowCellDisplayText(e.ControllerRow, "colTemplate");
584

    
585
                if (string.IsNullOrEmpty(_Unit) || string.IsNullOrEmpty(_Template))
586
                    gridViewConverter.UnselectRow(e.ControllerRow);
587
            }
588
            else if (e.Action == CollectionChangeAction.Refresh)
589
            {
590
                foreach (int rowHandle in gridViewConverter.GetSelectedRows())
591
                {
592
                    string _Unit = gridViewConverter.GetRowCellDisplayText(rowHandle, "colUnit");
593
                    string _Template = gridViewConverter.GetRowCellDisplayText(rowHandle, "colTemplate");
594

    
595
                    if (string.IsNullOrEmpty(_Unit) || string.IsNullOrEmpty(_Template))
596
                        gridViewConverter.UnselectRow(rowHandle);
597
                }
598

    
599
                List<int> selectedRowHandleList = gridViewConverter.GetSelectedRows().ToList();
600
                var firstNotSecond = prevSelectedList.Except(selectedRowHandleList).ToList();
601
                var secondNotFirst = selectedRowHandleList.Except(prevSelectedList).ToList();
602

    
603
                if (!firstNotSecond.Any() && !secondNotFirst.Any())
604
                {
605
                    this.gridViewConverter.SelectionChanged -= new DevExpress.Data.SelectionChangedEventHandler(this.gridViewConverter_SelectionChanged);
606
                    gridViewConverter.ClearSelection();
607
                    this.gridViewConverter.SelectionChanged += new DevExpress.Data.SelectionChangedEventHandler(this.gridViewConverter_SelectionChanged);
608
                }
609
            }
610

    
611
            prevSelectedList = gridViewConverter.GetSelectedRows().ToList();
612
        }
613
    }
614
}
클립보드 이미지 추가 (최대 크기: 500 MB)