프로젝트

일반

사용자정보

통계
| 개정판:

hytos / DTI_PID / SPPIDConverter_CustomCommand / SPPIDConverter.cs @ 943d9c39

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

1
/*---------------------------------------------------------------------+\
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
using System.ComponentModel;
23
using System.Windows.Forms;
24
using System.Collections.Generic;
25
using Ingr.RAD2D;
26
using System.Runtime.InteropServices;
27
using System.Drawing;
28
using SPPID.Modeling;
29
using SPPID.Utill;
30
using SPPID.Model;
31
using System.Threading;
32
using Microsoft.Win32;
33

    
34
namespace CustomCommand
35
{
36
    /// <summary>
37
    /// Used to create a modeless dialog form command to be used in  
38
    /// SmartSketch.
39
    /// </summary>
40
    public partial class SPPIDConverter : UserControl
41
    {
42
        /// Expose my Caption property
43
        /// </summary>
44
        public string Caption
45
        {
46
            get; set;
47
        }
48

    
49
        /// <summary>
50
        /// Expose my PreferredHeight property
51
        /// </summary>
52
        public int PreferredHeight
53
        {
54
            get; set;
55
        }
56

    
57
        /// <summary>
58
        /// Expose my PreferredWidth property
59
        /// </summary>
60
        public int PreferredWidth
61
        {
62
            get; set;
63
        }
64

    
65
        /// <summary>
66
        /// Expose my PreferredLeft property
67
        /// </summary>
68
        public int PreferredLeft
69
        {
70
            get; set;
71
        }
72

    
73
        /// <summary>
74
        /// Expose my PreferredTop property
75
        /// </summary>
76
        public int PreferredTop
77
        {
78
            get; set;
79
        }
80

    
81
        /// <summary>
82
        /// Expose a Dialog property letting the application know that this
83
        /// control should be shown as a dialog box.
84
        /// </summary>
85
        public bool Dialog
86
        {
87
            get; set;
88
        }
89

    
90
        /// <summary>
91
        /// Gets the description.
92
        /// </summary>
93
        /// <value>
94
        /// The description of the command as assigned in the resources file.
95
        /// </value>
96
        public string Description
97
        {
98
            get
99
            {
100
                return Properties.Resources.ResourceManager.GetString("Description", System.Globalization.CultureInfo.CurrentCulture);
101
            }
102
        }
103

    
104
        /// <summary>
105
        /// Gets the tooltip of the command.
106
        /// </summary>
107
        /// <value>
108
        /// The tooltip of the command as assigned in the resources file.
109
        /// </value>
110
        public string GetTooltip
111
        {
112
            get
113
            {
114
                return Properties.Resources.ResourceManager.GetString("Tooltip", System.Globalization.CultureInfo.CurrentCulture);
115
            }
116
        }
117

    
118
        /// <summary>
119
        /// Gets the toolbar image.
120
        /// </summary>
121
        /// <value>
122
        /// The toolbar image of the command as assigned in the resources file.
123
        /// </value>
124
        public System.Drawing.Image ToolbarImage
125
        {
126
            get
127
            {
128
                return (System.Drawing.Image)Properties.Resources.ResourceManager.GetObject("ToolbarImage", System.Globalization.CultureInfo.CurrentCulture);
129
            }
130
        }
131

    
132
        /// <summary>
133
        /// Initialize this control's member data.  Be sure to modify the
134
        /// preferred height and width if you change the size of the user
135
        /// control.
136
        /// </summary>
137
        public SPPIDConverter()
138
        {
139
            InitializeComponent();
140

    
141
            //My caption property value
142
            Caption = "SPPID Converter";
143

    
144
            //My preferred height value.
145
            PreferredHeight = this.Height;
146

    
147
            // My preferred width.
148
            PreferredWidth = this.Width + 15;
149

    
150
            // My preferred left and top positions.
151
            PreferredLeft = 100;
152
            PreferredTop = 100;
153

    
154
        }
155

    
156
        /// <summary>
157
        /// This function lets the Intergraph application communicate with
158
        /// the command.
159
        /// </summary>
160
        /// <param name="basicCommand">The basic command</param>
161
        public void Command_Initialize(object basicCommand)
162
        {
163
            commandControl.Command = basicCommand;
164
        }
165

    
166
        /// <summary>
167
        /// The Initialize event is where the command should perform 1 time
168
        /// initialization, for example it might save a reference to the
169
        /// active document in private global data.
170
        /// </summary>
171
        /// <param name="sender">The sender of the event</param>
172
        /// <param name="e">The event's arguments</param>
173
        private void commandControl_Initialize(object sender, EventArgs e)
174
        {
175
            /* Set mouseControl.WantsWrappers to True if you want the Mouse Control
176
             * to return your applications objects as opposed to RAD2D objects.
177
             * This is required if you are programming on a typelibrary other
178
             * than RAD2D.
179
             */
