프로젝트

일반

사용자정보

통계
| 브랜치(Branch): | 개정판:

hytos / DTI_PID / SPPIDConverter / ConverterDocking.cs @ 69b7387a

이력 | 보기 | 이력해설 | 다운로드 (6.93 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 69b7387a gaqhf
using System.IO;
12 65881d60 gaqhf
using Microsoft.VisualBasic;
13 e3e2d41f gaqhf
using Ingr.RAD2D;
14 d19ae675 gaqhf
using Converter.BaseModel;
15
using Converter.SPPID.Properties;
16
using Converter.SPPID.DB;
17
using Converter.SPPID.Util;
18
using Converter.SPPID.Form;
19
using Converter.SPPID.Model;
20 1ba9c671 gaqhf
using Plaice;
21
using Llama;
22 ca214bc3 gaqhf
using DevExpress.XtraSplashScreen;
23 65881d60 gaqhf
24
namespace Converter.SPPID.Wrapper
25
{
26
    public partial class ConverterDocking : UserControl
27
    {
28 e3e2d41f gaqhf
        Ingr.RAD2D.Application radApp;
29 d19ae675 gaqhf
        dynamic application;
30 65881d60 gaqhf
        public ConverterDocking()
31
        {
32
            InitializeComponent();
33 d19ae675 gaqhf
            application = Interaction.GetObject("", "PIDAutomation.Application");
34 e3e2d41f gaqhf
            WrapperApplication wApp = new WrapperApplication(application.Application);
35
            radApp = wApp.RADApplication;
36 1ba9c671 gaqhf
37 6a7573b0 gaqhf
            try
38
            {
39
                textEditDrawingX.EditValue = Settings.Default.DrawingX;
40
                textEditDrawingY.EditValue = Settings.Default.DrawingY;
41
            }
42
            catch (Exception ex)
43
            {
44
                StringBuilder sb = new StringBuilder();
45
                sb.AppendLine(ex.Message);
46
                sb.AppendLine(ex.StackTrace);
47
                MessageBox.Show(sb.ToString());
48
            }
49
            
50
51 1ba9c671 gaqhf
#if DEBUG
52
            simpleButton1.Visible = true;
53 51ae61b9 gaqhf
54
            Project_Info _ProjectInfo = Project_Info.GetInstance();
55
            _ProjectInfo.DefaultPath = Settings.Default.LatestProjectPath;
56
            if (Project_DB.ConnTestAndCreateTable())
57
            {
58
                
59
            }
60
            else
61
            {
62
63
            }
64 1ba9c671 gaqhf
#endif
65 65881d60 gaqhf
        }
66
67 e3e2d41f gaqhf
        private void btnConverter_Click(object sender, EventArgs e)
68 65881d60 gaqhf
        {
69 1ba9c671 gaqhf
            ConverterForm converterForm = new ConverterForm();
70
            if (converterForm.ShowDialog() == DialogResult.OK)
71 65881d60 gaqhf
            {
72 1ba9c671 gaqhf
                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 69b7387a gaqhf
        private void btnLinkOPC_Click(object sender, EventArgs e)
101
        {
102
            try
103
            {
104
                LMADataSource dataSource = new LMADataSource();
105
                LMDrawings drawings = new LMDrawings();
106
                drawings.Collect(dataSource);
107
108
                foreach (LMDrawing item in drawings)
109
                {
110
111
                    
112
                }
113
114
            }
115
            catch (Exception ex)
116
            {
117
                MessageBox.Show(ex.Message + "\r\n" + ex.StackTrace);
118
            }
119
        }
120
121 6a7573b0 gaqhf
        private void btnGetDrawingSize_Click(object sender, EventArgs e)
122 1ba9c671 gaqhf
        {
123 6a7573b0 gaqhf
            if (radApp.ActiveSelectSet.Count > 0)
124 65881d60 gaqhf
            {
125 6a7573b0 gaqhf
                DependencyObject line2D = radApp.ActiveSelectSet[0] as DependencyObject;
126
                if (line2D != null)
127 1ba9c671 gaqhf
                {
128 6a7573b0 gaqhf
                    double minX = 0;
129
                    double minY = 0;
130
                    double maxX = 0;
131
                    double maxY = 0;
132
                    line2D.Range(out minX, out minY, out maxX, out maxY);
133
134
                    Settings.Default.DrawingX = maxX - minX;
135
                    Settings.Default.DrawingY = maxY - minY;
136
                    Settings.Default.Save();
137
138
                    textEditDrawingX.EditValue = Settings.Default.DrawingX;
139
                    textEditDrawingY.EditValue = Settings.Default.DrawingY;
140 1ba9c671 gaqhf
                }
141 6a7573b0 gaqhf
                else
142
                    MessageBox.Show(Msg.SelectLine, Msg.Warning, MessageBoxButtons.OK, MessageBoxIcon.Warning);
143 65881d60 gaqhf
            }
144 6a7573b0 gaqhf
            else
145
                MessageBox.Show(Msg.SelectLine, Msg.Warning, MessageBoxButtons.OK, MessageBoxIcon.Warning);
146
        }
147
148 02480ac1 gaqhf
        static Command command;
149
        int CmdID;
150
        string CmdCLSID;
151
        bool isActiveInPlace;
152
        CommandTypeConstants CommandTypeConstants;
153
        string argList;
154
        string DLLName;
155
        string HelpFile;
156
157 6a7573b0 gaqhf
        private void simpleButton1_Click(object sender, EventArgs e)
158
        {
159 1ab9a205 gaqhf
            Placement _placement = new Placement();
160 6a7573b0 gaqhf
            LMADataSource dataSource = new LMADataSource();//placement.PIDDataSource;
161
162 69b7387a gaqhf
            string modelItemId = "B79C53F295454F489B9DBCD9F1078D3E";
163
            LMOPC opc = dataSource.GetOPC(modelItemId);
164 1ab9a205 gaqhf
            try
165 02480ac1 gaqhf
            {
166 69b7387a gaqhf
                if (opc != null)
167 02480ac1 gaqhf
                {
168 69b7387a gaqhf
                    LMOPC pairedOPC = opc.pairedWithOPCObject;
169
                    //MessageBox.Show(pairedOPC.get_ItemStatus());
170
                    //pairedOPC.Attributes[]
171
                    _placement.PIDPlaceSymbol(@"\Piping\Piping OPC's\Off-Drawing.sym", 0, 0, 0, 0, pairedOPC.AsLMAItem());
172 02480ac1 gaqhf
                }
173 1ab9a205 gaqhf
            }
174
            catch (Exception ex)
175
            {
176
                System.Windows.Forms.MessageBox.Show(ex.Message + "\r\n" + ex.StackTrace);
177
            }
178
            finally
179
            {
180 02480ac1 gaqhf
181 1ab9a205 gaqhf
            }
182
183
            if (radApp.ActiveSelectSet.Count > 0)
184
            {
185
                DependencyObject line2D = radApp.ActiveSelectSet[0] as DependencyObject;
186
                if (line2D != null)
187 02480ac1 gaqhf
                {
188 1ab9a205 gaqhf
                    double minX = 0;
189
                    double minY = 0;
190
                    double maxX = 0;
191
                    double maxY = 0;
192
                    line2D.Range(out minX, out minY, out maxX, out maxY);
193
194
                    StringBuilder sb = new StringBuilder();
195
                    sb.AppendLine(minX.ToString());
196
                    sb.AppendLine(minY.ToString());
197
                    sb.AppendLine(maxX.ToString());
198
                    sb.AppendLine(maxY.ToString());
199
                    MessageBox.Show(sb.ToString());
200 02480ac1 gaqhf
201
                }
202 1ab9a205 gaqhf
                else
203
                    MessageBox.Show(Msg.SelectLine, Msg.Warning, MessageBoxButtons.OK, MessageBoxIcon.Warning);
204 02480ac1 gaqhf
            }
205 1ab9a205 gaqhf
            else
206
                MessageBox.Show(Msg.SelectLine, Msg.Warning, MessageBoxButtons.OK, MessageBoxIcon.Warning);
207 69b7387a gaqhf
            
208 65881d60 gaqhf
        }
209 6a7573b0 gaqhf
210
        
211 65881d60 gaqhf
    }
212
}
클립보드 이미지 추가 (최대 크기: 500 MB)