hytos / DTI_PID / SPPIDConverter / ConverterDocking.cs @ b93e7eef
이력 | 보기 | 이력해설 | 다운로드 (6.95 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 |
for (int i = 0; i < converterForm.Documents.Count; i++) |
52 |
{ |
53 |
SPPID_Document document = converterForm.Documents[i]; |
54 |
if (document.SetSPPIDMapping() && document.Enable) |
55 |
{ |
56 |
AutoModeling modeling = new AutoModeling(document, application, radApp); |
57 |
modeling.DocumentLabelText = string.Format("Drawing Name : {0} ({1}/{2})", document.DrawingName, i + 1, converterForm.Documents.Count); |
58 |
modeling.Run(); |
59 |
} |
60 |
} |
61 |
} |
62 |
catch (Exception ex) |
63 |
{ |
64 |
MessageBox.Show(ex.Message + "\r\n" + ex.StackTrace); |
65 |
} |
66 |
finally |
67 |
{ |
68 |
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 |
//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 |
|
92 |
// Close the Splash Screen. |
93 |
SplashScreenManager.CloseForm(false); |
94 |
|
95 |
////SetVisibleCore(false); |
96 |
|
97 |
//SplashScreenWrapper wrapper = new SplashScreenWrapper(); |
98 |
//wrapper.ShowDialog(); |
99 |
|
100 |
return; |
101 |
|
102 |
Placement _placement = new Placement(); |
103 |
LMADataSource dataSource = _placement.PIDDataSource; |
104 |
|
105 |
//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 |
|
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 |
|
150 |
Ingr.RAD2D.Symbol2d symbol2d = radApp.ActiveSelectSet[0] as Ingr.RAD2D.Symbol2d; |
151 |
if (symbol2d != null) |
152 |
{ |
153 |
double minX; |
154 |
double minY; |
155 |
double maxX; |
156 |
double maxY; |
157 |
symbol2d.Range(out minX, out minY, out maxX, out maxY); |
158 |
|
159 |
foreach (var attributes in symbol2d.AttributeSets) |
160 |
{ |
161 |
foreach (var attribute in attributes) |
162 |
{ |
163 |
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 |
|
178 |
|
179 |
} |
180 |
} |
181 |
} |
182 |
} |
183 |
} |
184 |
|
185 |
|
186 |
} |
187 |
|
188 |
|
189 |
|
190 |
} |
191 |
} |
192 |
} |