180
            mouseControl.WantsWrappers(false);
181

    
182
            try
183
            {
184
                RegistryKey key = Registry.LocalMachine;
185
                RegistryKey software = key.OpenSubKey("SOFTWARE");
186
                RegistryKey DOFTECH = software.OpenSubKey("DOFTECH");
187
                if (DOFTECH != null)
188
                {
189
                    RegistryKey ID2 = DOFTECH.OpenSubKey("ID2");
190
                    if (ID2 != null)
191
                    {
192
                        SPPIDUtill.defaultPath = ID2.GetValue("Path").ToString();
193

    
194
                        Log.logPath = SPPIDUtill.defaultPath + @"Converter\SPPID Converter.log";
195
                        SPPIDUtill.mappingFilePath = SPPIDUtill.defaultPath + @"Converter\mapping.xml";
196
                        string dllPath = SPPIDUtill.defaultPath + @"Converter\SPPIDConverter.dll";
197

    
198
                        SPPIDUtill.LoadMapping(symbolMapping, attributeMapping);
199
                        Ingr.RAD2D.Application application = commandControl.Application.RADApplication;
200

    
201
                        ToolBars toolBars = application.ToolBars;
202
                        bool find = true;
203
                        while (find)
204
                        {
205
                            find = false;
206
                            foreach (ToolbarControl item in toolBars["Main"].Controls)
207
                            {
208
                                if (item.DLLName.Contains("SPPIDConverter.dll"))
209
                                {
210
                                    item.Delete();
211
                                    find = true;
212
                                    break;
213
                                }
214
                            }
215
                        }
216

    
217
                        ToolbarControl toolBarControl = toolBars["Main"].Controls.AppendMacroCommand(dllPath);
218
                        toolBarControl.ToolTipText = GetTooltip;
219
                        toolBarControl.Picture = ToolbarImage;
220

    
221
                        Menus menu = application.Menus;
222
                        find = true;
223
                        while (find)
224
                        {
225
                            find = false;
226
                            foreach (MenuControl item in menu["&Tools"].Controls)
227
                            {
228
                                if (item.Caption == GetTooltip)
229
                                {
230
                                    item.Delete();
231
                                    find = true;
232
                                    break;
233
                                }
234
                            }
235
                        }
236
                        MenuControl menuControl = application.Menus["&Tools"].Controls.AppendMacroCommand(GetTooltip, dllPath);
237
                        menuControl.ToolTipText = GetTooltip;
238
                    }
239
                }
240
            }
241
            catch (Exception ex)
242
            {
243
                Log.WriteLine(ex);
244
            }
245
        }
246

    
247
        /// <summary>
248
        /// The Terminate event is where the command can clean up any command
249
        /// specific allocated resources. 
250
        /// </summary>
251
        /// <param name="sender">The sender of the event</param>
252
        /// <param name="e">The event's arguments</param>
253
        public void commandControl_Terminate(object sender, EventArgs e)
