hytos / DTI_PID / SPPIDConverter / ConverterDocking.cs @ ca214bc3
이력 | 보기 | 이력해설 | 다운로드 (6.49 KB)
1 |
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 |
using Ingr.RAD2D; |
13 |
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 |
using Plaice; |
20 |
using Llama; |
21 |
using DevExpress.XtraSplashScreen; |
22 |
|
23 |
namespace Converter.SPPID.Wrapper |
24 |
{ |
25 |
public partial class ConverterDocking : UserControl |
26 |
{ |
27 |
Ingr.RAD2D.Application radApp; |
28 |
dynamic application; |
29 |
public ConverterDocking() |
30 |
{ |
31 |
InitializeComponent(); |
32 |
application = Interaction.GetObject("", "PIDAutomation.Application"); |
33 |
WrapperApplication wApp = new WrapperApplication(application.Application); |
34 |
radApp = wApp.RADApplication; |
35 |
|
36 |
#if DEBUG |
37 |
simpleButton1.Visible = true; |
38 |
#endif |
39 |
} |
40 |
|
41 |
private void btnConverter_Click(object sender, EventArgs e) |
42 |
{ |
43 |
ConverterForm converterForm = new ConverterForm(); |
44 |
if (converterForm.ShowDialog() == DialogResult.OK) |
45 |
{ |
46 |
|
47 |
try |
48 |
{ |
49 |
CloseOPCForm.Run(); |
50 |
|
51 |
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 |
{ |
66 |
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 |
//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 |
Placement _placement = new Placement(); |
95 |
LMADataSource dataSource = _placement.PIDDataSource; |
96 |
|
97 |
//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 |
|
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 |
|
142 |
Ingr.RAD2D.Symbol2d symbol2d = radApp.ActiveSelectSet[0] as Ingr.RAD2D.Symbol2d; |
143 |
if (symbol2d != null) |
144 |
{ |
145 |
double minX; |
146 |
double minY; |
147 |
double maxX; |
148 |
double maxY; |
149 |
symbol2d.Range(out minX, out minY, out maxX, out maxY); |
150 |
|
151 |
foreach (var attributes in symbol2d.AttributeSets) |
152 |
{ |
153 |
foreach (var attribute in attributes) |
154 |
{ |
155 |
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 |
|
170 |
|
171 |
} |
172 |
} |
173 |
} |
174 |
} |
175 |
} |
176 |
|
177 |
|
178 |
} |
179 |
|
180 |
|
181 |
|
182 |
} |
183 |
} |
184 |
} |