hytos / DTI_PID / SPPIDConverter / ConverterDocking.cs @ b93e7eef
이력 | 보기 | 이력해설 | 다운로드 (6.95 KB)
1 | 65881d60 | gaqhf | using System; |
---|---|---|---|
2 | using System.Collections.Generic; |
||
3 | using System.ComponentModel; |
||
4 | using System.Drawing; |
||
5 | using System.Data; |
||
6 | using System.Linq; |
||
7 | using System.Text; |
||
8 | using System.Threading.Tasks; |
||
9 | using System.Windows.Forms; |
||
10 | using System.Threading; |
||
11 | using Microsoft.VisualBasic; |
||
12 | e3e2d41f | gaqhf | using Ingr.RAD2D; |
13 | d19ae675 | gaqhf | using Converter.BaseModel; |
14 | using Converter.SPPID.Properties; |
||
15 | using Converter.SPPID.DB; |
||
16 | using Converter.SPPID.Util; |
||
17 | using Converter.SPPID.Form; |
||
18 | using Converter.SPPID.Model; |
||
19 | 1ba9c671 | gaqhf | using Plaice; |
20 | using Llama; |
||
21 | ca214bc3 | gaqhf | using DevExpress.XtraSplashScreen; |
22 | 65881d60 | gaqhf | |
23 | namespace Converter.SPPID.Wrapper |
||
24 | { |
||
25 | public partial class ConverterDocking : UserControl |
||
26 | { |
||
27 | e3e2d41f | gaqhf | Ingr.RAD2D.Application radApp; |
28 | d19ae675 | gaqhf | dynamic application; |
29 | 65881d60 | gaqhf | public ConverterDocking() |
30 | { |
||
31 | InitializeComponent(); |
||
32 | d19ae675 | gaqhf | application = Interaction.GetObject("", "PIDAutomation.Application"); |
33 | e3e2d41f | gaqhf | WrapperApplication wApp = new WrapperApplication(application.Application); |
34 | radApp = wApp.RADApplication; |
||
35 | 1ba9c671 | gaqhf | |
36 | #if DEBUG |
||
37 | simpleButton1.Visible = true; |
||
38 | #endif |
||
39 | 65881d60 | gaqhf | } |
40 | |||
41 | e3e2d41f | gaqhf | private void btnConverter_Click(object sender, EventArgs e) |
42 | 65881d60 | gaqhf | { |
43 | 1ba9c671 | gaqhf | ConverterForm converterForm = new ConverterForm(); |
44 | if (converterForm.ShowDialog() == DialogResult.OK) |
||
45 | 65881d60 | gaqhf | { |
46 | 1ba9c671 | gaqhf | |
47 | try |
||
48 | { |
||
49 | CloseOPCForm.Run(); |
||
50 | ca214bc3 | gaqhf | |
51 | d5ec4d0f | gaqhf | for (int i = 0; i < converterForm.Documents.Count; i++) |
52 | 1ba9c671 | gaqhf | { |
53 | d5ec4d0f | gaqhf | SPPID_Document document = converterForm.Documents[i]; |
54 | 1ba9c671 | gaqhf | if (document.SetSPPIDMapping() && document.Enable) |
55 | { |
||
56 | AutoModeling modeling = new AutoModeling(document, application, radApp); |
||
57 | d5ec4d0f | gaqhf | modeling.DocumentLabelText = string.Format("Drawing Name : {0} ({1}/{2})", document.DrawingName, i + 1, converterForm.Documents.Count); |
58 | 1ba9c671 | gaqhf | modeling.Run(); |
59 | } |
||
60 | } |
||
61 | } |
||
62 | catch (Exception ex) |
||
63 | { |
||
64 | MessageBox.Show(ex.Message + "\r\n" + ex.StackTrace); |
||
65 | } |
||
66 | finally |
||
67 | d19ae675 | gaqhf | { |
68 | 1ba9c671 | gaqhf | CloseOPCForm.Stop(); |
69 | } |
||
70 | |||
71 | MessageBox.Show(Msg.EndConvert, Msg.Information, MessageBoxButtons.OK, MessageBoxIcon.Information); |
||
72 | } |
||
73 | } |
||
74 | |||
75 | private void simpleButton1_Click(object sender, EventArgs e) |
||
76 | { |
||
77 | f31645b6 | gaqhf | //SPPIDSplashScreen s = new SPPIDSplashScreen(); |
78 | //s.ShowDialog(); |
||
79 | |||
80 | |||
81 | SplashScreenManager.ShowForm(typeof(SPPIDSplashScreen), true, true); |
||
82 | SplashScreenManager.Default.SendCommand(SPPIDSplashScreen.SplashScreenCommand.SetDocumentName, (IntPtr)radApp.HWnd); |
||
83 | // The splash screen will be opened in a separate thread. To interact with it, use the SendCommand method. |
||
84 | for (int i = 1; i <= 100; i++) |
||
85 | { |
||
86 | |||
87 | SplashScreenManager.Default.SendCommand(SPPIDSplashScreen.SplashScreenCommand.SetProgress, i); |
||
88 | //To process commands, override the SplashScreen.ProcessCommand method. |
||
89 | Thread.Sleep(100); |
||
90 | } |
||
91 | ca214bc3 | gaqhf | |
92 | f31645b6 | gaqhf | // Close the Splash Screen. |
93 | SplashScreenManager.CloseForm(false); |
||
94 | ca214bc3 | gaqhf | |
95 | f31645b6 | gaqhf | ////SetVisibleCore(false); |
96 | ca214bc3 | gaqhf | |
97 | f31645b6 | gaqhf | //SplashScreenWrapper wrapper = new SplashScreenWrapper(); |
98 | //wrapper.ShowDialog(); |
||
99 | ca214bc3 | gaqhf | |
100 | return; |
||
101 | |||
102 | 1ba9c671 | gaqhf | Placement _placement = new Placement(); |
103 | LMADataSource dataSource = _placement.PIDDataSource; |
||
104 | d19ae675 | gaqhf | |
105 | 1f1b3a40 | gaqhf | //double maxX = 0; |
106 | //double maxY = 0; |
||
107 | //foreach (object drawingObj in radApp.ActiveDocument.SelectSet) |
||
108 | //{ |
||
109 | // DependencyObject dd = drawingObj as DependencyObject; |
||
110 | // foreach (var attributes in dd.AttributeSets) |
||
111 | // { |
||
112 | // foreach (var item in attributes) |
||
113 | // { |
||
114 | // string name = item.Name; |
||
115 | // string value = item.GetValue().ToString(); |
||
116 | // } |
||
117 | // } |
||
118 | // if (dd != null) |
||
119 | // { |
||
120 | // LineString2d lineString2D = dd.DrawingObjects[4] as LineString2d; |
||
121 | // lineString2D.InsertVertex(lineString2D.VertexCount, 0.5, 0.5); |
||
122 | // lineString2D.RemoveVertex(lineString2D.VertexCount); |
||
123 | // } |
||
124 | //} |
||
125 | 1ba9c671 | gaqhf | |
126 | //DependencyObject drawingObject = radApp.ActiveSelectSet[0] as DependencyObject; |
||
127 | //foreach (var attributes in drawingObject.AttributeSets) |
||
128 | //{ |
||
129 | // foreach (var attribute in attributes) |
||
130 | // { |
||
131 | // if (attribute.Name == "ModelID") |
||
132 | // { |
||
133 | // LMModelItem modelItem = dataSource.GetModelItem(attribute.GetValue()); |
||
134 | // _LMAItem item = modelItem.AsLMAItem(); |
||
135 | // try |
||
136 | // { |
||
137 | // string modelitemID = item.Id; |
||
138 | // _placement.PIDAutoJoin(item, AutoJoinEndConstants.AutoJoin_None, ref item); |
||
139 | // string afterModelItemID = item.Id; |
||
140 | // item.Commit(); |
||
141 | // } |
||
142 | // catch (Exception ex) |
||
143 | // { |
||
144 | // System.Windows.Forms.MessageBox.Show(ex.Message + "\r\n" + ex.StackTrace); |
||
145 | // } |
||
146 | // } |
||
147 | // } |
||
148 | //} |
||
149 | 1f1b3a40 | gaqhf | |
150 | 1ba9c671 | gaqhf | Ingr.RAD2D.Symbol2d symbol2d = radApp.ActiveSelectSet[0] as Ingr.RAD2D.Symbol2d; |
151 | if (symbol2d != null) |
||
152 | 65881d60 | gaqhf | { |
153 | 1f1b3a40 | gaqhf | double minX; |
154 | double minY; |
||
155 | double maxX; |
||
156 | double maxY; |
||
157 | symbol2d.Range(out minX, out minY, out maxX, out maxY); |
||
158 | 1ba9c671 | gaqhf | |
159 | 1f1b3a40 | gaqhf | foreach (var attributes in symbol2d.AttributeSets) |
160 | 1ba9c671 | gaqhf | { |
161 | 1f1b3a40 | gaqhf | foreach (var attribute in attributes) |
162 | 1ba9c671 | gaqhf | { |
163 | 1f1b3a40 | gaqhf | string name = attribute.Name; |
164 | string value = attribute.GetValue().ToString(); |
||
165 | if (name == "ModelID") |
||
166 | { |
||
167 | string modelID = value; |
||
168 | LMModelItem modelItem = dataSource.GetModelItem(modelID); |
||
169 | foreach (LMRepresentation rep in modelItem.Representations) |
||
170 | { |
||
171 | if (rep.Attributes["RepresentationType"].get_Value() == "Symbol") |
||
172 | { |
||
173 | LMSymbol symbol = dataSource.GetSymbol(rep.Id); |
||
174 | |||
175 | double prevX = symbol.get_XCoordinate(); |
||
176 | double prevY = symbol.get_YCoordinate(); |
||
177 | 1ba9c671 | gaqhf | |
178 | |||
179 | 1f1b3a40 | gaqhf | } |
180 | } |
||
181 | } |
||
182 | 1ba9c671 | gaqhf | } |
183 | } |
||
184 | 1f1b3a40 | gaqhf | |
185 | |||
186 | 65881d60 | gaqhf | } |
187 | 1ba9c671 | gaqhf | |
188 | |||
189 | |||
190 | 65881d60 | gaqhf | } |
191 | } |
||
192 | } |