프로젝트

일반

사용자정보

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

hytos / DTI_PID / SPPIDConverter / ConverterDocking.cs @ f31645b6

이력 | 보기 | 이력해설 | 다운로드 (6.71 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
                    foreach (var document in converterForm.Documents)
52
                    {
53
                        if (document.SetSPPIDMapping() && document.Enable)
54
                        {
55
                            AutoModeling modeling = new AutoModeling(document, application, radApp);
56
                            modeling.Run();
57
                        }
58
                    }
59
                }
60
                catch (Exception ex)
61
                {
62
                    MessageBox.Show(ex.Message + "\r\n" + ex.StackTrace);
63
                }
64
                finally
65
                {
66
                    CloseOPCForm.Stop();
67
                }
68

    
69
                MessageBox.Show(Msg.EndConvert, Msg.Information, MessageBoxButtons.OK, MessageBoxIcon.Information);
70
            }
71
        }
72

    
73
        private void simpleButton1_Click(object sender, EventArgs e)
74
        {
75
            //SPPIDSplashScreen s = new SPPIDSplashScreen();
76
            //s.ShowDialog();
77

    
78

    
79
            SplashScreenManager.ShowForm(typeof(SPPIDSplashScreen), true, true);
80
            SplashScreenManager.Default.SendCommand(SPPIDSplashScreen.SplashScreenCommand.SetDocumentName, (IntPtr)radApp.HWnd);
81
            // The splash screen will be opened in a separate thread. To interact with it, use the SendCommand method.
82
            for (int i = 1; i <= 100; i++)
83
            {
84
                
85
                SplashScreenManager.Default.SendCommand(SPPIDSplashScreen.SplashScreenCommand.SetProgress, i);
86
                //To process commands, override the SplashScreen.ProcessCommand method.
87
                Thread.Sleep(100);
88
            }
89

    
90
            // Close the Splash Screen.
91
            SplashScreenManager.CloseForm(false);
92

    
93
            ////SetVisibleCore(false);
94

    
95
            //SplashScreenWrapper wrapper = new SplashScreenWrapper();
96
            //wrapper.ShowDialog();
97

    
98
            return;
99

    
100
            Placement _placement = new Placement();
101
            LMADataSource dataSource = _placement.PIDDataSource;
102

    
103
            //double maxX = 0;
104
            //double maxY = 0;
105
            //foreach (object drawingObj in radApp.ActiveDocument.SelectSet)
106
            //{
107
            //    DependencyObject dd = drawingObj as DependencyObject;
108
            //    foreach (var attributes in dd.AttributeSets)
109
            //    {
110
            //        foreach (var item in attributes)
111
            //        {
112
            //            string name = item.Name;
113
            //            string value = item.GetValue().ToString();
114
            //        }
115
            //    }
116
            //    if (dd != null)
117
            //    {
118
            //        LineString2d lineString2D = dd.DrawingObjects[4] as LineString2d;
119
            //        lineString2D.InsertVertex(lineString2D.VertexCount, 0.5, 0.5);
120
            //        lineString2D.RemoveVertex(lineString2D.VertexCount);
121
            //    }
122
            //}
123

    
124
            //DependencyObject drawingObject = radApp.ActiveSelectSet[0] as DependencyObject;
125
            //foreach (var attributes in drawingObject.AttributeSets)
126
            //{
127
            //    foreach (var attribute in attributes)
128
            //    {
129
            //        if (attribute.Name == "ModelID")
130
            //        {
131
            //            LMModelItem modelItem = dataSource.GetModelItem(attribute.GetValue());
132
            //            _LMAItem item = modelItem.AsLMAItem();
133
            //            try
134
            //            {
135
            //                string modelitemID = item.Id;
136
            //                _placement.PIDAutoJoin(item, AutoJoinEndConstants.AutoJoin_None, ref item);
137
            //                string afterModelItemID = item.Id;
138
            //                item.Commit();
139
            //            }
140
            //            catch (Exception ex)
141
            //            {
142
            //                System.Windows.Forms.MessageBox.Show(ex.Message + "\r\n" + ex.StackTrace);
143
            //            }
144
            //        }
145
            //    }
146
            //}
147

    
148
            Ingr.RAD2D.Symbol2d symbol2d = radApp.ActiveSelectSet[0] as Ingr.RAD2D.Symbol2d;
149
            if (symbol2d != null)
150
            {
151
                double minX;
152
                double minY;
153
                double maxX;
154
                double maxY;
155
                symbol2d.Range(out minX, out minY, out maxX, out maxY);
156

    
157
                foreach (var attributes in symbol2d.AttributeSets)
158
                {
159
                    foreach (var attribute in attributes)
160
                    {
161
                        string name = attribute.Name;
162
                        string value = attribute.GetValue().ToString();
163
                        if (name == "ModelID")
164
                        {
165
                            string modelID = value;
166
                            LMModelItem modelItem = dataSource.GetModelItem(modelID);
167
                            foreach (LMRepresentation rep in modelItem.Representations)
168
                            {
169
                                if (rep.Attributes["RepresentationType"].get_Value() == "Symbol")
170
                                {
171
                                    LMSymbol symbol = dataSource.GetSymbol(rep.Id);
172

    
173
                                    double prevX = symbol.get_XCoordinate();
174
                                    double prevY = symbol.get_YCoordinate();
175

    
176

    
177
                                }
178
                            }
179
                        }
180
                    }
181
                }
182

    
183
               
184
            }
185

    
186

    
187

    
188
        }
189
    }
190
}
클립보드 이미지 추가 (최대 크기: 500 MB)