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