254
        {
255
            //Ingr.RAD2D.Application application = commandControl.Application.RADApplication;
256
            //string dllPath = SPPIDUtill.defaultPath + @"Converter\SPPIDConverter.dll";
257
            //application.RunMacro(dllPath);
258
        }
259

    
260

    
261
        #region ?? CustomCommand Source ????
262

    
263
        private Dictionary<string, string> symbolMapping = new Dictionary<string, string>();
264
        private Dictionary<string, string> attributeMapping = new Dictionary<string, string>();
265
        Thread autoModelingThread;
266

    
267
        #region Botton Event
268
        private void openDocumentsToolStripMenuItem_Click(object sender, EventArgs e)
269
        {
270
            OpenFileDialog dia = new OpenFileDialog();
271
            dia.Multiselect = true;
272
            dia.Filter = "Xml Files(*.xml)|*.xml";
273
            if (dia.ShowDialog() == DialogResult.OK)
274
            {
275
                SPPIDUtill.LoadMapping(symbolMapping, attributeMapping);
276
                foreach (string fileName in dia.FileNames)
277
                    SetDrawingTreeNode(fileName);
278
                treeViewDrawing.Nodes[0].Expand();
279
                RefreshItemNode();
280
            }
281
        }
282

    
283
        private void itemMappingToolStripMenuItem_Click(object sender, EventArgs e)
284
        {
285
            List<string> needSymbolName = GetNeedSymbolMapping();
286
            List<string> needAttributeName = GetNeedAttributeMapping();
287
            MappingForm form = new MappingForm(symbolMapping, attributeMapping, needSymbolName, needAttributeName);
288
            if (form.ShowDialog() == DialogResult.OK)
289
            {
290
                SPPIDUtill.SaveMapping(symbolMapping, attributeMapping);
291
                RefreshItemNode();
292
            }
293
        }
294

    
295
        private void importToolStripMenuItem_Click(object sender, EventArgs e)
296
        {
297
            OpenFileDialog dia = new OpenFileDialog();
298
            dia.Multiselect = false;
299
            dia.Filter = "Excel File(*.xlsx;*.xls)|*.xlsx;*.xls";
300
            if (dia.ShowDialog() == DialogResult.OK)
301
            {
302
                ExcelUtill.LoadMappingExcelFile(dia.FileName, symbolMapping);
303
                try
304
                {
305
                    SPPIDUtill.SaveMapping(symbolMapping, attributeMapping);
306
                    RefreshItemNode();
307
                    MessageBox.Show("Success Load Excel File");
308
                }
309
                catch (Exception ex)
310
                {
311
                    Log.WriteLine(ex);
312
                    MessageBox.Show("Fail Save Mapping File");
313
                }
314
            }
315
        }
316

    
317
        private void convertToolStripMenuItem_Click(object sender, EventArgs e)
318
        {
319
            try
320
            {
321
                SPPIDUtill.LoadMapping(symbolMapping, attributeMapping);
322

    
323
                List<SPPID.Model.Document> documents = new List<SPPID.Model.Document>();
324
                foreach (TreeNode node in treeViewDrawing.Nodes[0].Nodes)
325
                {
326
                    if (node.Checked)
327
                    {
328
                        SPPID.Model.Document document = node.Tag as SPPID.Model.Document;
329
                        if (document != null && document.Init())
330
                            documents.Add(document);
331
                        else
332
                            Log.WriteLine("Fail Init");
333
                    }
334
                }
335

    
336
                autoModelingThread = new Thread(Func =>
337
                {
338
                    try
339
                    {
340
                        foreach (SPPID.Model.Document document in documents)
341
                        {
342

    
343
                            AutoModeling auto = new AutoModeling(document);
344
                            auto.SetListBoxLog(listBoxLog);
345
                            auto.SetProgressBar(toolStripProgressBar);
346
                            auto.Run();
347
                        }
348
                    }
349
                    catch (Exception ex)
350
                    {
351
                        Log.WriteLine(ex);
352
                    }
353
                });
354
                autoModelingThread.Start();
355
            }
356
            catch (Exception ex)
357
            {
358
                Log.WriteLine(ex);
359
            }
360
        }
