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