hytos / DTI_PID / SPPIDConverter_CustomCommand / SPPIDConverter.cs @ 522be0fa
이력 | 보기 | 이력해설 | 다운로드 (29.1 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 |
using Microsoft.VisualBasic; |
34 |
|
35 |
namespace CustomCommand |
36 |
{ |
37 |
/// <summary> |
38 |
/// Used to create a modeless dialog form command to be used in |
39 |
/// SmartSketch. |
40 |
/// </summary> |
41 |
public partial class SPPIDConverter : UserControl |
42 |
{ |
43 |
/// Expose my Caption property |
44 |
/// </summary> |
45 |
public string Caption |
46 |
{ |
47 |
get; set; |
48 |
} |
49 |
|
50 |
/// <summary> |
51 |
/// Expose my PreferredHeight property |
52 |
/// </summary> |
53 |
public int PreferredHeight |
54 |
{ |
55 |
get; set; |
56 |
} |
57 |
|
58 |
/// <summary> |
59 |
/// Expose my PreferredWidth property |
60 |
/// </summary> |
61 |
public int PreferredWidth |
62 |
{ |
63 |
get; set; |
64 |
} |
65 |
|
66 |
/// <summary> |
67 |
/// Expose my PreferredLeft property |
68 |
/// </summary> |
69 |
public int PreferredLeft |
70 |
{ |
71 |
get; set; |
72 |
} |
73 |
|
74 |
/// <summary> |
75 |
/// Expose my PreferredTop property |
76 |
/// </summary> |
77 |
public int PreferredTop |
78 |
{ |
79 |
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 |
} |
118 |
|
119 |
/// <summary> |
120 |
/// 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 |
return (System.Drawing.Image)Properties.Resources.ResourceManager.GetObject("ToolbarImage", System.Globalization.CultureInfo.CurrentCulture); |
130 |
} |
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 |
/// active document in private global data. |
171 |
/// </summary> |
172 |
/// <param name="sender">The sender of the event</param> |
173 |
/// <param name="e">The event's arguments</param> |
174 |
private void commandControl_Initialize(object sender, EventArgs e) |
175 |
{ |
176 |
/* 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 |
try |
184 |
{ |
185 |
RegistryKey key = Registry.LocalMachine; |
186 |
RegistryKey software = key.OpenSubKey("SOFTWARE"); |
187 |
RegistryKey DOFTECH = software.OpenSubKey("DOFTECH"); |
188 |
if (DOFTECH != null) |
189 |
{ |
190 |
RegistryKey ID2 = DOFTECH.OpenSubKey("ID2"); |
191 |
if (ID2 != null) |
192 |
{ |
193 |
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 |
string dllPath = SPPIDUtill.defaultPath + @"Converter\SPPIDConverter.dll"; |
198 |
|
199 |
SPPIDUtill.LoadMapping(symbolMapping, attributeMapping); |
200 |
Ingr.RAD2D.Application application = commandControl.Application.RADApplication; |
201 |
|
202 |
ToolBars toolBars = application.ToolBars; |
203 |
bool find = true; |
204 |
while (find) |
205 |
{ |
206 |
find = false; |
207 |
foreach (ToolbarControl item in toolBars["Main"].Controls) |
208 |
{ |
209 |
if (item.DLLName.Contains("SPPIDConverter.dll")) |
210 |
{ |
211 |
item.Delete(); |
212 |
find = true; |
213 |
break; |
214 |
} |
215 |
} |
216 |
} |
217 |
|
218 |
ToolbarControl toolBarControl = toolBars["Main"].Controls.AppendMacroCommand(dllPath); |
219 |
toolBarControl.ToolTipText = GetTooltip; |
220 |
toolBarControl.Picture = ToolbarImage; |
221 |
|
222 |
Menus menu = application.Menus; |
223 |
find = true; |
224 |
while (find) |
225 |
{ |
226 |
find = false; |
227 |
foreach (MenuControl item in menu["&Tools"].Controls) |
228 |
{ |
229 |
if (item.Caption == GetTooltip) |
230 |
{ |
231 |
item.Delete(); |
232 |
find = true; |
233 |
break; |
234 |
} |
235 |
} |
236 |
} |
237 |
MenuControl menuControl = application.Menus["&Tools"].Controls.AppendMacroCommand(GetTooltip, dllPath); |
238 |
menuControl.ToolTipText = GetTooltip; |
239 |
} |
240 |
} |
241 |
} |
242 |
catch (Exception ex) |
243 |
{ |
244 |
Log.WriteLine(ex); |
245 |
} |
246 |
} |
247 |
|
248 |
/// <summary> |
249 |
/// The Terminate event is where the command can clean up any command |
250 |
/// specific allocated resources. |
251 |
/// </summary> |
252 |
/// <param name="sender">The sender of the event</param> |
253 |
/// <param name="e">The event's arguments</param> |
254 |
public void commandControl_Terminate(object sender, EventArgs e) |
255 |
{ |
256 |
//Ingr.RAD2D.Application application = commandControl.Application.RADApplication; |
257 |
//string dllPath = SPPIDUtill.defaultPath + @"Converter\SPPIDConverter.dll"; |
258 |
//application.RunMacro(dllPath); |
259 |
} |
260 |
|
261 |
|
262 |
#region ?? CustomCommand Source ???? |
263 |
|
264 |
private Dictionary<string, string> symbolMapping = new Dictionary<string, string>(); |
265 |
private Dictionary<string, string> attributeMapping = new Dictionary<string, string>(); |
266 |
Thread autoModelingThread; |
267 |
|
268 |
#region Botton Event |
269 |
private void openDocumentsToolStripMenuItem_Click(object sender, EventArgs e) |
270 |
{ |
271 |
OpenFileDialog dia = new OpenFileDialog(); |
272 |
dia.Multiselect = true; |
273 |
dia.Filter = "Xml Files(*.xml)|*.xml"; |
274 |
if (dia.ShowDialog() == DialogResult.OK) |
275 |
{ |
276 |
SPPIDUtill.LoadMapping(symbolMapping, attributeMapping); |
277 |
foreach (string fileName in dia.FileNames) |
278 |
SetDrawingTreeNode(fileName); |
279 |
treeViewDrawing.Nodes[0].Expand(); |
280 |
RefreshItemNode(); |
281 |
} |
282 |
} |
283 |
|
284 |
private void itemMappingToolStripMenuItem_Click(object sender, EventArgs e) |
285 |
{ |
286 |
List<string> needSymbolName = GetNeedSymbolMapping(); |
287 |
List<string> needAttributeName = GetNeedAttributeMapping(); |
288 |
MappingForm form = new MappingForm(symbolMapping, attributeMapping, needSymbolName, needAttributeName); |
289 |
if (form.ShowDialog() == DialogResult.OK) |
290 |
{ |
291 |
SPPIDUtill.SaveMapping(symbolMapping, attributeMapping); |
292 |
RefreshItemNode(); |
293 |
} |
294 |
} |
295 |
|
296 |
private void importToolStripMenuItem_Click(object sender, EventArgs e) |
297 |
{ |
298 |
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 |
ExcelUtill.LoadMappingExcelFile(dia.FileName, symbolMapping); |
304 |
try |
305 |
{ |
306 |
SPPIDUtill.SaveMapping(symbolMapping, attributeMapping); |
307 |
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 |
} |
317 |
|
318 |
private void convertToolStripMenuItem_Click(object sender, EventArgs e) |
319 |
{ |
320 |
try |
321 |
{ |
322 |
Thread thread = new Thread(func => { |
323 |
for (int i = 0; i < 3; i++) |
324 |
{ |
325 |
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 |
} |
329 |
}); |
330 |
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 |
} |
368 |
catch (Exception ex) |
369 |
{ |
370 |
Log.WriteLine(ex); |
371 |
} |
372 |
} |
373 |
|
374 |
private void stopToolStripMenuItem_Click(object sender, EventArgs e) |
375 |
{ |
376 |
try |
377 |
{ |
378 |
if (autoModelingThread != null) |
379 |
autoModelingThread.Abort(); |
380 |
} |
381 |
catch (Exception ex) |
382 |
{ |
383 |
Log.WriteLine(ex); |
384 |
} |
385 |
} |
386 |
#endregion |
387 |
|
388 |
//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 |
|
404 |
#region TreeNode |
405 |
|
406 |
#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 |
SPPID.Model.Document document = SPPID.Model.Document.Load(fileName, symbolMapping, attributeMapping); |
449 |
|
450 |
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 |
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 |
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 |
node.Name = LineNumber.LineNumberSymbolPath; |
487 |
node.Text = item.TEXT; |
488 |
node.Tag = item; |
489 |
drawingNode.Nodes.Add(node); |
490 |
HideCheckBox(treeViewDrawing, node); |
491 |
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 |
} |
501 |
|
502 |
foreach (Symbol item in document.SYMBOLS) |
503 |
{ |
504 |
TreeNode node = new TreeNode(); |
505 |
node.Name = item.PARENT; |
506 |
node.Text = item.NAME; |
507 |
node.Tag = item; |
508 |
drawingNode.Nodes.Add(node); |
509 |
HideCheckBox(treeViewDrawing, node); |
510 |
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 |
|
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 |
} |
530 |
|
531 |
foreach (Line item in document.LINES) |
532 |
{ |
533 |
TreeNode node = new TreeNode(); |
534 |
node.Name = item.TYPE; |
535 |
node.Text = item.TYPE; |
536 |
node.Tag = item; |
537 |
drawingNode.Nodes.Add(node); |
538 |
HideCheckBox(treeViewDrawing, node); |
539 |
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 |
} |
549 |
|
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 |
|
570 |
foreach (Text item in document.TEXTS) |
571 |
{ |
572 |
TreeNode node = new TreeNode(); |
573 |
node.Name = item.NAME; |
574 |
node.Text = item.NAME; |
575 |
node.Tag = item; |
576 |
drawingNode.Nodes.Add(node); |
577 |
HideCheckBox(treeViewDrawing, node); |
578 |
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 |
} |
588 |
} |
589 |
} |
590 |
|
591 |
private void RefreshItemNode() |
592 |
{ |
593 |
foreach (TreeNode docNode in treeViewDrawing.Nodes[0].Nodes) |
594 |
{ |
595 |
docNode.ForeColor = Color.Red; |
596 |
bool result = true; |
597 |
foreach (TreeNode itemNode in docNode.Nodes) |
598 |
{ |
599 |
string name = itemNode.Name; |
600 |
if (name == "SIZE") |
601 |
{ |
602 |
string sppidName = SPPIDUtill.GetSPPIDSymbolMappingName(SPPID.Model.Text.pipingCompSize, symbolMapping); |
603 |
if (!string.IsNullOrEmpty(sppidName)) |
604 |
{ |
605 |
itemNode.ForeColor = Color.Gray; |
606 |
} |
607 |
else |
608 |
{ |
609 |
itemNode.ForeColor = Color.Red; |
610 |
result = false; |
611 |
} |
612 |
sppidName = SPPIDUtill.GetSPPIDSymbolMappingName(SPPID.Model.Text.instrumentSize, symbolMapping); |
613 |
if (!string.IsNullOrEmpty(sppidName)) |
614 |
{ |
615 |
itemNode.ForeColor = Color.Gray; |
616 |
} |
617 |
else |
618 |
{ |
619 |
itemNode.ForeColor = Color.Red; |
620 |
result = false; |
621 |
} |
622 |
} |
623 |
else |
624 |
{ |
625 |
string sppidName = SPPIDUtill.GetSPPIDSymbolMappingName(name, symbolMapping); |
626 |
if (!string.IsNullOrEmpty(sppidName)) |
627 |
{ |
628 |
itemNode.ForeColor = Color.Gray; |
629 |
} |
630 |
else |
631 |
{ |
632 |
itemNode.ForeColor = Color.Red; |
633 |
result = false; |
634 |
} |
635 |
} |
636 |
|
637 |
foreach (TreeNode childNode in itemNode.Nodes) |
638 |
{ |
639 |
name = childNode.Name; |
640 |
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 |
if (!string.IsNullOrEmpty(sppidName)) |
647 |
{ |
648 |
childNode.ForeColor = Color.Gray; |
649 |
} |
650 |
else |
651 |
{ |
652 |
childNode.ForeColor = Color.Red; |
653 |
if (typeof(SymbolChild) == childNode.Tag.GetType()) |
654 |
childNode.Parent.ForeColor = Color.Red; |
655 |
} |
656 |
} |
657 |
} |
658 |
|
659 |
if (result) |
660 |
{ |
661 |
docNode.ForeColor = Color.Black; |
662 |
} |
663 |
} |
664 |
} |
665 |
|
666 |
private List<string> GetNeedSymbolMapping() |
667 |
{ |
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 |
if (name == "SIZE") |
675 |
{ |
676 |
string sppidName = SPPIDUtill.GetSPPIDSymbolMappingName(SPPID.Model.Text.pipingCompSize, symbolMapping); |
677 |
if (string.IsNullOrEmpty(sppidName) && !nameList.Contains(SPPID.Model.Text.pipingCompSize)) |
678 |
nameList.Add(SPPID.Model.Text.pipingCompSize); |
679 |
sppidName = SPPIDUtill.GetSPPIDSymbolMappingName(SPPID.Model.Text.instrumentSize, symbolMapping); |
680 |
if (string.IsNullOrEmpty(sppidName) && !nameList.Contains(SPPID.Model.Text.instrumentSize)) |
681 |
nameList.Add(SPPID.Model.Text.instrumentSize); |
682 |
|
683 |
} |
684 |
else |
685 |
{ |
686 |
string sppidName = SPPIDUtill.GetSPPIDSymbolMappingName(name, symbolMapping); |
687 |
if (string.IsNullOrEmpty(sppidName) && !nameList.Contains(name)) |
688 |
nameList.Add(name); |
689 |
} |
690 |
|
691 |
|
692 |
foreach (TreeNode childNode in docNode.Nodes) |
693 |
{ |
694 |
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 |
} |
725 |
} |
726 |
} |
727 |
|
728 |
return nameList; |
729 |
} |
730 |
|
731 |
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 |
|
758 |
treeViewDrawing.AfterCheck += new TreeViewEventHandler(this.treeViewDrawing_AfterCheck); |
759 |
} |
760 |
|
761 |
private void exitToolStripMenuItem_Click(object sender, EventArgs e) |
762 |
{ |
763 |
commandControl.Application.RADApplication.Interactive = true; |
764 |
Hide(); |
765 |
commandControl.Done = true; |
766 |
} |
767 |
|
768 |
#endregion |
769 |
|
770 |
#endregion |
771 |
|
772 |
|
773 |
} |
774 |
} |