361

    
362
        private void stopToolStripMenuItem_Click(object sender, EventArgs e)
363
        {
364
            try
365
            {
366
                if (autoModelingThread != null)
367
                    autoModelingThread.Abort();
368
            }
369
            catch (Exception ex)
370
            {
371
                Log.WriteLine(ex);
372
            }
373
        }
374
        #endregion
375

    
376
        //private void listBoxLog_DrawItem(object sender, DrawItemEventArgs e)
377
        //{
378
        //    if (e.Index >= 0)
379
        //    {
380
        //        ListBoxItem item = listBoxLog.Items[e.Index] as ListBoxItem;
381
        //        if (item != null)
382
        //        {
383
        //            e.Graphics.DrawString(item.Message,
384
        //                listBoxLog.Font,
385
        //                new SolidBrush(item.Color),
386
        //                0,
387
        //                e.Index * listBoxLog.ItemHeight);
388
        //        }
389
        //    }
390
        //}
391

    
392
        #region TreeNode
393

    
394
        #region Hide TreeNode CheckBox
395
        private const int TVIF_STATE = 0x8;
396
        private const int TVIS_STATEIMAGEMASK = 0xF000;
397
        private const int TV_FIRST = 0x1100;
398
        private const int TVM_SETITEM = TV_FIRST + 63;
399

    
400
        [StructLayout(LayoutKind.Sequential, Pack = 8, CharSet = CharSet.Auto)]
401
        private struct TVITEM
402
        {
403
            public int mask;
404
            public IntPtr hItem;
405
            public int state;
406
            public int stateMask;
407
            [MarshalAs(UnmanagedType.LPTStr)]
408
            public string lpszText;
409
            public int cchTextMax;
410
            public int iImage;
411
            public int iSelectedImage;
412
            public int cChildren;
413
            public IntPtr lParam;
414
        }
415

    
416
        [DllImport("user32.dll", CharSet = CharSet.Auto)]
417
        private static extern IntPtr SendMessage(IntPtr hWnd, int Msg, IntPtr wParam,
418
                                                 ref TVITEM lParam);
419

    
420
        /// <summary>
421
        /// Hides the checkbox for the specified node on a TreeView control.
422
        /// </summary>
423
        private void HideCheckBox(TreeView tvw, TreeNode node)
424
        {
425
            TVITEM tvi = new TVITEM();
426
            tvi.hItem = node.Handle;
427
            tvi.mask = TVIF_STATE;
428
            tvi.stateMask = TVIS_STATEIMAGEMASK;
429
            tvi.state = 0;
430
            SendMessage(tvw.Handle, TVM_SETITEM, IntPtr.Zero, ref tvi);
431
        }
432
        #endregion
433

    
434
        private void SetDrawingTreeNode(string fileName)
435
        {
436
            SPPID.Model.Document document = SPPID.Model.Document.Load(fileName, symbolMapping, attributeMapping);
437

    
438
            TreeNode drawingNode = new TreeNode();
439
            if (document == null)
440
            {
441
                drawingNode.Text = fileName;
442
                drawingNode.Name = fileName;
443
                drawingNode.ForeColor = Color.Red;
444
                treeViewDrawing.Nodes[0].Nodes.Add(drawingNode);
445
            }
446
            else
447
            {
448
                foreach (TreeNode treeNode in treeViewDrawing.Nodes[0].Nodes)
449
                {
450
                    if (treeNode.Text == document.DWGNAME)
451
                    {
452
                        treeViewDrawing.Nodes[0].Nodes.Remove(treeNode);
453
                        break;
454
                    }
455
                }
456

    
457
                drawingNode.Text = document.DWGNAME;
458
                drawingNode.Name = document.DWGNAME;
459
                drawingNode.Tag = document;
460
                treeViewDrawing.Nodes[0].Nodes.Add(drawingNode);
461
            }
462

    
463
            SetItemTreeNode(drawingNode);
464
        }
