프로젝트

일반

사용자정보

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

hytos / DTI_PID / SPPIDConverter_CustomCommand / ConverterForm.cs @ 1cad80c1

이력 | 보기 | 이력해설 | 다운로드 (24.9 KB)

1 d57a5303 gaqhf
/*---------------------------------------------------------------------+\
2
|                                                                       |
3
|        Copyright 2016 Intergraph Corporation                          |
4
|        All Rights Reserved                                            |
5
|                                                                       |
6
|        Including software, file formats, and audio-visual displays;   |
7
|        may only be used pursuant to applicable software license       |
8
|        agreement; contains confidential and proprietary information of|
9
|        Intergraph and/or third parties which is protected by copyright|
10
|        and trade secret law and may not be provided or otherwise made |
11
|        available without proper authorization.                        |
12
|                                                                       |
13
|        Unpublished -- rights reserved under the Copyright Laws of the |
14
|        United States.                                                 |
15
|                                                                       |
16
|        Intergraph Corporation                                         |
17
|        Huntsville, Alabama         35894-0001                         |
18
|                                                                       |
19
\+---------------------------------------------------------------------*/
20
21
using System;
22 91502a9b gaqhf
using System.Collections.Generic;
23 d57a5303 gaqhf
using System.Windows.Forms;
24
using Ingr.RAD2D;
25 022cae08 gaqhf
using System.Runtime.InteropServices;
26
using System.Drawing;
27 d57a5303 gaqhf
using SPPID.Modeling;
28
using SPPID.Utill;
29
using SPPID.Model;
30 91502a9b gaqhf
using System.Threading;
31 4582b1d2 gaqhf
using Microsoft.Win32;
32 d57a5303 gaqhf
33
namespace CustomCommand
34
{
35
    /// <summary>
36
    /// This is the primary form.  The form is shown as modal.
37
    /// This command may be built as an executable (EXE) or as a dynamic link 
38
    /// library (DLL).
39
    /// 
40
    /// When you implement the code that dismisses your form, e.g., an OK
41
    /// button or a Stop Processing button, you should include the following:
42
    /// 
43
    ///     Hide the form, for example
44
    ///         converterForm.Hide
45
    ///     
46
    ///     Set the Application's Interactive property to True, for example
47
    ///         commandControl.Application.Interactive = True
48
    ///
49
    ///     Set Intergraph Command Control Done property to True, for example
50
    ///         commandControl.Done = True
51
    /// </summary>
52
    public partial class ConverterForm : Form
53
    {
54
        #region Default CustomCommand
55 91502a9b gaqhf
        readonly string menuControlName = "ID2 to SPPID Converter";
56
        readonly string toolTipText = "ID2 to SPPID Converter";
57 1cad80c1 gaqhf
        readonly Image image = (Image)Properties.Resources.ResourceManager.GetObject("ToolbarImage");
58 d57a5303 gaqhf
        /// <summary>
59
        /// Constructs and initializes the form.
60
        /// </summary>
61
        public ConverterForm()
62
        {
63
            InitializeComponent();
64
        }
65
        
66
        /// <summary>
67
        /// The OK Click Event is used to dismiss the form.
68
        /// </summary>
69
        /// <param name="sender">The sender of the event</param>
70
        /// <param name="e">Arguments passed during event</param>
71
        //private void cmdOK_Click(object sender, EventArgs e)
72
        //{
73
        //    commandControl.Application.RADApplication.Interactive = true;
74
        //    Hide();
75
        //    commandControl.Done = true;
76
        //}
77
78
        /// <summary>
79
        /// The Activate Event is where the command should show its form
80
        /// if it should be displayed.
81
        /// </summary>
82
        /// <param name="sender">The sender of the event</param>
83
        /// <param name="e">Arguments passed during event</param>
84
        private void commandControl_Activate(object sender, EventArgs e)
85
        {
86
            ShowDialog();
87
        }
88
89
        /// <summary>
90
        /// The Deactivate event is where the command should hide its form if it
91
        /// was displayed.  The command should not unload the form here.
92
        /// The command's form should be unloaded in the Class Module Terminate event.
93
        /// </summary>
94
        /// <param name="sender">The sender of the event</param>
95
        /// <param name="e">Arguments passed during event</param>
96
        private void commandControl_Deactivate(object sender, EventArgs e)
97
        {
98
            Hide();
99
        }
100
101
        /// <summary>
102
        /// The Initialize event is where the command should perform 1 time 
103
        /// initialization, for example it might save a reference to the 
104
        /// active document in private global data.
105
        /// </summary>
106
        /// <param name="sender">The sender of the event</param>
107
        /// <param name="e">Arguments passed during event</param>
108
        private void commandControl_Initialize(object sender, EventArgs e)
109
        {
110 91502a9b gaqhf
            try
111
            {
112 4582b1d2 gaqhf
                RegistryKey key = Registry.LocalMachine;
113
                RegistryKey software = key.OpenSubKey("SOFTWARE");
114
                RegistryKey DOFTECH = software.OpenSubKey("DOFTECH");
115
                if (DOFTECH != null)
116 91502a9b gaqhf
                {
117 4582b1d2 gaqhf
                    RegistryKey ID2 = DOFTECH.OpenSubKey("ID2");
118
                    if (ID2 != null)
119 91502a9b gaqhf
                    {
120 4582b1d2 gaqhf
                        SPPIDUtill.defaultPath = ID2.GetValue("Path").ToString();
121
122
                        Log.logPath = SPPIDUtill.defaultPath + @"Converter\SPPID Converter.log";
123
                        SPPIDUtill.mappingFilePath = SPPIDUtill.defaultPath + @"Converter\mapping.xml";
124
                        string dllPath = SPPIDUtill.defaultPath + @"Converter\SPPIDConverter_CustomCommand.dll";
125
126
                        SPPIDUtill.LoadMapping(mapping);
127
                        Ingr.RAD2D.Application application = commandControl.Application.RADApplication;
128
129
                        ToolBars toolBars = application.ToolBars;
130
                        bool find = true;
131
                        while (find)
132 91502a9b gaqhf
                        {
133 4582b1d2 gaqhf
                            find = false;
134
                            foreach (ToolbarControl item in toolBars["Main"].Controls)
135
                            {
136
                                if (item.DLLName.Contains("SPPIDConverter_CustomCommand.dll"))
137
                                {
138
                                    item.Delete();
139
                                    find = true;
140
                                    break;
141
                                }
142
                            }
143 91502a9b gaqhf
                        }
144
145 4582b1d2 gaqhf
                        ToolbarControl toolBarControl = toolBars["Main"].Controls.AppendMacroCommand(dllPath);
146
                        toolBarControl.ToolTipText = toolTipText;
147
                        //toolBarControl.Picture = image;
148 91502a9b gaqhf
149 4582b1d2 gaqhf
                        Menus menu = application.Menus;
150
                        find = true;
151
                        while (find)
152 91502a9b gaqhf
                        {
153 4582b1d2 gaqhf
                            find = false;
154
                            foreach (MenuControl item in menu["&Tools"].Controls)
155
                            {
156
                                if (item.Caption == menuControlName)
157
                                {
158
                                    item.Delete();
159
                                    find = true;
160
                                    break;
161
                                }
162
                            }
163 91502a9b gaqhf
                        }
164 4582b1d2 gaqhf
                        MenuControl menuControl = application.Menus["&Tools"].Controls.AppendMacroCommand(menuControlName, dllPath);
165
                        menuControl.ToolTipText = toolTipText;
166 91502a9b gaqhf
                    }
167
                }
168
            }
169
            catch (Exception ex)
170
            {
171
                Log.WriteLine(ex);
172
            }
173 d57a5303 gaqhf
        }
174
175
        /// <summary>
176
        /// The Terminate event is where the command can clean up any command
177
        /// specific allocated resources.
178
        /// </summary>
179
        /// <param name="sender">The sender of the event</param>
180
        /// <param name="e">Arguments passed during event</param>
181
        public void commandControl_Terminate(object sender, EventArgs e)
182
        {
183 91502a9b gaqhf
           
184 d57a5303 gaqhf
        }
185
186
        /// <summary>
187
        /// The primary form should not simply be unloaded. You should set the
188
        /// Intergraph Command Control Done property to True when you want the 
189
        /// form to be unloaded. Then unload the form in the dispose method.
190
        /// </summary>
191
        /// <param name="sender">The sender of the event</param>
192
        /// <param name="e">Arguments passed during event</param>
193
        private void ConverterForm_FormClosing(object sender, FormClosingEventArgs e)
194
        {
195
            commandControl.Application.RADApplication.Interactive = true; // Add by kyouho
196
            Hide();
197
            commandControl.Done = true;
198
            e.Cancel = true; //Do not let C# close out the form ... Let RAD close it.
199
        }
200 022cae08 gaqhf
        #endregion
201
202
        #region ?? CustomCommand Source ????
203
204 91502a9b gaqhf
        private Dictionary<string, string> mapping = new Dictionary<string, string>();
205
        Thread autoModelingThread;
206
207
        #region Botton Event
208 022cae08 gaqhf
        private void openDocumentsToolStripMenuItem_Click(object sender, EventArgs e)
209
        {
210
            OpenFileDialog dia = new OpenFileDialog();
211
            dia.Multiselect = true;
212 91502a9b gaqhf
            dia.Filter = "Xml Files(*.xml)|*.xml";
213 022cae08 gaqhf
            if (dia.ShowDialog() == DialogResult.OK)
214
            {
215 91502a9b gaqhf
                SPPIDUtill.LoadMapping(mapping);
216 022cae08 gaqhf
                foreach (string fileName in dia.FileNames)
217
                    SetDrawingTreeNode(fileName);
218
                treeViewDrawing.Nodes[0].Expand();
219 91502a9b gaqhf
                RefreshItemNode();
220 022cae08 gaqhf
            }
221
        }
222
223
        private void itemMappingToolStripMenuItem_Click(object sender, EventArgs e)
224
        {
225 91502a9b gaqhf
            List<string> needName = GetNeedMapping();
226
            MappingForm form = new MappingForm(mapping, needName);
227
            if (form.ShowDialog() == DialogResult.OK)
228
            {
229
                SPPIDUtill.SaveMapping(mapping);
230
                RefreshItemNode();
231
            }
232 022cae08 gaqhf
        }
233
234
        private void importToolStripMenuItem_Click(object sender, EventArgs e)
235
        {
236 91502a9b gaqhf
            OpenFileDialog dia = new OpenFileDialog();
237
            dia.Multiselect = false;
238
            dia.Filter = "Excel File(*.xlsx;*.xls)|*.xlsx;*.xls";
239
            if (dia.ShowDialog() == DialogResult.OK)
240
            {
241
                ExcelUtill.LoadMappingExcelFile(dia.FileName, mapping);
242
                try
243
                {
244
                    SPPIDUtill.SaveMapping(mapping);
245
                    RefreshItemNode();
246
                    MessageBox.Show("Success Load Excel File");
247
                }
248
                catch (Exception ex)
249
                {
250
                    Log.WriteLine(ex);
251
                    MessageBox.Show("Fail Save Mapping File");
252
                }
253
            }
254 022cae08 gaqhf
        }
255 91502a9b gaqhf
256 022cae08 gaqhf
        private void convertToolStripMenuItem_Click(object sender, EventArgs e)
257
        {
258 1cad80c1 gaqhf
            Ingr.RAD2D.Application application = commandControl.Application.RADApplication;
259
260 91502a9b gaqhf
            SPPIDUtill.LoadMapping(mapping);
261
262
            List<SPPID.Model.Document> documents = new List<SPPID.Model.Document>();
263
            foreach (TreeNode node in treeViewDrawing.Nodes[0].Nodes)
264
            {
265
                if (node.Checked)
266
                {
267
                    SPPID.Model.Document document = node.Tag as SPPID.Model.Document;
268
                    if (document != null && document.Init())
269
                        documents.Add(document);
270
                }
271
            }
272 022cae08 gaqhf
273 1cad80c1 gaqhf
            //Ingr.RAD2D.Document SPPID_Doc = application.Documents.Add();
274
            //SPPID_Doc.SaveOnClose = false;
275
            //SPPID_Doc.SaveAs(@"C:\dasd.pid");
276
            //SPPID_Doc.Close(false);
277
278
279
            // Save ??? ????
280
            string folderPath = "";
281
            if (documents.Count > 0)
282
            {
283
                FolderBrowserDialog dia = new FolderBrowserDialog();
284
                dia.ShowNewFolderButton = true;
285
                if (dia.ShowDialog() == DialogResult.OK)
286
                    folderPath = dia.SelectedPath + @"\";
287
                else
288
                    return;
289
            }
290
291 91502a9b gaqhf
            autoModelingThread = new Thread(Func =>
292
            {
293
                try
294
                {
295
                    foreach (SPPID.Model.Document document in documents)
296
                    {
297 1cad80c1 gaqhf
                        Ingr.RAD2D.Document SPPID_Doc = application.Documents.Add();
298
                        SPPID_Doc.SaveOnClose = false;
299
300 91502a9b gaqhf
                        AutoModeling auto = new AutoModeling(document);
301
                        auto.SetListBoxLog(listBoxLog);
302
                        auto.SetProgressBar(toolStripProgressBar);
303
                        auto.Run();
304 1cad80c1 gaqhf
305
                        SPPID_Doc.SaveAs(@"C:\" + document.DWGNAME);
306
                        SPPID_Doc.Close(false);
307 91502a9b gaqhf
                    }
308
                }
309
                catch (Exception ex)
310
                {
311
                    Log.WriteLine(ex);
312
                }
313
            });
314
            autoModelingThread.Start();
315 022cae08 gaqhf
        }
316
317
        private void stopToolStripMenuItem_Click(object sender, EventArgs e)
318
        {
319 91502a9b gaqhf
            try
320
            {
321
                if (autoModelingThread != null)
322
                    autoModelingThread.Abort();
323
            }
324
            catch (Exception ex)
325
            {
326
                Log.WriteLine(ex);
327
            }
328
        }
329
        #endregion
330 022cae08 gaqhf
331 91502a9b gaqhf
        private void listBoxLog_DrawItem(object sender, DrawItemEventArgs e)
332
        {
333
            if (e.Index >= 0)
334
            {
335
                ListBoxItem item = listBoxLog.Items[e.Index] as ListBoxItem;
336
                if (item != null)
337
                {
338
                    e.Graphics.DrawString(item.Message,
339
                        listBoxLog.Font,
340
                        new SolidBrush(item.Color),
341
                        0,
342
                        e.Index * listBoxLog.ItemHeight);
343
                }
344
            }
345 022cae08 gaqhf
        }
346
347
        #region TreeNode
348 91502a9b gaqhf
349 022cae08 gaqhf
        #region Hide TreeNode CheckBox
350
        private const int TVIF_STATE = 0x8;
351
        private const int TVIS_STATEIMAGEMASK = 0xF000;
352
        private const int TV_FIRST = 0x1100;
353
        private const int TVM_SETITEM = TV_FIRST + 63;
354
355
        [StructLayout(LayoutKind.Sequential, Pack = 8, CharSet = CharSet.Auto)]
356
        private struct TVITEM
357
        {
358
            public int mask;
359
            public IntPtr hItem;
360
            public int state;
361
            public int stateMask;
362
            [MarshalAs(UnmanagedType.LPTStr)]
363
            public string lpszText;
364
            public int cchTextMax;
365
            public int iImage;
366
            public int iSelectedImage;
367
            public int cChildren;
368
            public IntPtr lParam;
369
        }
370
371
        [DllImport("user32.dll", CharSet = CharSet.Auto)]
372
        private static extern IntPtr SendMessage(IntPtr hWnd, int Msg, IntPtr wParam,
373
                                                 ref TVITEM lParam);
374
375
        /// <summary>
376
        /// Hides the checkbox for the specified node on a TreeView control.
377
        /// </summary>
378
        private void HideCheckBox(TreeView tvw, TreeNode node)
379
        {
380
            TVITEM tvi = new TVITEM();
381
            tvi.hItem = node.Handle;
382
            tvi.mask = TVIF_STATE;
383
            tvi.stateMask = TVIS_STATEIMAGEMASK;
384
            tvi.state = 0;
385
            SendMessage(tvw.Handle, TVM_SETITEM, IntPtr.Zero, ref tvi);
386
        }
387
        #endregion
388
389
        private void SetDrawingTreeNode(string fileName)
390
        {
391 91502a9b gaqhf
            SPPID.Model.Document document = SPPID.Model.Document.Load(fileName, mapping);
392 1cad80c1 gaqhf
393 022cae08 gaqhf
            TreeNode drawingNode = new TreeNode();
394
            if (document == null)
395
            {
396
                drawingNode.Text = fileName;
397
                drawingNode.Name = fileName;
398
                drawingNode.ForeColor = Color.Red;
399
                treeViewDrawing.Nodes[0].Nodes.Add(drawingNode);
400
            }
401
            else
402
            {
403 1cad80c1 gaqhf
                foreach (TreeNode treeNode in treeViewDrawing.Nodes[0].Nodes)
404
                {
405
                    if (treeNode.Text == document.DWGNAME)
406
                    {
407
                        treeViewDrawing.Nodes[0].Nodes.Remove(treeNode);
408
                        break;
409
                    }
410
                }
411
412 022cae08 gaqhf
                drawingNode.Text = document.DWGNAME;
413
                drawingNode.Name = document.DWGNAME;
414
                drawingNode.Tag = document;
415
                treeViewDrawing.Nodes[0].Nodes.Add(drawingNode);
416
            }
417
418
            SetItemTreeNode(drawingNode);
419
        }
420
421
        private void SetItemTreeNode(TreeNode drawingNode)
422
        {
423
            SPPID.Model.Document document = drawingNode.Tag as SPPID.Model.Document;
424
            if (document != null)
425
            {
426
                foreach (LineNumber item in document.LINENUMBERS)
427
                {
428
                    TreeNode node = new TreeNode();
429 f9d4b6aa gaqhf
                    node.Name = LineNumber.LineNumberSymbolPath;
430 022cae08 gaqhf
                    node.Text = item.TEXT;
431 91502a9b gaqhf
                    node.Tag = item;
432 022cae08 gaqhf
                    drawingNode.Nodes.Add(node);
433
                    HideCheckBox(treeViewDrawing, node);
434 91502a9b gaqhf
                    foreach (ItemAttribute attribute in item.ATTRIBUTES)
435
                    {
436
                        TreeNode attrNode = new TreeNode();
437
                        attrNode.Name = attribute.Attribute;
438
                        attrNode.Text = attribute.Attribute;
439
                        attrNode.Tag = attribute;
440
                        node.Nodes.Add(attrNode);
441
                        HideCheckBox(treeViewDrawing, attrNode);
442
                    }
443 022cae08 gaqhf
                }
444
445
                foreach (Symbol item in document.SYMBOLS)
446
                {
447
                    TreeNode node = new TreeNode();
448 91502a9b gaqhf
                    node.Name = item.PARENT;
449 022cae08 gaqhf
                    node.Text = item.NAME;
450 91502a9b gaqhf
                    node.Tag = item;
451 022cae08 gaqhf
                    drawingNode.Nodes.Add(node);
452
                    HideCheckBox(treeViewDrawing, node);
453 91502a9b gaqhf
                    foreach (ItemAttribute attribute in item.ATTRIBUTES)
454
                    {
455
                        TreeNode attrNode = new TreeNode();
456
                        attrNode.Name = attribute.Attribute;
457
                        attrNode.Text = attribute.Attribute;
458
                        attrNode.Tag = attribute;
459
                        node.Nodes.Add(attrNode);
460
                        HideCheckBox(treeViewDrawing, attrNode);
461
                    }
462 022cae08 gaqhf
                }
463
464
                foreach (Line item in document.LINES)
465
                {
466
                    TreeNode node = new TreeNode();
467 91502a9b gaqhf
                    node.Name = item.TYPE;
468 022cae08 gaqhf
                    node.Text = item.TYPE;
469 91502a9b gaqhf
                    node.Tag = item;
470 022cae08 gaqhf
                    drawingNode.Nodes.Add(node);
471
                    HideCheckBox(treeViewDrawing, node);
472 91502a9b gaqhf
                    foreach (ItemAttribute attribute in item.ATTRIBUTES)
473
                    {
474
                        TreeNode attrNode = new TreeNode();
475
                        attrNode.Name = attribute.Attribute;
476
                        attrNode.Text = attribute.Attribute;
477
                        attrNode.Tag = attribute;
478
                        node.Nodes.Add(attrNode);
479
                        HideCheckBox(treeViewDrawing, attrNode);
480
                    }
481 022cae08 gaqhf
                }
482
483
                foreach (Text item in document.TEXTS)
484
                {
485
                    TreeNode node = new TreeNode();
486 91502a9b gaqhf
                    node.Name = item.NAME;
487 022cae08 gaqhf
                    node.Text = item.NAME;
488 91502a9b gaqhf
                    node.Tag = item;
489 022cae08 gaqhf
                    drawingNode.Nodes.Add(node);
490
                    HideCheckBox(treeViewDrawing, node);
491 91502a9b gaqhf
                    foreach (ItemAttribute attribute in item.ATTRIBUTES)
492
                    {
493
                        TreeNode attrNode = new TreeNode();
494
                        attrNode.Name = attribute.Attribute;
495
                        attrNode.Text = attribute.Attribute;
496
                        attrNode.Tag = attribute;
497
                        node.Nodes.Add(attrNode);
498
                        HideCheckBox(treeViewDrawing, attrNode);
499
                    }
500 022cae08 gaqhf
                }
501
            }
502
        }
503
504 91502a9b gaqhf
        private void RefreshItemNode()
505 022cae08 gaqhf
        {
506 f9d4b6aa gaqhf
            foreach (TreeNode docNode in treeViewDrawing.Nodes[0].Nodes)
507 91502a9b gaqhf
            {
508 f9d4b6aa gaqhf
                docNode.ForeColor = Color.Red;
509 91502a9b gaqhf
                bool result = true;
510 f9d4b6aa gaqhf
                foreach (TreeNode itemNode in docNode.Nodes)
511 91502a9b gaqhf
                {
512 f9d4b6aa gaqhf
                    string name = itemNode.Name;
513
                    if (name == "SIZE")
514 91502a9b gaqhf
                    {
515 f9d4b6aa gaqhf
                        string sppidName = SPPIDUtill.GetSPPIDMappingName(SPPID.Model.Text.pipingCompSize, mapping);
516
                        if (!string.IsNullOrEmpty(sppidName))
517
                        {
518
                            itemNode.ForeColor = Color.Gray;
519
                        }
520
                        else
521
                        {
522
                            itemNode.ForeColor = Color.Red;
523
                            result = false;
524
                        }
525
                        sppidName = SPPIDUtill.GetSPPIDMappingName(SPPID.Model.Text.instrumentSize, mapping);
526
                        if (!string.IsNullOrEmpty(sppidName))
527
                        {
528
                            itemNode.ForeColor = Color.Gray;
529
                        }
530
                        else
531
                        {
532
                            itemNode.ForeColor = Color.Red;
533
                            result = false;
534
                        }
535 91502a9b gaqhf
                    }
536
                    else
537
                    {
538 f9d4b6aa gaqhf
                        string sppidName = SPPIDUtill.GetSPPIDMappingName(name, mapping);
539
                        if (!string.IsNullOrEmpty(sppidName))
540
                        {
541
                            itemNode.ForeColor = Color.Gray;
542
                        }
543
                        else
544
                        {
545
                            itemNode.ForeColor = Color.Red;
546
                            result = false;
547
                        }
548 91502a9b gaqhf
                    }
549
550 f9d4b6aa gaqhf
                    foreach (TreeNode attrNode in itemNode.Nodes)
551 91502a9b gaqhf
                    {
552 f9d4b6aa gaqhf
                        name = attrNode.Name;
553
                        string sppidName = SPPIDUtill.GetSPPIDMappingName(name, mapping);
554
                        if (!string.IsNullOrEmpty(sppidName))
555 91502a9b gaqhf
                        {
556
                            attrNode.ForeColor = Color.Gray;
557
                        }
558
                        else
559
                        {
560
                            attrNode.ForeColor = Color.Red;
561
                        }
562
                    }
563
                }
564 022cae08 gaqhf
565 91502a9b gaqhf
                if (result)
566
                {
567 f9d4b6aa gaqhf
                    docNode.ForeColor = Color.Black;
568 91502a9b gaqhf
                }
569
            }
570
        }
571 022cae08 gaqhf
572 91502a9b gaqhf
        private List<string> GetNeedMapping()
573
        {
574
            List<string> nameList = new List<string>();
575
            foreach (TreeNode dwgNode in treeViewDrawing.Nodes[0].Nodes)
576
            {
577
                foreach (TreeNode docNode in dwgNode.Nodes)
578
                {
579
                    string name = docNode.Name;
580 f9d4b6aa gaqhf
                    if (name == "SIZE")
581
                    {
582
                        string sppidName = SPPIDUtill.GetSPPIDMappingName(SPPID.Model.Text.pipingCompSize, mapping);
583
                        if (string.IsNullOrEmpty(sppidName) && !nameList.Contains(name))
584
                            nameList.Add(SPPID.Model.Text.pipingCompSize);
585
                        sppidName = SPPIDUtill.GetSPPIDMappingName(SPPID.Model.Text.instrumentSize, mapping);
586
                        if (string.IsNullOrEmpty(sppidName) && !nameList.Contains(name))
587
                            nameList.Add(SPPID.Model.Text.instrumentSize);
588
589
                    }
590
                    else
591
                    {
592
                        string sppidName = SPPIDUtill.GetSPPIDMappingName(name, mapping);
593
                        if (string.IsNullOrEmpty(sppidName) && !nameList.Contains(name))
594
                            nameList.Add(name);
595
                    }
596 91502a9b gaqhf
597
                    // Attribute
598
                    foreach (TreeNode attrNode in docNode.Nodes)
599
                    {
600
                        name = attrNode.Name;
601 f9d4b6aa gaqhf
                        string sppidName = SPPIDUtill.GetSPPIDMappingName(name, mapping);
602 91502a9b gaqhf
                        if (string.IsNullOrEmpty(sppidName) && !nameList.Contains(name))
603
                            nameList.Add(name);
604
                    }
605
                }
606
            }
607 022cae08 gaqhf
608 91502a9b gaqhf
            return nameList;
609 022cae08 gaqhf
        }
610
611 91502a9b gaqhf
        private void treeViewDrawing_AfterCheck(object sender, TreeViewEventArgs e)
612
        {
613
            treeViewDrawing.AfterCheck -= new TreeViewEventHandler(this.treeViewDrawing_AfterCheck);
614
615
            if (e.Node.Level == 0)
616
            {
617
                foreach (TreeNode node in e.Node.Nodes)
618
                    node.Checked = e.Node.Checked;
619
            }
620
            else if (e.Node.Level == 1)
621
            {
622
                bool result = false;
623
                foreach (TreeNode node in e.Node.Parent.Nodes)
624
                {
625
                    if (node.Checked)
626
                    {
627
                        result = true;
628
                        break;
629
                    }
630
                }
631
632
                if (result)
633
                    e.Node.Parent.Checked = true;
634
                else
635
                    e.Node.Parent.Checked = false;
636
            }
637 022cae08 gaqhf
638 91502a9b gaqhf
            treeViewDrawing.AfterCheck += new TreeViewEventHandler(this.treeViewDrawing_AfterCheck);
639
        }
640 022cae08 gaqhf
        #endregion
641
642 d57a5303 gaqhf
        #endregion
643 022cae08 gaqhf
644 91502a9b gaqhf
645 d57a5303 gaqhf
    }
646
}
클립보드 이미지 추가 (최대 크기: 500 MB)