프로젝트

일반

사용자정보

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

hytos / DTI_PID / SPPIDConverter_CustomCommand / SPPIDConverter.cs @ 522be0fa

이력 | 보기 | 이력해설 | 다운로드 (29.1 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 8c37691c gaqhf
using System.ComponentModel;
23 d57a5303 gaqhf
using System.Windows.Forms;
24 8c37691c gaqhf
using System.Collections.Generic;
25 d57a5303 gaqhf
using Ingr.RAD2D;
26 022cae08 gaqhf
using System.Runtime.InteropServices;
27
using System.Drawing;
28 d57a5303 gaqhf
using SPPID.Modeling;
29
using SPPID.Utill;
30
using SPPID.Model;
31 91502a9b gaqhf
using System.Threading;
32 4582b1d2 gaqhf
using Microsoft.Win32;
33 522be0fa gaqhf
using Microsoft.VisualBasic;
34 d57a5303 gaqhf
35
namespace CustomCommand
36
{
37
    /// <summary>
38 8c37691c gaqhf
    /// Used to create a modeless dialog form command to be used in  
39
    /// SmartSketch.
40 d57a5303 gaqhf
    /// </summary>
41 8c37691c gaqhf
    public partial class SPPIDConverter : UserControl
42 d57a5303 gaqhf
    {
43 8c37691c gaqhf
        /// Expose my Caption property
44
        /// </summary>
45
        public string Caption
46
        {
47
            get; set;
48
        }
49
50 d57a5303 gaqhf
        /// <summary>
51 8c37691c gaqhf
        /// Expose my PreferredHeight property
52 d57a5303 gaqhf
        /// </summary>
53 8c37691c gaqhf
        public int PreferredHeight
54 d57a5303 gaqhf
        {
55 8c37691c gaqhf
            get; set;
56 d57a5303 gaqhf
        }
57 8c37691c gaqhf
58 d57a5303 gaqhf
        /// <summary>
59 8c37691c gaqhf
        /// Expose my PreferredWidth property
60 d57a5303 gaqhf
        /// </summary>
61 8c37691c gaqhf
        public int PreferredWidth
62
        {
63
            get; set;
64
        }
65 d57a5303 gaqhf
66
        /// <summary>
67 8c37691c gaqhf
        /// Expose my PreferredLeft property
68 d57a5303 gaqhf
        /// </summary>
69 8c37691c gaqhf
        public int PreferredLeft
70 d57a5303 gaqhf
        {
71 8c37691c gaqhf
            get; set;
72 d57a5303 gaqhf
        }
73
74
        /// <summary>
75 8c37691c gaqhf
        /// Expose my PreferredTop property
76 d57a5303 gaqhf
        /// </summary>
77 8c37691c gaqhf
        public int PreferredTop
78 d57a5303 gaqhf
        {
79 8c37691c gaqhf
            get; set;
80
        }
81
82
        /// <summary>
83
        /// Expose a Dialog property letting the application know that this
84
        /// control should be shown as a dialog box.
85
        /// </summary>
86
        public bool Dialog
87
        {
88
            get; set;
89
        }
90
91
        /// <summary>
92
        /// Gets the description.
93
        /// </summary>
94
        /// <value>
95
        /// The description of the command as assigned in the resources file.
96
        /// </value>
97
        public string Description
98
        {
99
            get
100
            {
101
                return Properties.Resources.ResourceManager.GetString("Description", System.Globalization.CultureInfo.CurrentCulture);
102
            }
103
        }
104
105
        /// <summary>
106
        /// Gets the tooltip of the command.
107
        /// </summary>
108
        /// <value>
109
        /// The tooltip of the command as assigned in the resources file.
110
        /// </value>
111
        public string GetTooltip
112
        {
113
            get
114
            {
115
                return Properties.Resources.ResourceManager.GetString("Tooltip", System.Globalization.CultureInfo.CurrentCulture);
116
            }
117 d57a5303 gaqhf
        }
118
119
        /// <summary>
120 8c37691c gaqhf
        /// Gets the toolbar image.
121
        /// </summary>
122
        /// <value>
123
        /// The toolbar image of the command as assigned in the resources file.
124
        /// </value>
125
        public System.Drawing.Image ToolbarImage
126
        {
127
            get
128
            {
129 cfbb1be0 gaqhf
                return (System.Drawing.Image)Properties.Resources.ResourceManager.GetObject("ToolbarImage", System.Globalization.CultureInfo.CurrentCulture);
130 8c37691c gaqhf
            }
131
        }
132
133
        /// <summary>
134
        /// Initialize this control's member data.  Be sure to modify the
135
        /// preferred height and width if you change the size of the user
136
        /// control.
137
        /// </summary>
138
        public SPPIDConverter()
139
        {
140
            InitializeComponent();
141
142
            //My caption property value
143
            Caption = "SPPID Converter";
144
145
            //My preferred height value.
146
            PreferredHeight = this.Height;
147
148
            // My preferred width.
149
            PreferredWidth = this.Width + 15;
150
151
            // My preferred left and top positions.
152
            PreferredLeft = 100;
153
            PreferredTop = 100;
154
155
        }
156
157
        /// <summary>
158
        /// This function lets the Intergraph application communicate with
159
        /// the command.
160
        /// </summary>
161
        /// <param name="basicCommand">The basic command</param>
162
        public void Command_Initialize(object basicCommand)
163
        {
164
            commandControl.Command = basicCommand;
165
        }
166
167
        /// <summary>
168
        /// The Initialize event is where the command should perform 1 time
169
        /// initialization, for example it might save a reference to the
170 d57a5303 gaqhf
        /// active document in private global data.
171
        /// </summary>
172
        /// <param name="sender">The sender of the event</param>
173 8c37691c gaqhf
        /// <param name="e">The event's arguments</param>
174 d57a5303 gaqhf
        private void commandControl_Initialize(object sender, EventArgs e)
175
        {
176 8c37691c gaqhf
            /* Set mouseControl.WantsWrappers to True if you want the Mouse Control
177
             * to return your applications objects as opposed to RAD2D objects.
178
             * This is required if you are programming on a typelibrary other
179
             * than RAD2D.
180
             */
181
            mouseControl.WantsWrappers(false);
182
183 91502a9b gaqhf
            try
184
            {
185 4582b1d2 gaqhf
                RegistryKey key = Registry.LocalMachine;
186
                RegistryKey software = key.OpenSubKey("SOFTWARE");
187
                RegistryKey DOFTECH = software.OpenSubKey("DOFTECH");
188
                if (DOFTECH != null)
189 91502a9b gaqhf
                {
190 4582b1d2 gaqhf
                    RegistryKey ID2 = DOFTECH.OpenSubKey("ID2");
191
                    if (ID2 != null)
192 91502a9b gaqhf
                    {
193 4582b1d2 gaqhf
                        SPPIDUtill.defaultPath = ID2.GetValue("Path").ToString();
194
195
                        Log.logPath = SPPIDUtill.defaultPath + @"Converter\SPPID Converter.log";
196
                        SPPIDUtill.mappingFilePath = SPPIDUtill.defaultPath + @"Converter\mapping.xml";
197 8c37691c gaqhf
                        string dllPath = SPPIDUtill.defaultPath + @"Converter\SPPIDConverter.dll";
198 4582b1d2 gaqhf
199 8c37691c gaqhf
                        SPPIDUtill.LoadMapping(symbolMapping, attributeMapping);
200 4582b1d2 gaqhf
                        Ingr.RAD2D.Application application = commandControl.Application.RADApplication;
201
202
                        ToolBars toolBars = application.ToolBars;
203
                        bool find = true;
204
                        while (find)
205 91502a9b gaqhf
                        {
206 4582b1d2 gaqhf
                            find = false;
207
                            foreach (ToolbarControl item in toolBars["Main"].Controls)
208
                            {
209 8c37691c gaqhf
                                if (item.DLLName.Contains("SPPIDConverter.dll"))
210 4582b1d2 gaqhf
                                {
211
                                    item.Delete();
212
                                    find = true;
213
                                    break;
214
                                }
215
                            }
216 91502a9b gaqhf
                        }
217
218 4582b1d2 gaqhf
                        ToolbarControl toolBarControl = toolBars["Main"].Controls.AppendMacroCommand(dllPath);
219 cfbb1be0 gaqhf
                        toolBarControl.ToolTipText = GetTooltip;
220
                        toolBarControl.Picture = ToolbarImage;
221 91502a9b gaqhf
222 4582b1d2 gaqhf
                        Menus menu = application.Menus;
223
                        find = true;
224
                        while (find)
225 91502a9b gaqhf
                        {
226 4582b1d2 gaqhf
                            find = false;
227
                            foreach (MenuControl item in menu["&Tools"].Controls)
228
                            {
229 cfbb1be0 gaqhf
                                if (item.Caption == GetTooltip)
230 4582b1d2 gaqhf
                                {
231
                                    item.Delete();
232
                                    find = true;
233
                                    break;
234
                                }
235
                            }
236 91502a9b gaqhf
                        }
237 cfbb1be0 gaqhf
                        MenuControl menuControl = application.Menus["&Tools"].Controls.AppendMacroCommand(GetTooltip, dllPath);
238
                        menuControl.ToolTipText = GetTooltip;
239 91502a9b gaqhf
                    }
240
                }
241
            }
242
            catch (Exception ex)
243
            {
244
                Log.WriteLine(ex);
245
            }
246 d57a5303 gaqhf
        }
247
248
        /// <summary>
249
        /// The Terminate event is where the command can clean up any command
250 8c37691c gaqhf
        /// specific allocated resources. 
251 d57a5303 gaqhf
        /// </summary>
252
        /// <param name="sender">The sender of the event</param>
253 8c37691c gaqhf
        /// <param name="e">The event's arguments</param>
254 d57a5303 gaqhf
        public void commandControl_Terminate(object sender, EventArgs e)
255
        {
256 8c37691c gaqhf
            //Ingr.RAD2D.Application application = commandControl.Application.RADApplication;
257
            //string dllPath = SPPIDUtill.defaultPath + @"Converter\SPPIDConverter.dll";
258
            //application.RunMacro(dllPath);
259 d57a5303 gaqhf
        }
260
261 022cae08 gaqhf
262
        #region ?? CustomCommand Source ????
263
264 8c37691c gaqhf
        private Dictionary<string, string> symbolMapping = new Dictionary<string, string>();
265
        private Dictionary<string, string> attributeMapping = new Dictionary<string, string>();
266 91502a9b gaqhf
        Thread autoModelingThread;
267
268
        #region Botton Event
269 022cae08 gaqhf
        private void openDocumentsToolStripMenuItem_Click(object sender, EventArgs e)
270
        {
271
            OpenFileDialog dia = new OpenFileDialog();
272
            dia.Multiselect = true;
273 91502a9b gaqhf
            dia.Filter = "Xml Files(*.xml)|*.xml";
274 022cae08 gaqhf
            if (dia.ShowDialog() == DialogResult.OK)
275
            {
276 8c37691c gaqhf
                SPPIDUtill.LoadMapping(symbolMapping, attributeMapping);
277 022cae08 gaqhf
                foreach (string fileName in dia.FileNames)
278
                    SetDrawingTreeNode(fileName);
279
                treeViewDrawing.Nodes[0].Expand();
280 91502a9b gaqhf
                RefreshItemNode();
281 022cae08 gaqhf
            }
282
        }
283
284
        private void itemMappingToolStripMenuItem_Click(object sender, EventArgs e)
285
        {
286 8c37691c gaqhf
            List<string> needSymbolName = GetNeedSymbolMapping();
287
            List<string> needAttributeName = GetNeedAttributeMapping();
288
            MappingForm form = new MappingForm(symbolMapping, attributeMapping, needSymbolName, needAttributeName);
289 91502a9b gaqhf
            if (form.ShowDialog() == DialogResult.OK)
290
            {
291 8c37691c gaqhf
                SPPIDUtill.SaveMapping(symbolMapping, attributeMapping);
292 91502a9b gaqhf
                RefreshItemNode();
293
            }
294 022cae08 gaqhf
        }
295
296
        private void importToolStripMenuItem_Click(object sender, EventArgs e)
297
        {
298 91502a9b gaqhf
            OpenFileDialog dia = new OpenFileDialog();
299
            dia.Multiselect = false;
300
            dia.Filter = "Excel File(*.xlsx;*.xls)|*.xlsx;*.xls";
301
            if (dia.ShowDialog() == DialogResult.OK)
302
            {
303 8c37691c gaqhf
                ExcelUtill.LoadMappingExcelFile(dia.FileName, symbolMapping);
304 91502a9b gaqhf
                try
305
                {
306 8c37691c gaqhf
                    SPPIDUtill.SaveMapping(symbolMapping, attributeMapping);
307 91502a9b gaqhf
                    RefreshItemNode();
308
                    MessageBox.Show("Success Load Excel File");
309
                }
310
                catch (Exception ex)
311
                {
312
                    Log.WriteLine(ex);
313
                    MessageBox.Show("Fail Save Mapping File");
314
                }
315
            }
316 022cae08 gaqhf
        }
317 91502a9b gaqhf
318 022cae08 gaqhf
        private void convertToolStripMenuItem_Click(object sender, EventArgs e)
319
        {
320 8c37691c gaqhf
            try
321 91502a9b gaqhf
            {
322 522be0fa gaqhf
                Thread thread = new Thread(func => {
323
                    for (int i = 0; i < 3; i++)
324 8c37691c gaqhf
                    {
325 522be0fa gaqhf
                        dynamic application = Interaction.GetObject("", "PIDAutomation.Application");
326
                        dynamic newDrawing = application.Drawings.Add("Unit1", "D-size.pid", "TEST001" + i, "TEST001" + i);
327
                        Thread.Sleep(5000);
328 8c37691c gaqhf
                    }
329
                });
330 522be0fa gaqhf
                thread.Start();
331
                
332
333
                //SPPIDUtill.LoadMapping(symbolMapping, attributeMapping);
334
335
                //List<SPPID.Model.Document> documents = new List<SPPID.Model.Document>();
336
                //foreach (TreeNode node in treeViewDrawing.Nodes[0].Nodes)
337
                //{
338
                //    if (node.Checked)
339
                //    {
340
                //        SPPID.Model.Document document = node.Tag as SPPID.Model.Document;
341
                //        if (document != null && document.Init())
342
                //            documents.Add(document);
343
                //        else
344
                //            Log.WriteLine("Fail Init");
345
                //    }
346
                //}
347
348
                //autoModelingThread = new Thread(Func =>
349
                //{
350
                //    try
351
                //    {
352
                //        foreach (SPPID.Model.Document document in documents)
353
                //        {
354
355
                //            AutoModeling auto = new AutoModeling(document);
356
                //            auto.SetListBoxLog(listBoxLog);
357
                //            auto.SetProgressBar(toolStripProgressBar);
358
                //            auto.Run();
359
                //        }
360
                //    }
361
                //    catch (Exception ex)
362
                //    {
363
                //        Log.WriteLine(ex);
364
                //    }
365
                //});
366
                //autoModelingThread.Start();
367 8c37691c gaqhf
            }
368
            catch (Exception ex)
369
            {
370
                Log.WriteLine(ex);
371
            }
372 022cae08 gaqhf
        }
373
374
        private void stopToolStripMenuItem_Click(object sender, EventArgs e)
375
        {
376 91502a9b gaqhf
            try
377
            {
378
                if (autoModelingThread != null)
379
                    autoModelingThread.Abort();
380
            }
381
            catch (Exception ex)
382
            {
383
                Log.WriteLine(ex);
384
            }
385
        }
386
        #endregion
387 022cae08 gaqhf
388 8c37691c gaqhf
        //private void listBoxLog_DrawItem(object sender, DrawItemEventArgs e)
389
        //{
390
        //    if (e.Index >= 0)
391
        //    {
392
        //        ListBoxItem item = listBoxLog.Items[e.Index] as ListBoxItem;
393
        //        if (item != null)
394
        //        {
395
        //            e.Graphics.DrawString(item.Message,
396
        //                listBoxLog.Font,
397
        //                new SolidBrush(item.Color),
398
        //                0,
399
        //                e.Index * listBoxLog.ItemHeight);
400
        //        }
401
        //    }
402
        //}
403 022cae08 gaqhf
404
        #region TreeNode
405 91502a9b gaqhf
406 022cae08 gaqhf
        #region Hide TreeNode CheckBox
407
        private const int TVIF_STATE = 0x8;
408
        private const int TVIS_STATEIMAGEMASK = 0xF000;
409
        private const int TV_FIRST = 0x1100;
410
        private const int TVM_SETITEM = TV_FIRST + 63;
411
412
        [StructLayout(LayoutKind.Sequential, Pack = 8, CharSet = CharSet.Auto)]
413
        private struct TVITEM
414
        {
415
            public int mask;
416
            public IntPtr hItem;
417
            public int state;
418
            public int stateMask;
419
            [MarshalAs(UnmanagedType.LPTStr)]
420
            public string lpszText;
421
            public int cchTextMax;
422
            public int iImage;
423
            public int iSelectedImage;
424
            public int cChildren;
425
            public IntPtr lParam;
426
        }
427
428
        [DllImport("user32.dll", CharSet = CharSet.Auto)]
429
        private static extern IntPtr SendMessage(IntPtr hWnd, int Msg, IntPtr wParam,
430
                                                 ref TVITEM lParam);
431
432
        /// <summary>
433
        /// Hides the checkbox for the specified node on a TreeView control.
434
        /// </summary>
435
        private void HideCheckBox(TreeView tvw, TreeNode node)
436
        {
437
            TVITEM tvi = new TVITEM();
438
            tvi.hItem = node.Handle;
439
            tvi.mask = TVIF_STATE;
440
            tvi.stateMask = TVIS_STATEIMAGEMASK;
441
            tvi.state = 0;
442
            SendMessage(tvw.Handle, TVM_SETITEM, IntPtr.Zero, ref tvi);
443
        }
444
        #endregion
445
446
        private void SetDrawingTreeNode(string fileName)
447
        {
448 8c37691c gaqhf
            SPPID.Model.Document document = SPPID.Model.Document.Load(fileName, symbolMapping, attributeMapping);
449 1cad80c1 gaqhf
450 022cae08 gaqhf
            TreeNode drawingNode = new TreeNode();
451
            if (document == null)
452
            {
453
                drawingNode.Text = fileName;
454
                drawingNode.Name = fileName;
455
                drawingNode.ForeColor = Color.Red;
456
                treeViewDrawing.Nodes[0].Nodes.Add(drawingNode);
457
            }
458
            else
459
            {
460 1cad80c1 gaqhf
                foreach (TreeNode treeNode in treeViewDrawing.Nodes[0].Nodes)
461
                {
462
                    if (treeNode.Text == document.DWGNAME)
463
                    {
464
                        treeViewDrawing.Nodes[0].Nodes.Remove(treeNode);
465
                        break;
466
                    }
467
                }
468
469 022cae08 gaqhf
                drawingNode.Text = document.DWGNAME;
470
                drawingNode.Name = document.DWGNAME;
471
                drawingNode.Tag = document;
472
                treeViewDrawing.Nodes[0].Nodes.Add(drawingNode);
473
            }
474
475
            SetItemTreeNode(drawingNode);
476
        }
477
478
        private void SetItemTreeNode(TreeNode drawingNode)
479
        {
480
            SPPID.Model.Document document = drawingNode.Tag as SPPID.Model.Document;
481
            if (document != null)
482
            {
483
                foreach (LineNumber item in document.LINENUMBERS)
484
                {
485
                    TreeNode node = new TreeNode();
486 f9d4b6aa gaqhf
                    node.Name = LineNumber.LineNumberSymbolPath;
487 022cae08 gaqhf
                    node.Text = item.TEXT;
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
                foreach (Symbol item in document.SYMBOLS)
503
                {
504
                    TreeNode node = new TreeNode();
505 91502a9b gaqhf
                    node.Name = item.PARENT;
506 022cae08 gaqhf
                    node.Text = item.NAME;
507 91502a9b gaqhf
                    node.Tag = item;
508 022cae08 gaqhf
                    drawingNode.Nodes.Add(node);
509
                    HideCheckBox(treeViewDrawing, node);
510 91502a9b gaqhf
                    foreach (ItemAttribute attribute in item.ATTRIBUTES)
511
                    {
512
                        TreeNode attrNode = new TreeNode();
513
                        attrNode.Name = attribute.Attribute;
514
                        attrNode.Text = attribute.Attribute;
515
                        attrNode.Tag = attribute;
516
                        node.Nodes.Add(attrNode);
517
                        HideCheckBox(treeViewDrawing, attrNode);
518
                    }
519 e647dda7 gaqhf
520
                    foreach (SymbolChild child in item.CHILD_LIST)
521
                    {
522
                        TreeNode attrNode = new TreeNode();
523
                        attrNode.Name = child.Name;
524
                        attrNode.Text = child.Name;
525
                        attrNode.Tag = child;
526
                        node.Nodes.Add(attrNode);
527
                        HideCheckBox(treeViewDrawing, attrNode);
528
                    }
529 022cae08 gaqhf
                }
530
531
                foreach (Line item in document.LINES)
532
                {
533
                    TreeNode node = new TreeNode();
534 91502a9b gaqhf
                    node.Name = item.TYPE;
535 022cae08 gaqhf
                    node.Text = item.TYPE;
536 91502a9b gaqhf
                    node.Tag = item;
537 022cae08 gaqhf
                    drawingNode.Nodes.Add(node);
538
                    HideCheckBox(treeViewDrawing, node);
539 91502a9b gaqhf
                    foreach (ItemAttribute attribute in item.ATTRIBUTES)
540
                    {
541
                        TreeNode attrNode = new TreeNode();
542
                        attrNode.Name = attribute.Attribute;
543
                        attrNode.Text = attribute.Attribute;
544
                        attrNode.Tag = attribute;
545
                        node.Nodes.Add(attrNode);
546
                        HideCheckBox(treeViewDrawing, attrNode);
547
                    }
548 022cae08 gaqhf
                }
549 8c37691c gaqhf
                
550
                foreach (SpecBreak item in document.SPECBREAK)
551
                {
552
                    foreach (ItemAttribute attribute in item.ATTRIBUTES)
553
                    {
554
                        TreeNode node = new TreeNode();
555
                        node.Name = attribute.Attribute;
556
                        node.Text = attribute.Attribute;
557
                        node.Tag = item;
558
                        drawingNode.Nodes.Add(node);
559
                        HideCheckBox(treeViewDrawing, node);
560
561
                        TreeNode attrNode = new TreeNode();
562
                        attrNode.Name = attribute.Attribute;
563
                        attrNode.Text = attribute.Attribute;
564
                        attrNode.Tag = attribute;
565
                        node.Nodes.Add(attrNode);
566
                        HideCheckBox(treeViewDrawing, attrNode);
567
                    }
568
                }
569 022cae08 gaqhf
570
                foreach (Text item in document.TEXTS)
571
                {
572
                    TreeNode node = new TreeNode();
573 91502a9b gaqhf
                    node.Name = item.NAME;
574 022cae08 gaqhf
                    node.Text = item.NAME;
575 91502a9b gaqhf
                    node.Tag = item;
576 022cae08 gaqhf
                    drawingNode.Nodes.Add(node);
577
                    HideCheckBox(treeViewDrawing, node);
578 91502a9b gaqhf
                    foreach (ItemAttribute attribute in item.ATTRIBUTES)
579
                    {
580
                        TreeNode attrNode = new TreeNode();
581
                        attrNode.Name = attribute.Attribute;
582
                        attrNode.Text = attribute.Attribute;
583
                        attrNode.Tag = attribute;
584
                        node.Nodes.Add(attrNode);
585
                        HideCheckBox(treeViewDrawing, attrNode);
586
                    }
587 022cae08 gaqhf
                }
588
            }
589
        }
590
591 91502a9b gaqhf
        private void RefreshItemNode()
592 022cae08 gaqhf
        {
593 f9d4b6aa gaqhf
            foreach (TreeNode docNode in treeViewDrawing.Nodes[0].Nodes)
594 91502a9b gaqhf
            {
595 f9d4b6aa gaqhf
                docNode.ForeColor = Color.Red;
596 91502a9b gaqhf
                bool result = true;
597 f9d4b6aa gaqhf
                foreach (TreeNode itemNode in docNode.Nodes)
598 91502a9b gaqhf
                {
599 f9d4b6aa gaqhf
                    string name = itemNode.Name;
600
                    if (name == "SIZE")
601 91502a9b gaqhf
                    {
602 8c37691c gaqhf
                        string sppidName = SPPIDUtill.GetSPPIDSymbolMappingName(SPPID.Model.Text.pipingCompSize, symbolMapping);
603 f9d4b6aa gaqhf
                        if (!string.IsNullOrEmpty(sppidName))
604
                        {
605
                            itemNode.ForeColor = Color.Gray;
606
                        }
607
                        else
608
                        {
609
                            itemNode.ForeColor = Color.Red;
610
                            result = false;
611
                        }
612 8c37691c gaqhf
                        sppidName = SPPIDUtill.GetSPPIDSymbolMappingName(SPPID.Model.Text.instrumentSize, symbolMapping);
613 f9d4b6aa gaqhf
                        if (!string.IsNullOrEmpty(sppidName))
614
                        {
615
                            itemNode.ForeColor = Color.Gray;
616
                        }
617
                        else
618
                        {
619
                            itemNode.ForeColor = Color.Red;
620
                            result = false;
621
                        }
622 91502a9b gaqhf
                    }
623
                    else
624
                    {
625 8c37691c gaqhf
                        string sppidName = SPPIDUtill.GetSPPIDSymbolMappingName(name, symbolMapping);
626 f9d4b6aa gaqhf
                        if (!string.IsNullOrEmpty(sppidName))
627
                        {
628
                            itemNode.ForeColor = Color.Gray;
629
                        }
630
                        else
631
                        {
632
                            itemNode.ForeColor = Color.Red;
633
                            result = false;
634
                        }
635 91502a9b gaqhf
                    }
636
637 e647dda7 gaqhf
                    foreach (TreeNode childNode in itemNode.Nodes)
638 91502a9b gaqhf
                    {
639 e647dda7 gaqhf
                        name = childNode.Name;
640 8c37691c gaqhf
                        string sppidName = "";
641
                        if (childNode.Tag.GetType() == typeof(ItemAttribute))
642
                            sppidName = SPPIDUtill.GetSPPIDAttributeMappingName(name, attributeMapping);
643
                        else
644
                            sppidName = SPPIDUtill.GetSPPIDSymbolMappingName(name, symbolMapping);
645
                        
646 f9d4b6aa gaqhf
                        if (!string.IsNullOrEmpty(sppidName))
647 91502a9b gaqhf
                        {
648 e647dda7 gaqhf
                            childNode.ForeColor = Color.Gray;
649 91502a9b gaqhf
                        }
650
                        else
651
                        {
652 e647dda7 gaqhf
                            childNode.ForeColor = Color.Red;
653
                            if (typeof(SymbolChild) == childNode.Tag.GetType())
654
                                childNode.Parent.ForeColor = Color.Red;
655 91502a9b gaqhf
                        }
656
                    }
657
                }
658 022cae08 gaqhf
659 91502a9b gaqhf
                if (result)
660
                {
661 f9d4b6aa gaqhf
                    docNode.ForeColor = Color.Black;
662 91502a9b gaqhf
                }
663
            }
664
        }
665 022cae08 gaqhf
666 8c37691c gaqhf
        private List<string> GetNeedSymbolMapping()
667 91502a9b gaqhf
        {
668
            List<string> nameList = new List<string>();
669
            foreach (TreeNode dwgNode in treeViewDrawing.Nodes[0].Nodes)
670
            {
671
                foreach (TreeNode docNode in dwgNode.Nodes)
672
                {
673
                    string name = docNode.Name;
674 f9d4b6aa gaqhf
                    if (name == "SIZE")
675
                    {
676 8c37691c gaqhf
                        string sppidName = SPPIDUtill.GetSPPIDSymbolMappingName(SPPID.Model.Text.pipingCompSize, symbolMapping);
677
                        if (string.IsNullOrEmpty(sppidName) && !nameList.Contains(SPPID.Model.Text.pipingCompSize))
678 f9d4b6aa gaqhf
                            nameList.Add(SPPID.Model.Text.pipingCompSize);
679 8c37691c gaqhf
                        sppidName = SPPIDUtill.GetSPPIDSymbolMappingName(SPPID.Model.Text.instrumentSize, symbolMapping);
680
                        if (string.IsNullOrEmpty(sppidName) && !nameList.Contains(SPPID.Model.Text.instrumentSize))
681 f9d4b6aa gaqhf
                            nameList.Add(SPPID.Model.Text.instrumentSize);
682
683
                    }
684
                    else
685
                    {
686 8c37691c gaqhf
                        string sppidName = SPPIDUtill.GetSPPIDSymbolMappingName(name, symbolMapping);
687 f9d4b6aa gaqhf
                        if (string.IsNullOrEmpty(sppidName) && !nameList.Contains(name))
688
                            nameList.Add(name);
689
                    }
690 91502a9b gaqhf
691 8c37691c gaqhf
692
                    foreach (TreeNode childNode in docNode.Nodes)
693 91502a9b gaqhf
                    {
694 8c37691c gaqhf
                        name = childNode.Name;
695
                        if (childNode.Tag.GetType() == typeof(SymbolChild))
696
                        {
697
                            string sppidName = SPPIDUtill.GetSPPIDSymbolMappingName(name, symbolMapping);
698
                            if (string.IsNullOrEmpty(sppidName) && !nameList.Contains(name))
699
                                nameList.Add(name);
700
                        }
701
                    }
702
                }
703
            }
704
705
            return nameList;
706
        }
707
708
        private List<string> GetNeedAttributeMapping()
709
        {
710
            List<string> nameList = new List<string>();
711
            foreach (TreeNode dwgNode in treeViewDrawing.Nodes[0].Nodes)
712
            {
713
                foreach (TreeNode docNode in dwgNode.Nodes)
714
                {
715
                    foreach (TreeNode childNode in docNode.Nodes)
716
                    {
717
                        string name = childNode.Name;
718
                        if (childNode.Tag.GetType() == typeof(ItemAttribute))
719
                        {
720
                            string sppidName = SPPIDUtill.GetSPPIDAttributeMappingName(name, attributeMapping);
721
                            if (string.IsNullOrEmpty(sppidName) && !nameList.Contains(name))
722
                                nameList.Add(name);
723
                        }
724 91502a9b gaqhf
                    }
725
                }
726
            }
727 022cae08 gaqhf
728 91502a9b gaqhf
            return nameList;
729 022cae08 gaqhf
        }
730
731 91502a9b gaqhf
        private void treeViewDrawing_AfterCheck(object sender, TreeViewEventArgs e)
732
        {
733
            treeViewDrawing.AfterCheck -= new TreeViewEventHandler(this.treeViewDrawing_AfterCheck);
734
735
            if (e.Node.Level == 0)
736
            {
737
                foreach (TreeNode node in e.Node.Nodes)
738
                    node.Checked = e.Node.Checked;
739
            }
740
            else if (e.Node.Level == 1)
741
            {
742
                bool result = false;
743
                foreach (TreeNode node in e.Node.Parent.Nodes)
744
                {
745
                    if (node.Checked)
746
                    {
747
                        result = true;
748
                        break;
749
                    }
750
                }
751
752
                if (result)
753
                    e.Node.Parent.Checked = true;
754
                else
755
                    e.Node.Parent.Checked = false;
756
            }
757 022cae08 gaqhf
758 91502a9b gaqhf
            treeViewDrawing.AfterCheck += new TreeViewEventHandler(this.treeViewDrawing_AfterCheck);
759
        }
760 022cae08 gaqhf
761 8c37691c gaqhf
        private void exitToolStripMenuItem_Click(object sender, EventArgs e)
762
        {
763
            commandControl.Application.RADApplication.Interactive = true;
764
            Hide();
765
            commandControl.Done = true;
766
        }
767
768 d57a5303 gaqhf
        #endregion
769 022cae08 gaqhf
770 e647dda7 gaqhf
        #endregion
771 91502a9b gaqhf
772 58403896 gaqhf
773 d57a5303 gaqhf
    }
774
}