프로젝트

일반

사용자정보

통계
| 개정판:

hytos / DTI_PID / SPPIDConverter / ConverterDocking.cs @ 2fdb56bf

이력 | 보기 | 이력해설 | 다운로드 (3.99 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
                    for (int i = 0; i < converterForm.Documents.Count; i++)
52
                    {
53
                        SPPID_Document document = converterForm.Documents[i];
54
                        if (document.SetSPPIDMapping() && document.Enable)
55
                        {
56
                            AutoModeling modeling = new AutoModeling(document, application, radApp);
57
                            modeling.DocumentLabelText = string.Format("Drawing Name : {0} ({1}/{2})", document.DrawingName, i + 1, converterForm.Documents.Count);
58
                            modeling.Run();
59
                        }
60
                    }
61
                }
62
                catch (Exception ex)
63
                {
64
                    MessageBox.Show(ex.Message + "\r\n" + ex.StackTrace);
65
                }
66
                finally
67
                {
68
                    CloseOPCForm.Stop();
69
                }
70

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

    
75
        private void simpleButton1_Click(object sender, EventArgs e)
76
        {
77
            Placement placement = new Placement();
78
            LMADataSource dataSource = placement.PIDDataSource;
79

    
80
            Ingr.RAD2D.Symbol2d symbol2d = radApp.ActiveSelectSet[0] as Ingr.RAD2D.Symbol2d;
81
            if (symbol2d != null)
82
            {
83
                double minX;
84
                double minY;
85
                double maxX;
86
                double maxY;
87
                symbol2d.Range(out minX, out minY, out maxX, out maxY);
88

    
89
                foreach (var attributes in symbol2d.AttributeSets)
90
                {
91
                    foreach (var attribute in attributes)
92
                    {
93
                        string name = attribute.Name;
94
                        string value = attribute.GetValue().ToString();
95
                        if (name == "ModelID")
96
                        {
97
                            string modelID = value;
98
                            LMModelItem modelItem = dataSource.GetModelItem(modelID);
99
                            foreach (LMRepresentation rep in modelItem.Representations)
100
                            {
101
                                if (rep.Attributes["RepresentationType"].get_Value() == "Symbol")
102
                                {
103
                                    LMSymbol symbol = dataSource.GetSymbol(rep.Id);
104

    
105
                                    double prevX = symbol.get_XCoordinate();
106
                                    double prevY = symbol.get_YCoordinate();
107

    
108

    
109
                                }
110
                            }
111
                        }
112
                    }
113
                }
114

    
115
               
116
            }
117
        }
118
    }
119
}
클립보드 이미지 추가 (최대 크기: 500 MB)