hytos / DTI_PID / SPPIDConverter / ConverterDocking.cs @ 229cfccb
이력 | 보기 | 이력해설 | 다운로드 (6.49 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 | 1ba9c671 | gaqhf | foreach (var document in converterForm.Documents) |
52 | { |
||
53 | if (document.SetSPPIDMapping() && document.Enable) |
||
54 | { |
||
55 | AutoModeling modeling = new AutoModeling(document, application, radApp); |
||
56 | modeling.Run(); |
||
57 | } |
||
58 | } |
||
59 | } |
||
60 | catch (Exception ex) |
||
61 | { |
||
62 | MessageBox.Show(ex.Message + "\r\n" + ex.StackTrace); |
||
63 | } |
||
64 | finally |
||
65 | d19ae675 | gaqhf | { |
66 | 1ba9c671 | gaqhf | CloseOPCForm.Stop(); |
67 | } |
||
68 | |||
69 | MessageBox.Show(Msg.EndConvert, Msg.Information, MessageBoxButtons.OK, MessageBoxIcon.Information); |
||
70 | } |
||
71 | } |
||
72 | |||
73 | private void simpleButton1_Click(object sender, EventArgs e) |
||
74 | { |
||
75 | ca214bc3 | gaqhf | //SplashScreenManager.ShowForm(typeof(SPPIDSplashScreen), true, true); |
76 | //// The splash screen will be opened in a separate thread. To interact with it, use the SendCommand method. |
||
77 | //for (int i = 1; i <= 100; i++) |
||
78 | //{ |
||
79 | // SplashScreenManager.Default.SendCommand(SPPIDSplashScreen.SplashScreenCommand.SetProgress, i); |
||
80 | // //To process commands, override the SplashScreen.ProcessCommand method. |
||
81 | // Thread.Sleep(25); |
||
82 | //} |
||
83 | |||
84 | //// Close the Splash Screen. |
||
85 | //SplashScreenManager.CloseForm(false); |
||
86 | |||
87 | //SetVisibleCore(false); |
||
88 | |||
89 | SplashScreenWrapper wrapper = new SplashScreenWrapper(); |
||
90 | wrapper.ShowDialog(); |
||
91 | |||
92 | return; |
||
93 | |||
94 | 1ba9c671 | gaqhf | Placement _placement = new Placement(); |
95 | LMADataSource dataSource = _placement.PIDDataSource; |
||
96 | d19ae675 | gaqhf | |
97 | 1f1b3a40 | gaqhf | //double maxX = 0; |
98 | //double maxY = 0; |
||
99 | //foreach (object drawingObj in radApp.ActiveDocument.SelectSet) |
||
100 | //{ |
||
101 | // DependencyObject dd = drawingObj as DependencyObject; |
||
102 | // foreach (var attributes in dd.AttributeSets) |
||
103 | // { |
||
104 | // foreach (var item in attributes) |
||
105 | // { |
||
106 | // string name = item.Name; |
||
107 | // string value = item.GetValue().ToString(); |
||
108 | // } |
||
109 | // } |
||
110 | // if (dd != null) |
||
111 | // { |
||
112 | // LineString2d lineString2D = dd.DrawingObjects[4] as LineString2d; |
||
113 | // lineString2D.InsertVertex(lineString2D.VertexCount, 0.5, 0.5); |
||
114 | // lineString2D.RemoveVertex(lineString2D.VertexCount); |
||
115 | // } |
||
116 | //} |
||
117 | 1ba9c671 | gaqhf | |
118 | //DependencyObject drawingObject = radApp.ActiveSelectSet[0] as DependencyObject; |
||
119 | //foreach (var attributes in drawingObject.AttributeSets) |
||
120 | //{ |
||
121 | // foreach (var attribute in attributes) |
||
122 | // { |
||
123 | // if (attribute.Name == "ModelID") |
||
124 | // { |
||
125 | // LMModelItem modelItem = dataSource.GetModelItem(attribute.GetValue()); |
||
126 | // _LMAItem item = modelItem.AsLMAItem(); |
||
127 | // try |
||
128 | // { |
||
129 | // string modelitemID = item.Id; |
||
130 | // _placement.PIDAutoJoin(item, AutoJoinEndConstants.AutoJoin_None, ref item); |
||
131 | // string afterModelItemID = item.Id; |
||
132 | // item.Commit(); |
||
133 | // } |
||
134 | // catch (Exception ex) |
||
135 | // { |
||
136 | // System.Windows.Forms.MessageBox.Show(ex.Message + "\r\n" + ex.StackTrace); |
||
137 | // } |
||
138 | // } |
||
139 | // } |
||
140 | //} |
||
141 | 1f1b3a40 | gaqhf | |
142 | 1ba9c671 | gaqhf | Ingr.RAD2D.Symbol2d symbol2d = radApp.ActiveSelectSet[0] as Ingr.RAD2D.Symbol2d; |
143 | if (symbol2d != null) |
||
144 | 65881d60 | gaqhf | { |
145 | 1f1b3a40 | gaqhf | double minX; |
146 | double minY; |
||
147 | double maxX; |
||
148 | double maxY; |
||
149 | symbol2d.Range(out minX, out minY, out maxX, out maxY); |
||
150 | 1ba9c671 | gaqhf | |
151 | 1f1b3a40 | gaqhf | foreach (var attributes in symbol2d.AttributeSets) |
152 | 1ba9c671 | gaqhf | { |
153 | 1f1b3a40 | gaqhf | foreach (var attribute in attributes) |
154 | 1ba9c671 | gaqhf | { |
155 | 1f1b3a40 | gaqhf | string name = attribute.Name; |
156 | string value = attribute.GetValue().ToString(); |
||
157 | if (name == "ModelID") |
||
158 | { |
||
159 | string modelID = value; |
||
160 | LMModelItem modelItem = dataSource.GetModelItem(modelID); |
||
161 | foreach (LMRepresentation rep in modelItem.Representations) |
||
162 | { |
||
163 | if (rep.Attributes["RepresentationType"].get_Value() == "Symbol") |
||
164 | { |
||
165 | LMSymbol symbol = dataSource.GetSymbol(rep.Id); |
||
166 | |||
167 | double prevX = symbol.get_XCoordinate(); |
||
168 | double prevY = symbol.get_YCoordinate(); |
||
169 | 1ba9c671 | gaqhf | |
170 | |||
171 | 1f1b3a40 | gaqhf | } |
172 | } |
||
173 | } |
||
174 | 1ba9c671 | gaqhf | } |
175 | } |
||
176 | 1f1b3a40 | gaqhf | |
177 | |||
178 | 65881d60 | gaqhf | } |
179 | 1ba9c671 | gaqhf | |
180 | |||
181 | |||
182 | 65881d60 | gaqhf | } |
183 | } |
||
184 | } |