프로젝트

일반

사용자정보

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

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

이력 | 보기 | 이력해설 | 다운로드 (6.93 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 System.IO;
12
using Microsoft.VisualBasic;
13
using Ingr.RAD2D;
14
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
using Plaice;
21
using Llama;
22
using DevExpress.XtraSplashScreen;
23

    
24
namespace Converter.SPPID.Wrapper
25
{
26
    public partial class ConverterDocking : UserControl
27
    {
28
        Ingr.RAD2D.Application radApp;
29
        dynamic application;
30
        public ConverterDocking()
31
        {
32
            InitializeComponent();
33
            application = Interaction.GetObject("", "PIDAutomation.Application");
34
            WrapperApplication wApp = new WrapperApplication(application.Application);
35
            radApp = wApp.RADApplication;
36

    
37
            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
#if DEBUG
52
            simpleButton1.Visible = true;
53

    
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
#endif
65
        }
66

    
67
        private void btnConverter_Click(object sender, EventArgs e)
68
        {
69
            ConverterForm converterForm = new ConverterForm();
70
            if (converterForm.ShowDialog() == DialogResult.OK)
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 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
        private void btnGetDrawingSize_Click(object sender, EventArgs e)
122
        {
123
            if (radApp.ActiveSelectSet.Count > 0)
124
            {
125
                DependencyObject line2D = radApp.ActiveSelectSet[0] as DependencyObject;
126
                if (line2D != null)
127
                {
128
                    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
                }
141
                else
142
                    MessageBox.Show(Msg.SelectLine, Msg.Warning, MessageBoxButtons.OK, MessageBoxIcon.Warning);
143
            }
144
            else
145
                MessageBox.Show(Msg.SelectLine, Msg.Warning, MessageBoxButtons.OK, MessageBoxIcon.Warning);
146
        }
147

    
148
        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
        private void simpleButton1_Click(object sender, EventArgs e)
158
        {
159
            Placement _placement = new Placement();
160
            LMADataSource dataSource = new LMADataSource();//placement.PIDDataSource;
161

    
162
            string modelItemId = "B79C53F295454F489B9DBCD9F1078D3E";
163
            LMOPC opc = dataSource.GetOPC(modelItemId);
164
            try
165
            {
166
                if (opc != null)
167
                {
168
                    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
                }
173
            }
174
            catch (Exception ex)
175
            {
176
                System.Windows.Forms.MessageBox.Show(ex.Message + "\r\n" + ex.StackTrace);
177
            }
178
            finally
179
            {
180

    
181
            }
182

    
183
            if (radApp.ActiveSelectSet.Count > 0)
184
            {
185
                DependencyObject line2D = radApp.ActiveSelectSet[0] as DependencyObject;
186
                if (line2D != null)
187
                {
188
                    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

    
201
                }
202
                else
203
                    MessageBox.Show(Msg.SelectLine, Msg.Warning, MessageBoxButtons.OK, MessageBoxIcon.Warning);
204
            }
205
            else
206
                MessageBox.Show(Msg.SelectLine, Msg.Warning, MessageBoxButtons.OK, MessageBoxIcon.Warning);
207
            
208
        }
209

    
210
        
211
    }
212
}
클립보드 이미지 추가 (최대 크기: 500 MB)