hytos / DTI_PID / SPPIDConverter_CustomCommand / SPPIDConverter.cs @ 7edc8b5f
이력 | 보기 | 이력해설 | 다운로드 (28.8 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 | d57a5303 | gaqhf | |
34 | namespace CustomCommand |
||
35 | { |
||
36 | /// <summary> |
||
37 | 8c37691c | gaqhf | /// Used to create a modeless dialog form command to be used in |
38 | /// SmartSketch. |
||
39 | d57a5303 | gaqhf | /// </summary> |
40 | 8c37691c | gaqhf | public partial class SPPIDConverter : UserControl |
41 | d57a5303 | gaqhf | { |
42 | 91502a9b | gaqhf | readonly string menuControlName = "ID2 to SPPID Converter"; |
43 | readonly string toolTipText = "ID2 to SPPID Converter"; |
||
44 | 1cad80c1 | gaqhf | readonly Image image = (Image)Properties.Resources.ResourceManager.GetObject("ToolbarImage"); |
45 | 8c37691c | gaqhf | |
46 | /// Expose my Caption property |
||
47 | /// </summary> |
||
48 | public string Caption |
||
49 | { |
||
50 | get; set; |
||
51 | } |
||
52 | |||
53 | d57a5303 | gaqhf | /// <summary> |
54 | 8c37691c | gaqhf | /// Expose my PreferredHeight property |
55 | d57a5303 | gaqhf | /// </summary> |
56 | 8c37691c | gaqhf | public int PreferredHeight |
57 | d57a5303 | gaqhf | { |
58 | 8c37691c | gaqhf | get; set; |
59 | d57a5303 | gaqhf | } |
60 | 8c37691c | gaqhf | |
61 | d57a5303 | gaqhf | /// <summary> |
62 | 8c37691c | gaqhf | /// Expose my PreferredWidth property |
63 | d57a5303 | gaqhf | /// </summary> |
64 | 8c37691c | gaqhf | public int PreferredWidth |
65 | { |
||
66 | get; set; |
||
67 | } |
||
68 | d57a5303 | gaqhf | |
69 | /// <summary> |
||
70 | 8c37691c | gaqhf | /// Expose my PreferredLeft property |
71 | d57a5303 | gaqhf | /// </summary> |
72 | 8c37691c | gaqhf | public int PreferredLeft |
73 | d57a5303 | gaqhf | { |
74 | 8c37691c | gaqhf | get; set; |
75 | d57a5303 | gaqhf | } |
76 | |||
77 | /// <summary> |
||
78 | 8c37691c | gaqhf | /// Expose my PreferredTop property |
79 | d57a5303 | gaqhf | /// </summary> |
80 | 8c37691c | gaqhf | public int PreferredTop |
81 | d57a5303 | gaqhf | { |
82 | 8c37691c | gaqhf | 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 | d57a5303 | gaqhf | } |
121 | |||
122 | /// <summary> |
||
123 | 8c37691c | gaqhf | /// 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 | d57a5303 | gaqhf | /// active document in private global data. |
174 | /// </summary> |
||
175 | /// <param name="sender">The sender of the event</param> |
||
176 | 8c37691c | gaqhf | /// <param name="e">The event's arguments</param> |
177 | d57a5303 | gaqhf | private void commandControl_Initialize(object sender, EventArgs e) |
178 | { |
||
179 | 8c37691c | gaqhf | /* 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 | 91502a9b | gaqhf | try |
187 | { |
||
188 | 4582b1d2 | gaqhf | RegistryKey key = Registry.LocalMachine; |
189 | RegistryKey software = key.OpenSubKey("SOFTWARE"); |
||
190 | RegistryKey DOFTECH = software.OpenSubKey("DOFTECH"); |
||
191 | if (DOFTECH != null) |
||
192 | 91502a9b | gaqhf | { |
193 | 4582b1d2 | gaqhf | RegistryKey ID2 = DOFTECH.OpenSubKey("ID2"); |
194 | if (ID2 != null) |
||
195 | 91502a9b | gaqhf | { |
196 | 4582b1d2 | gaqhf | 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 | 8c37691c | gaqhf | string dllPath = SPPIDUtill.defaultPath + @"Converter\SPPIDConverter.dll"; |
201 | 4582b1d2 | gaqhf | |
202 | 8c37691c | gaqhf | SPPIDUtill.LoadMapping(symbolMapping, attributeMapping); |
203 | 4582b1d2 | gaqhf | Ingr.RAD2D.Application application = commandControl.Application.RADApplication; |
204 | |||
205 | ToolBars toolBars = application.ToolBars; |
||
206 | bool find = true; |
||
207 | while (find) |
||
208 | 91502a9b | gaqhf | { |
209 | 4582b1d2 | gaqhf | find = false; |
210 | foreach (ToolbarControl item in toolBars["Main"].Controls) |
||
211 | { |
||
212 | 8c37691c | gaqhf | if (item.DLLName.Contains("SPPIDConverter.dll")) |
213 | 4582b1d2 | gaqhf | { |
214 | item.Delete(); |
||
215 | find = true; |
||
216 | break; |
||
217 | } |
||
218 | } |
||
219 | 91502a9b | gaqhf | } |
220 | |||
221 | 4582b1d2 | gaqhf | ToolbarControl toolBarControl = toolBars["Main"].Controls.AppendMacroCommand(dllPath); |
222 | toolBarControl.ToolTipText = toolTipText; |
||
223 | //toolBarControl.Picture = image; |
||
224 | 91502a9b | gaqhf | |
225 | 4582b1d2 | gaqhf | Menus menu = application.Menus; |
226 | find = true; |
||
227 | while (find) |
||
228 | 91502a9b | gaqhf | { |
229 | 4582b1d2 | gaqhf | 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 | 91502a9b | gaqhf | } |
240 | 4582b1d2 | gaqhf | MenuControl menuControl = application.Menus["&Tools"].Controls.AppendMacroCommand(menuControlName, dllPath); |
241 | menuControl.ToolTipText = toolTipText; |
||
242 | 91502a9b | gaqhf | } |
243 | } |
||
244 | } |
||
245 | catch (Exception ex) |
||
246 | { |
||
247 | Log.WriteLine(ex); |
||
248 | } |
||
249 | d57a5303 | gaqhf | } |
250 | |||
251 | /// <summary> |
||
252 | /// The Terminate event is where the command can clean up any command |
||
253 | 8c37691c | gaqhf | /// specific allocated resources. |
254 | d57a5303 | gaqhf | /// </summary> |
255 | /// <param name="sender">The sender of the event</param> |
||
256 | 8c37691c | gaqhf | /// <param name="e">The event's arguments</param> |
257 | d57a5303 | gaqhf | public void commandControl_Terminate(object sender, EventArgs e) |
258 | { |
||
259 | 8c37691c | gaqhf | //Ingr.RAD2D.Application application = commandControl.Application.RADApplication; |
260 | //string dllPath = SPPIDUtill.defaultPath + @"Converter\SPPIDConverter.dll"; |
||
261 | //application.RunMacro(dllPath); |
||
262 | d57a5303 | gaqhf | } |
263 | |||
264 | 022cae08 | gaqhf | |
265 | #region ?? CustomCommand Source ???? |
||
266 | |||
267 | 8c37691c | gaqhf | private Dictionary<string, string> symbolMapping = new Dictionary<string, string>(); |
268 | private Dictionary<string, string> attributeMapping = new Dictionary<string, string>(); |
||
269 | 91502a9b | gaqhf | Thread autoModelingThread; |
270 | |||
271 | #region Botton Event |
||
272 | 022cae08 | gaqhf | private void openDocumentsToolStripMenuItem_Click(object sender, EventArgs e) |
273 | { |
||
274 | OpenFileDialog dia = new OpenFileDialog(); |
||
275 | dia.Multiselect = true; |
||
276 | 91502a9b | gaqhf | dia.Filter = "Xml Files(*.xml)|*.xml"; |
277 | 022cae08 | gaqhf | if (dia.ShowDialog() == DialogResult.OK) |
278 | { |
||
279 | 8c37691c | gaqhf | SPPIDUtill.LoadMapping(symbolMapping, attributeMapping); |
280 | 022cae08 | gaqhf | foreach (string fileName in dia.FileNames) |
281 | SetDrawingTreeNode(fileName); |
||
282 | treeViewDrawing.Nodes[0].Expand(); |
||
283 | 91502a9b | gaqhf | RefreshItemNode(); |
284 | 022cae08 | gaqhf | } |
285 | } |
||
286 | |||
287 | private void itemMappingToolStripMenuItem_Click(object sender, EventArgs e) |
||
288 | { |
||
289 | 8c37691c | gaqhf | List<string> needSymbolName = GetNeedSymbolMapping(); |
290 | List<string> needAttributeName = GetNeedAttributeMapping(); |
||
291 | MappingForm form = new MappingForm(symbolMapping, attributeMapping, needSymbolName, needAttributeName); |
||
292 | 91502a9b | gaqhf | if (form.ShowDialog() == DialogResult.OK) |
293 | { |
||
294 | 8c37691c | gaqhf | SPPIDUtill.SaveMapping(symbolMapping, attributeMapping); |
295 | 91502a9b | gaqhf | RefreshItemNode(); |
296 | } |
||
297 | 022cae08 | gaqhf | } |
298 | |||
299 | private void importToolStripMenuItem_Click(object sender, EventArgs e) |
||
300 | { |
||
301 | 91502a9b | gaqhf | 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 | 8c37691c | gaqhf | ExcelUtill.LoadMappingExcelFile(dia.FileName, symbolMapping); |
307 | 91502a9b | gaqhf | try |
308 | { |
||
309 | 8c37691c | gaqhf | SPPIDUtill.SaveMapping(symbolMapping, attributeMapping); |
310 | 91502a9b | gaqhf | 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 | 022cae08 | gaqhf | } |
320 | 91502a9b | gaqhf | |
321 | 022cae08 | gaqhf | private void convertToolStripMenuItem_Click(object sender, EventArgs e) |
322 | { |
||
323 | 8c37691c | gaqhf | try |
324 | 91502a9b | gaqhf | { |
325 | 8c37691c | gaqhf | 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 | 91502a9b | gaqhf | { |
330 | 8c37691c | gaqhf | 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 | 91502a9b | gaqhf | } |
339 | 022cae08 | gaqhf | |
340 | 8c37691c | gaqhf | autoModelingThread = new Thread(Func => |
341 | 91502a9b | gaqhf | { |
342 | 8c37691c | gaqhf | try |
343 | 91502a9b | gaqhf | { |
344 | 8c37691c | gaqhf | foreach (SPPID.Model.Document document in documents) |
345 | { |
||
346 | 1cad80c1 | gaqhf | |
347 | 8c37691c | gaqhf | AutoModeling auto = new AutoModeling(document); |
348 | auto.SetListBoxLog(listBoxLog); |
||
349 | auto.SetProgressBar(toolStripProgressBar); |
||
350 | auto.Run(); |
||
351 | } |
||
352 | 91502a9b | gaqhf | } |
353 | 8c37691c | gaqhf | 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 | 022cae08 | gaqhf | } |
365 | |||
366 | private void stopToolStripMenuItem_Click(object sender, EventArgs e) |
||
367 | { |
||
368 | 91502a9b | gaqhf | try |
369 | { |
||
370 | if (autoModelingThread != null) |
||
371 | autoModelingThread.Abort(); |
||
372 | } |
||
373 | catch (Exception ex) |
||
374 | { |
||
375 | Log.WriteLine(ex); |
||
376 | } |
||
377 | } |
||
378 | #endregion |
||
379 | 022cae08 | gaqhf | |
380 | 8c37691c | gaqhf | //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 | 022cae08 | gaqhf | |
396 | #region TreeNode |
||
397 | 91502a9b | gaqhf | |
398 | 022cae08 | gaqhf | #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 | 8c37691c | gaqhf | SPPID.Model.Document document = SPPID.Model.Document.Load(fileName, symbolMapping, attributeMapping); |
441 | 1cad80c1 | gaqhf | |
442 | 022cae08 | gaqhf | 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 | 1cad80c1 | gaqhf | 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 | 022cae08 | gaqhf | 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 | f9d4b6aa | gaqhf | node.Name = LineNumber.LineNumberSymbolPath; |
479 | 022cae08 | gaqhf | node.Text = item.TEXT; |
480 | 91502a9b | gaqhf | node.Tag = item; |
481 | 022cae08 | gaqhf | drawingNode.Nodes.Add(node); |
482 | HideCheckBox(treeViewDrawing, node); |
||
483 | 91502a9b | gaqhf | 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 | 022cae08 | gaqhf | } |
493 | |||
494 | foreach (Symbol item in document.SYMBOLS) |
||
495 | { |
||
496 | TreeNode node = new TreeNode(); |
||
497 | 91502a9b | gaqhf | node.Name = item.PARENT; |
498 | 022cae08 | gaqhf | node.Text = item.NAME; |
499 | 91502a9b | gaqhf | node.Tag = item; |
500 | 022cae08 | gaqhf | drawingNode.Nodes.Add(node); |
501 | HideCheckBox(treeViewDrawing, node); |
||
502 | 91502a9b | gaqhf | 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 | e647dda7 | gaqhf | |
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 | 022cae08 | gaqhf | } |
522 | |||
523 | foreach (Line item in document.LINES) |
||
524 | { |
||
525 | TreeNode node = new TreeNode(); |
||
526 | 91502a9b | gaqhf | node.Name = item.TYPE; |
527 | 022cae08 | gaqhf | node.Text = item.TYPE; |
528 | 91502a9b | gaqhf | node.Tag = item; |
529 | 022cae08 | gaqhf | drawingNode.Nodes.Add(node); |
530 | HideCheckBox(treeViewDrawing, node); |
||
531 | 91502a9b | gaqhf | 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 | 022cae08 | gaqhf | } |
541 | 8c37691c | gaqhf | |
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 | 022cae08 | gaqhf | |
562 | foreach (Text item in document.TEXTS) |
||
563 | { |
||
564 | TreeNode node = new TreeNode(); |
||
565 | 91502a9b | gaqhf | node.Name = item.NAME; |
566 | 022cae08 | gaqhf | node.Text = item.NAME; |
567 | 91502a9b | gaqhf | node.Tag = item; |
568 | 022cae08 | gaqhf | drawingNode.Nodes.Add(node); |
569 | HideCheckBox(treeViewDrawing, node); |
||
570 | 91502a9b | gaqhf | 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 | 022cae08 | gaqhf | } |
580 | } |
||
581 | } |
||
582 | |||
583 | 91502a9b | gaqhf | private void RefreshItemNode() |
584 | 022cae08 | gaqhf | { |
585 | f9d4b6aa | gaqhf | foreach (TreeNode docNode in treeViewDrawing.Nodes[0].Nodes) |
586 | 91502a9b | gaqhf | { |
587 | f9d4b6aa | gaqhf | docNode.ForeColor = Color.Red; |
588 | 91502a9b | gaqhf | bool result = true; |
589 | f9d4b6aa | gaqhf | foreach (TreeNode itemNode in docNode.Nodes) |
590 | 91502a9b | gaqhf | { |
591 | f9d4b6aa | gaqhf | string name = itemNode.Name; |
592 | if (name == "SIZE") |
||
593 | 91502a9b | gaqhf | { |
594 | 8c37691c | gaqhf | string sppidName = SPPIDUtill.GetSPPIDSymbolMappingName(SPPID.Model.Text.pipingCompSize, symbolMapping); |
595 | f9d4b6aa | gaqhf | if (!string.IsNullOrEmpty(sppidName)) |
596 | { |
||
597 | itemNode.ForeColor = Color.Gray; |
||
598 | } |
||
599 | else |
||
600 | { |
||
601 | itemNode.ForeColor = Color.Red; |
||
602 | result = false; |
||
603 | } |
||
604 | 8c37691c | gaqhf | sppidName = SPPIDUtill.GetSPPIDSymbolMappingName(SPPID.Model.Text.instrumentSize, symbolMapping); |
605 | f9d4b6aa | gaqhf | if (!string.IsNullOrEmpty(sppidName)) |
606 | { |
||
607 | itemNode.ForeColor = Color.Gray; |
||
608 | } |
||
609 | else |
||
610 | { |
||
611 | itemNode.ForeColor = Color.Red; |
||
612 | result = false; |
||
613 | } |
||
614 | 91502a9b | gaqhf | } |
615 | else |
||
616 | { |
||
617 | 8c37691c | gaqhf | string sppidName = SPPIDUtill.GetSPPIDSymbolMappingName(name, symbolMapping); |
618 | f9d4b6aa | gaqhf | if (!string.IsNullOrEmpty(sppidName)) |
619 | { |
||
620 | itemNode.ForeColor = Color.Gray; |
||
621 | } |
||
622 | else |
||
623 | { |
||
624 | itemNode.ForeColor = Color.Red; |
||
625 | result = false; |
||
626 | } |
||
627 | 91502a9b | gaqhf | } |
628 | |||
629 | e647dda7 | gaqhf | foreach (TreeNode childNode in itemNode.Nodes) |
630 | 91502a9b | gaqhf | { |
631 | e647dda7 | gaqhf | name = childNode.Name; |
632 | 8c37691c | gaqhf | 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 | f9d4b6aa | gaqhf | if (!string.IsNullOrEmpty(sppidName)) |
639 | 91502a9b | gaqhf | { |
640 | e647dda7 | gaqhf | childNode.ForeColor = Color.Gray; |
641 | 91502a9b | gaqhf | } |
642 | else |
||
643 | { |
||
644 | e647dda7 | gaqhf | childNode.ForeColor = Color.Red; |
645 | if (typeof(SymbolChild) == childNode.Tag.GetType()) |
||
646 | childNode.Parent.ForeColor = Color.Red; |
||
647 | 91502a9b | gaqhf | } |
648 | } |
||
649 | } |
||
650 | 022cae08 | gaqhf | |
651 | 91502a9b | gaqhf | if (result) |
652 | { |
||
653 | f9d4b6aa | gaqhf | docNode.ForeColor = Color.Black; |
654 | 91502a9b | gaqhf | } |
655 | } |
||
656 | } |
||
657 | 022cae08 | gaqhf | |
658 | 8c37691c | gaqhf | private List<string> GetNeedSymbolMapping() |
659 | 91502a9b | gaqhf | { |
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 | f9d4b6aa | gaqhf | if (name == "SIZE") |
667 | { |
||
668 | 8c37691c | gaqhf | string sppidName = SPPIDUtill.GetSPPIDSymbolMappingName(SPPID.Model.Text.pipingCompSize, symbolMapping); |
669 | if (string.IsNullOrEmpty(sppidName) && !nameList.Contains(SPPID.Model.Text.pipingCompSize)) |
||
670 | f9d4b6aa | gaqhf | nameList.Add(SPPID.Model.Text.pipingCompSize); |
671 | 8c37691c | gaqhf | sppidName = SPPIDUtill.GetSPPIDSymbolMappingName(SPPID.Model.Text.instrumentSize, symbolMapping); |
672 | if (string.IsNullOrEmpty(sppidName) && !nameList.Contains(SPPID.Model.Text.instrumentSize)) |
||
673 | f9d4b6aa | gaqhf | nameList.Add(SPPID.Model.Text.instrumentSize); |
674 | |||
675 | } |
||
676 | else |
||
677 | { |
||
678 | 8c37691c | gaqhf | string sppidName = SPPIDUtill.GetSPPIDSymbolMappingName(name, symbolMapping); |
679 | f9d4b6aa | gaqhf | if (string.IsNullOrEmpty(sppidName) && !nameList.Contains(name)) |
680 | nameList.Add(name); |
||
681 | } |
||
682 | 91502a9b | gaqhf | |
683 | 8c37691c | gaqhf | |
684 | foreach (TreeNode childNode in docNode.Nodes) |
||
685 | 91502a9b | gaqhf | { |
686 | 8c37691c | gaqhf | 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 | 91502a9b | gaqhf | } |
717 | } |
||
718 | } |
||
719 | 022cae08 | gaqhf | |
720 | 91502a9b | gaqhf | return nameList; |
721 | 022cae08 | gaqhf | } |
722 | |||
723 | 91502a9b | gaqhf | 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 | 022cae08 | gaqhf | |
750 | 91502a9b | gaqhf | treeViewDrawing.AfterCheck += new TreeViewEventHandler(this.treeViewDrawing_AfterCheck); |
751 | } |
||
752 | 022cae08 | gaqhf | |
753 | 8c37691c | gaqhf | private void exitToolStripMenuItem_Click(object sender, EventArgs e) |
754 | { |
||
755 | commandControl.Application.RADApplication.Interactive = true; |
||
756 | Hide(); |
||
757 | commandControl.Done = true; |
||
758 | } |
||
759 | |||
760 | d57a5303 | gaqhf | #endregion |
761 | 022cae08 | gaqhf | |
762 | e647dda7 | gaqhf | #endregion |
763 | 91502a9b | gaqhf | |
764 | 58403896 | gaqhf | |
765 | d57a5303 | gaqhf | } |
766 | } |