465

    
466
        private void SetItemTreeNode(TreeNode drawingNode)
467
        {
468
            SPPID.Model.Document document = drawingNode.Tag as SPPID.Model.Document;
469
            if (document != null)
470
            {
471
                foreach (LineNumber item in document.LINENUMBERS)
472
                {
473
                    TreeNode node = new TreeNode();
474
                    node.Name = LineNumber.LineNumberSymbolPath;
475
                    node.Text = item.TEXT;
476
                    node.Tag = item;
477
                    drawingNode.Nodes.Add(node);
478
                    HideCheckBox(treeViewDrawing, node);
479
                    foreach (ItemAttribute attribute in item.ATTRIBUTES)
480
                    {
481
                        TreeNode attrNode = new TreeNode();
482
                        attrNode.Name = attribute.Attribute;
483
                        attrNode.Text = attribute.Attribute;
484
                        attrNode.Tag = attribute;
485
                        node.Nodes.Add(attrNode);
486
                        HideCheckBox(treeViewDrawing, attrNode);
487
                    }
488
                }
489

    
490
                foreach (Symbol item in document.SYMBOLS)
491
                {
492
                    TreeNode node = new TreeNode();
493
                    node.Name = item.PARENT;
494
                    node.Text = item.NAME;
495
                    node.Tag = item;
496
                    drawingNode.Nodes.Add(node);
497
                    HideCheckBox(treeViewDrawing, node);
498
                    foreach (ItemAttribute attribute in item.ATTRIBUTES)
499
                    {
500
                        TreeNode attrNode = new TreeNode();
501
                        attrNode.Name = attribute.Attribute;
502
                        attrNode.Text = attribute.Attribute;
503
                        attrNode.Tag = attribute;
504
                        node.Nodes.Add(attrNode);
505
                        HideCheckBox(treeViewDrawing, attrNode);
506
                    }
507

    
508
                    foreach (SymbolChild child in item.CHILD_LIST)
509
                    {
510
                        TreeNode attrNode = new TreeNode();
511
                        attrNode.Name = child.Name;
512
                        attrNode.Text = child.Name;
513
                        attrNode.Tag = child;
514
                        node.Nodes.Add(attrNode);
515
                        HideCheckBox(treeViewDrawing, attrNode);
516
                    }
517
                }
518

    
519
                foreach (Line item in document.LINES)
520
                {
521
                    TreeNode node = new TreeNode();
522
                    node.Name = item.TYPE;
523
                    node.Text = item.TYPE;
524
                    node.Tag = item;
525
                    drawingNode.Nodes.Add(node);
526
                    HideCheckBox(treeViewDrawing, node);
527
                    foreach (ItemAttribute attribute in item.ATTRIBUTES)
528
                    {
529
                        TreeNode attrNode = new TreeNode();
530
                        attrNode.Name = attribute.Attribute;
531
                        attrNode.Text = attribute.Attribute;
532
                        attrNode.Tag = attribute;
533
                        node.Nodes.Add(attrNode);
534
                        HideCheckBox(treeViewDrawing, attrNode);
535
                    }
536
                }
537
                
538
                foreach (SpecBreak item in document.SPECBREAK)
539
                {
540
                    foreach (ItemAttribute attribute in item.ATTRIBUTES)
541
                    {
542
                        TreeNode node = new TreeNode();
543
                        node.Name = attribute.Attribute;
544
                        node.Text = attribute.Attribute;
545
                        node.Tag = item;
546
                        drawingNode.Nodes.Add(node);
547
                        HideCheckBox(treeViewDrawing, node);
548

    
549
                        TreeNode attrNode = new TreeNode();
550
                        attrNode.Name = attribute.Attribute;
551
                        attrNode.Text = attribute.Attribute;
552
                        attrNode.Tag = attribute;
553
                        node.Nodes.Add(attrNode);
554
                        HideCheckBox(treeViewDrawing, attrNode);
555
                    }
556
                }
557

    
558
                foreach (Text item in document.TEXTS)
559
                {
560
                    TreeNode node = new TreeNode();
561
                    node.Name = item.NAME;
562
                    node.Text = item.NAME;
563
                    node.Tag = item;
564
                    drawingNode.Nodes.Add(node);
565
                    HideCheckBox(treeViewDrawing, node);
566
                    foreach (ItemAttribute attribute in item.ATTRIBUTES)
567
                    {
568
                        TreeNode attrNode = new TreeNode();
569
                        attrNode.Name = attribute.Attribute;
570
                        attrNode.Text = attribute.Attribute;
571
                        attrNode.Tag = attribute;
572
                        node.Nodes.Add(attrNode);
573
                        HideCheckBox(treeViewDrawing, attrNode);
574
                    }
575
                }
576
            }
577
        }
