hytos / DTI_PID / SPPIDConverter / ConverterDocking.cs @ 6a7573b0
이력 | 보기 | 이력해설 | 다운로드 (7.16 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 |
try |
37 |
{ |
38 |
textEditDrawingX.EditValue = Settings.Default.DrawingX; |
39 |
textEditDrawingY.EditValue = Settings.Default.DrawingY; |
40 |
} |
41 |
catch (Exception ex) |
42 |
{ |
43 |
StringBuilder sb = new StringBuilder(); |
44 |
sb.AppendLine(ex.Message); |
45 |
sb.AppendLine(ex.StackTrace); |
46 |
MessageBox.Show(sb.ToString()); |
47 |
} |
48 |
|
49 |
|
50 |
#if DEBUG |
51 |
simpleButton1.Visible = true; |
52 |
|
53 |
Project_Info _ProjectInfo = Project_Info.GetInstance(); |
54 |
_ProjectInfo.DefaultPath = Settings.Default.LatestProjectPath; |
55 |
if (Project_DB.ConnTestAndCreateTable()) |
56 |
{ |
57 |
|
58 |
} |
59 |
else |
60 |
{ |
61 |
|
62 |
} |
63 |
#endif |
64 |
} |
65 |
|
66 |
private void btnConverter_Click(object sender, EventArgs e) |
67 |
{ |
68 |
ConverterForm converterForm = new ConverterForm(); |
69 |
if (converterForm.ShowDialog() == DialogResult.OK) |
70 |
{ |
71 |
|
72 |
try |
73 |
{ |
74 |
CloseOPCForm.Run(); |
75 |
|
76 |
for (int i = 0; i < converterForm.Documents.Count; i++) |
77 |
{ |
78 |
SPPID_Document document = converterForm.Documents[i]; |
79 |
if (document.SetSPPIDMapping() && document.Enable) |
80 |
{ |
81 |
AutoModeling modeling = new AutoModeling(document, application, radApp); |
82 |
modeling.DocumentLabelText = string.Format("Drawing Name : {0} ({1}/{2})", document.DrawingName, i + 1, converterForm.Documents.Count); |
83 |
modeling.Run(); |
84 |
} |
85 |
} |
86 |
} |
87 |
catch (Exception ex) |
88 |
{ |
89 |
MessageBox.Show(ex.Message + "\r\n" + ex.StackTrace); |
90 |
} |
91 |
finally |
92 |
{ |
93 |
CloseOPCForm.Stop(); |
94 |
} |
95 |
|
96 |
MessageBox.Show(Msg.EndConvert, Msg.Information, MessageBoxButtons.OK, MessageBoxIcon.Information); |
97 |
} |
98 |
} |
99 |
|
100 |
private void btnGetDrawingSize_Click(object sender, EventArgs e) |
101 |
{ |
102 |
if (radApp.ActiveSelectSet.Count > 0) |
103 |
{ |
104 |
DependencyObject line2D = radApp.ActiveSelectSet[0] as DependencyObject; |
105 |
if (line2D != null) |
106 |
{ |
107 |
double minX = 0; |
108 |
double minY = 0; |
109 |
double maxX = 0; |
110 |
double maxY = 0; |
111 |
line2D.Range(out minX, out minY, out maxX, out maxY); |
112 |
|
113 |
Settings.Default.DrawingX = maxX - minX; |
114 |
Settings.Default.DrawingY = maxY - minY; |
115 |
Settings.Default.Save(); |
116 |
|
117 |
textEditDrawingX.EditValue = Settings.Default.DrawingX; |
118 |
textEditDrawingY.EditValue = Settings.Default.DrawingY; |
119 |
} |
120 |
else |
121 |
MessageBox.Show(Msg.SelectLine, Msg.Warning, MessageBoxButtons.OK, MessageBoxIcon.Warning); |
122 |
} |
123 |
else |
124 |
MessageBox.Show(Msg.SelectLine, Msg.Warning, MessageBoxButtons.OK, MessageBoxIcon.Warning); |
125 |
} |
126 |
|
127 |
private void simpleButton1_Click(object sender, EventArgs e) |
128 |
{ |
129 |
Placement placement = new Placement(); |
130 |
LMADataSource dataSource = new LMADataSource();//placement.PIDDataSource; |
131 |
|
132 |
placement.PIDPlaceSymbol(@"\Instrumentation\Relief Devices\Press Relief Valve.sym", 0, 0, Mirror: 0); |
133 |
placement.PIDPlaceSymbol(@"\Instrumentation\Relief Devices\Press Relief Valve.sym", 0.03, 0, Mirror: 1); |
134 |
//placement.PIDPlaceSymbol("", 0.06, 0, Mirror: 2); |
135 |
//Ingr.RAD2D.Symbol2d symbol2d = radApp.ActiveSelectSet[0] as Ingr.RAD2D.Symbol2d; |
136 |
//if (symbol2d != null) |
137 |
//{ |
138 |
// double minX; |
139 |
// double minY; |
140 |
// double maxX; |
141 |
// double maxY; |
142 |
// symbol2d.Range(out minX, out minY, out maxX, out maxY); |
143 |
|
144 |
// foreach (var attributes in symbol2d.AttributeSets) |
145 |
// { |
146 |
// foreach (var attribute in attributes) |
147 |
// { |
148 |
// string name = attribute.Name; |
149 |
// string value = attribute.GetValue().ToString(); |
150 |
// if (name == "ModelID") |
151 |
// { |
152 |
// string modelID = value; |
153 |
// LMModelItem modelItem = dataSource.GetModelItem(modelID); |
154 |
// foreach (LMRepresentation rep in modelItem.Representations) |
155 |
// { |
156 |
// if (rep.Attributes["RepresentationType"].get_Value() == "Symbol") |
157 |
// { |
158 |
// LMSymbol symbol = dataSource.GetSymbol(rep.Id); |
159 |
|
160 |
// List<double[]> points = new List<double[]>(); |
161 |
// StringBuilder sb = new StringBuilder(); |
162 |
// for (int i = 1; i < int.MaxValue; i++) |
163 |
// { |
164 |
// double connX = 0; |
165 |
// double connY = 0; |
166 |
// if (placement.PIDConnectPointLocation(symbol, i, ref connX, ref connY)) |
167 |
// { |
168 |
// points.Add(new double[] { connX, connY }); |
169 |
// sb.AppendLine(i + " / " + connX + " / " + connY); |
170 |
// } |
171 |
// else |
172 |
// break; |
173 |
// } |
174 |
|
175 |
// double prevX = symbol.get_XCoordinate(); |
176 |
// double prevY = symbol.get_YCoordinate(); |
177 |
|
178 |
// MessageBox.Show(sb.ToString()); |
179 |
// } |
180 |
// } |
181 |
// } |
182 |
// } |
183 |
// } |
184 |
|
185 |
|
186 |
//} |
187 |
} |
188 |
|
189 |
|
190 |
} |
191 |
} |