hytos / DTI_PID / SPPIDConverter / ConverterDocking.cs @ 6a7573b0
이력 | 보기 | 이력해설 | 다운로드 (7.16 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 | 6a7573b0 | gaqhf | 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 | 1ba9c671 | gaqhf | #if DEBUG |
51 | simpleButton1.Visible = true; |
||
52 | 51ae61b9 | gaqhf | |
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 | 1ba9c671 | gaqhf | #endif |
64 | 65881d60 | gaqhf | } |
65 | |||
66 | e3e2d41f | gaqhf | private void btnConverter_Click(object sender, EventArgs e) |
67 | 65881d60 | gaqhf | { |
68 | 1ba9c671 | gaqhf | ConverterForm converterForm = new ConverterForm(); |
69 | if (converterForm.ShowDialog() == DialogResult.OK) |
||
70 | 65881d60 | gaqhf | { |
71 | 1ba9c671 | gaqhf | |
72 | try |
||
73 | { |
||
74 | CloseOPCForm.Run(); |
||
75 | ca214bc3 | gaqhf | |
76 | d5ec4d0f | gaqhf | for (int i = 0; i < converterForm.Documents.Count; i++) |
77 | 1ba9c671 | gaqhf | { |
78 | d5ec4d0f | gaqhf | SPPID_Document document = converterForm.Documents[i]; |
79 | 1ba9c671 | gaqhf | if (document.SetSPPIDMapping() && document.Enable) |
80 | { |
||
81 | AutoModeling modeling = new AutoModeling(document, application, radApp); |
||
82 | d5ec4d0f | gaqhf | modeling.DocumentLabelText = string.Format("Drawing Name : {0} ({1}/{2})", document.DrawingName, i + 1, converterForm.Documents.Count); |
83 | 1ba9c671 | gaqhf | modeling.Run(); |
84 | } |
||
85 | } |
||
86 | } |
||
87 | catch (Exception ex) |
||
88 | { |
||
89 | MessageBox.Show(ex.Message + "\r\n" + ex.StackTrace); |
||
90 | } |
||
91 | finally |
||
92 | d19ae675 | gaqhf | { |
93 | 1ba9c671 | gaqhf | CloseOPCForm.Stop(); |
94 | } |
||
95 | |||
96 | MessageBox.Show(Msg.EndConvert, Msg.Information, MessageBoxButtons.OK, MessageBoxIcon.Information); |
||
97 | } |
||
98 | } |
||
99 | |||
100 | 6a7573b0 | gaqhf | private void btnGetDrawingSize_Click(object sender, EventArgs e) |
101 | 1ba9c671 | gaqhf | { |
102 | 6a7573b0 | gaqhf | if (radApp.ActiveSelectSet.Count > 0) |
103 | 65881d60 | gaqhf | { |
104 | 6a7573b0 | gaqhf | DependencyObject line2D = radApp.ActiveSelectSet[0] as DependencyObject; |
105 | if (line2D != null) |
||
106 | 1ba9c671 | gaqhf | { |
107 | 6a7573b0 | gaqhf | 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 | 1ba9c671 | gaqhf | } |
120 | 6a7573b0 | gaqhf | else |
121 | MessageBox.Show(Msg.SelectLine, Msg.Warning, MessageBoxButtons.OK, MessageBoxIcon.Warning); |
||
122 | 65881d60 | gaqhf | } |
123 | 6a7573b0 | gaqhf | 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 | 65881d60 | gaqhf | } |
188 | 6a7573b0 | gaqhf | |
189 | |||
190 | 65881d60 | gaqhf | } |
191 | } |