프로젝트

일반

사용자정보

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

hytos / DTI_PID / APIDConverter / APIDConverterExplorer.cs @ f71d5768

이력 | 보기 | 이력해설 | 다운로드 (4.32 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

    
11
using AcadApp = Autodesk.AutoCAD.ApplicationServices.Application;
12

    
13
using Autodesk.AutoCAD.ApplicationServices;
14
using Autodesk.AutoCAD.ApplicationServices.Core;
15
using Autodesk.AutoCAD.DatabaseServices;
16
using Autodesk.AutoCAD.EditorInput;
17

    
18
using AVEVA.PID.CustomizationUtility.DB;
19
using AVEVA.PID.CustomizationUtility.Model;
20
using AVEVA.PID.CustomizationUtility.Properties;
21

    
22
namespace AVEVA.PID.CustomizationUtility
23
{
24
    public partial class APIDConverterExplorer : UserControl
25
    {
26
        public APIDConverterExplorer()
27
        {
28
            InitializeComponent();
29

    
30
            textDrawingX.Text = Settings.Default.DrawingX.ToString();
31
            textDrawingY.Text = Settings.Default.DrawingY.ToString();
32
        }
33

    
34
        private void btnOpenConverter_Click(object sender, EventArgs e)
35
        {
36
            APIDConverter form = new APIDConverter();
37
            if (AcadApp.ShowModalDialog(form) == DialogResult.OK)
38
            {
39
                System.Data.DataTable avevaSymbolTable = Project_DB.SelectSymbolTable();
40

    
41
                foreach (var item in form.Documents)
42
                {
43
                    AutoModeling autoModeling = new AutoModeling(item, avevaSymbolTable);
44
                    autoModeling.CreateDrawing();
45
                }
46

    
47
                MessageBox.Show("End Conversion", "APID Converter", MessageBoxButtons.OK, MessageBoxIcon.Information);
48
            }
49
        }
50

    
51
        private void btnDrawingSize_Click(object sender, EventArgs e)
52
        {
53
            // Get the current document and database, and start a transaction
54
            Autodesk.AutoCAD.ApplicationServices.Document acDoc = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument;
55
            Database acCurDb = acDoc.Database;
56
            Editor acDocEd = acDoc.Editor;
57

    
58
            // Request for objects to be selected in the drawing area
59
            PromptSelectionResult acSSPrompt = acDocEd.GetSelection();
60

    
61
            // If the prompt status is OK, objects were selected
62
            if (acSSPrompt.Status == PromptStatus.OK)
63
            {
64
                ObjectId[] selectedObjectIds = acSSPrompt.Value.GetObjectIds();
65
                // Get the last selected entity
66

    
67
                if (selectedObjectIds.Length > 0)
68
                {
69
                    ObjectId objectId = selectedObjectIds[0];
70
                    using (Transaction acTrans = acCurDb.TransactionManager.StartTransaction())
71
                    {
72
                        Entity entity = acTrans.GetObject(objectId, OpenMode.ForRead, true) as Entity;
73
                        if (entity != null)
74
                        {
75
                            Extents3d extents = entity.GeometricExtents;
76
                            double width = extents.MaxPoint.X - extents.MinPoint.X;
77
                            double height = extents.MaxPoint.Y - extents.MinPoint.Y;
78

    
79
                            if (width == 0 || height == 0)
80
                            {
81
                                MessageBox.Show("Please select one rectangle", "APID Converter", MessageBoxButtons.OK, MessageBoxIcon.Error);
82
                                return;
83
                            }
84

    
85
                            Settings.Default.DrawingX = width;
86
                            Settings.Default.DrawingY = height;
87
                            Settings.Default.Save();
88
                            textDrawingX.Text = Settings.Default.DrawingX.ToString();
89
                            textDrawingY.Text = Settings.Default.DrawingY.ToString();
90

    
91
                            MessageBox.Show("End Drawing Size Setting", "APID Converter", MessageBoxButtons.OK, MessageBoxIcon.Information);
92
                        }
93
                        else
94
                        {
95
                            MessageBox.Show("Please select one rectangle", "APID Converter", MessageBoxButtons.OK, MessageBoxIcon.Error);
96
                        }
97
                        acTrans.Commit();
98
                    }
99
                }
100
                else
101
                {
102
                    MessageBox.Show("Please select one rectangle", "APID Converter", MessageBoxButtons.OK, MessageBoxIcon.Error);
103
                }
104
            }
105
        }
106
    }
107
}
클립보드 이미지 추가 (최대 크기: 500 MB)