578

    
579
        private void RefreshItemNode()
580
        {
581
            foreach (TreeNode docNode in treeViewDrawing.Nodes[0].Nodes)
582
            {
583
                docNode.ForeColor = Color.Red;
584
                bool result = true;
585
                foreach (TreeNode itemNode in docNode.Nodes)
586
                {
587
                    string name = itemNode.Name;
588
                    if (name == "SIZE")
589
                    {
590
                        string sppidName = SPPIDUtill.GetSPPIDSymbolMappingName(SPPID.Model.Text.pipingCompSize, symbolMapping);
591
                        if (!string.IsNullOrEmpty(sppidName))
592
                        {
593
                            itemNode.ForeColor = Color.Gray;
594
                        }
595
                        else
596
                        {
597
                            itemNode.ForeColor = Color.Red;
598
                            result = false;
599
                        }
600
                        sppidName = SPPIDUtill.GetSPPIDSymbolMappingName(SPPID.Model.Text.instrumentSize, symbolMapping);
601
                        if (!string.IsNullOrEmpty(sppidName))
602
                        {
603
                            itemNode.ForeColor = Color.Gray;
604
                        }
605
                        else
606
                        {
607
                            itemNode.ForeColor = Color.Red;
608
                            result = false;
609
                        }
610
                    }
611
                    else
612
                    {
613
                        string sppidName = SPPIDUtill.GetSPPIDSymbolMappingName(name, symbolMapping);
614
                        if (!string.IsNullOrEmpty(sppidName))
615
                        {
616
                            itemNode.ForeColor = Color.Gray;
617
                        }
618
                        else
619
                        {
620
                            itemNode.ForeColor = Color.Red;
621
                            result = false;
622
                        }
623
                    }
624

    
625
                    foreach (TreeNode childNode in itemNode.Nodes)
626
                    {
627
                        name = childNode.Name;
628
                        string sppidName = "";
629
                        if (childNode.Tag.GetType() == typeof(ItemAttribute))
630
                            sppidName = SPPIDUtill.GetSPPIDAttributeMappingName(name, attributeMapping);
631
                        else
632
                            sppidName = SPPIDUtill.GetSPPIDSymbolMappingName(name, symbolMapping);
633
                        
634
                        if (!string.IsNullOrEmpty(sppidName))
635
                        {
636
                            childNode.ForeColor = Color.Gray;
637
                        }
638
                        else
639
                        {
640
                            childNode.ForeColor = Color.Red;
641
                            if (typeof(SymbolChild) == childNode.Tag.GetType())
642
                                childNode.Parent.ForeColor = Color.Red;
643
                        }
644
                    }
645
                }
646

    
647
                if (result)
648
                {
649
                    docNode.ForeColor = Color.Black;
650
                }
651
            }
652
        }
653

    
654
        private List<string> GetNeedSymbolMapping()
655
        {
656
            List<string> nameList = new List<string>();
657
            foreach (TreeNode dwgNode in treeViewDrawing.Nodes[0].Nodes)
658
            {
659
                foreach (TreeNode docNode in dwgNode.Nodes)
660
                {
661
                    string name = docNode.Name;
662
                    if (name == "SIZE")
663
                    {
664
                        string sppidName = SPPIDUtill.GetSPPIDSymbolMappingName(SPPID.Model.Text.pipingCompSize, symbolMapping);
665
                        if (string.IsNullOrEmpty(sppidName) && !nameList.Contains(SPPID.Model.Text.pipingCompSize))
666
                            nameList.Add(SPPID.Model.Text.pipingCompSize);
667
                        sppidName = SPPIDUtill.GetSPPIDSymbolMappingName(SPPID.Model.Text.instrumentSize, symbolMapping);
668
                        if (string.IsNullOrEmpty(sppidName) && !nameList.Contains(SPPID.Model.Text.instrumentSize))
669
                            nameList.Add(SPPID.Model.Text.instrumentSize);
670

    
671
                    }
672
                    else
673
                    {
674
                        string sppidName = SPPIDUtill.GetSPPIDSymbolMappingName(name, symbolMapping);
675
                        if (string.IsNullOrEmpty(sppidName) && !nameList.Contains(name))
676
                            nameList.Add(name);
677
                    }
678

    
679

    
680
                    foreach (TreeNode childNode in docNode.Nodes)
681
                    {
682
                        name = childNode.Name;
683
                        if (childNode.Tag.GetType() == typeof(SymbolChild))
684
                        {
685
                            string sppidName = SPPIDUtill.GetSPPIDSymbolMappingName(name, symbolMapping);
686
                            if (string.IsNullOrEmpty(sppidName) && !nameList.Contains(name))
687
                                nameList.Add(name);
688
                        }
689
                    }
690
                }
691
            }
692

    
693
            return nameList;
694
        }
695

    
696
        private List<string> GetNeedAttributeMapping()
697
        {
698
            List<string> nameList = new List<string>();
699
            foreach (TreeNode dwgNode in treeViewDrawing.Nodes[0].Nodes)
700
            {
701
                foreach (TreeNode docNode in dwgNode.Nodes)
702
                {
703
                    foreach (TreeNode childNode in docNode.Nodes)
704
                    {
705
                        string name = childNode.Name;
706
                        if (childNode.Tag.GetType() == typeof(ItemAttribute))
707
                        {
708
                            string sppidName = SPPIDUtill.GetSPPIDAttributeMappingName(name, attributeMapping);
709
                            if (string.IsNullOrEmpty(sppidName) && !nameList.Contains(name))
710
                                nameList.Add(name);
711
                        }
712
                    }
713
                }
714
            }
715

    
716
            return nameList;
717
        }
718

    
719
        private void treeViewDrawing_AfterCheck(object sender, TreeViewEventArgs e)
720
        {
721
            treeViewDrawing.AfterCheck -= new TreeViewEventHandler(this.treeViewDrawing_AfterCheck);
722

    
723
            if (e.Node.Level == 0)
724
            {
725
                foreach (TreeNode node in e.Node.Nodes)
726
                    node.Checked = e.Node.Checked;
727
            }
728
            else if (e.Node.Level == 1)
729
            {
730
                bool result = false;
731
                foreach (TreeNode node in e.Node.Parent.Nodes)
732
                {
733
                    if (node.Checked)
734
                    {
735
                        result = true;
736
                        break;
737
                    }
738
                }
739

    
740
                if (result)
741
                    e.Node.Parent.Checked = true;
742
                else
743
                    e.Node.Parent.Checked = false;
744
            }
745

    
746
            treeViewDrawing.AfterCheck += new TreeViewEventHandler(this.treeViewDrawing_AfterCheck);
747
        }
748

    
749
        private void exitToolStripMenuItem_Click(object sender, EventArgs e)
750
        {
751
            commandControl.Application.RADApplication.Interactive = true;
752
            Hide();
753
            commandControl.Done = true;
754
        }
755

    
756
        #endregion
757

    
758
        #endregion
759

    
760

    
761
    }
762
}
클립보드 이미지 추가 (최대 크기: 500 MB)