프로젝트

일반

사용자정보

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

hytos / DTI_PID / APIDConverter / APIDConverterExplorer.cs @ 87f22597

이력 | 보기 | 이력해설 | 다운로드 (4.61 KB)

1 88cb9898 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
11 09a2e00c gaqhf
using AcadApp = Autodesk.AutoCAD.ApplicationServices.Application;
12 f71d5768 gaqhf
13
using Autodesk.AutoCAD.ApplicationServices;
14
using Autodesk.AutoCAD.ApplicationServices.Core;
15
using Autodesk.AutoCAD.DatabaseServices;
16
using Autodesk.AutoCAD.EditorInput;
17
18 09a2e00c gaqhf
using AVEVA.PID.CustomizationUtility.DB;
19
using AVEVA.PID.CustomizationUtility.Model;
20
using AVEVA.PID.CustomizationUtility.Properties;
21
22 88cb9898 gaqhf
namespace AVEVA.PID.CustomizationUtility
23
{
24
    public partial class APIDConverterExplorer : UserControl
25
    {
26
        public APIDConverterExplorer()
27
        {
28
            InitializeComponent();
29 f71d5768 gaqhf
30
            textDrawingX.Text = Settings.Default.DrawingX.ToString();
31
            textDrawingY.Text = Settings.Default.DrawingY.ToString();
32 88cb9898 gaqhf
        }
33 09a2e00c gaqhf
34
        private void btnOpenConverter_Click(object sender, EventArgs e)
35
        {
36 932933ed gaqhf
            
37 09a2e00c gaqhf
            APIDConverter form = new APIDConverter();
38
            if (AcadApp.ShowModalDialog(form) == DialogResult.OK)
39
            {
40 932933ed gaqhf
                try
41 14540282 gaqhf
                {
42 c94252bf gaqhf
                    AvevaThread.Run(ThreadType.DuplicationWarning);
43 932933ed gaqhf
                    foreach (var item in form.Documents)
44
                    {
45 dfb760ef gaqhf
                        AutoModeling autoModeling = new AutoModeling(item);
46 932933ed gaqhf
                        autoModeling.CreateDrawing();
47
                    }
48 c94252bf gaqhf
                    AvevaThread.Stop(ThreadType.DuplicationWarning);
49 932933ed gaqhf
                    MessageBox.Show("End Conversion", "APID Converter", MessageBoxButtons.OK, MessageBoxIcon.Information);
50 14540282 gaqhf
                }
51 932933ed gaqhf
                catch (Exception ex)
52
                {
53 73152510 gaqhf
54 932933ed gaqhf
                }
55
                finally
56
                {
57 c8b025e0 gaqhf
                    
58 932933ed gaqhf
                }
59
                
60 09a2e00c gaqhf
            }
61
        }
62 f71d5768 gaqhf
63
        private void btnDrawingSize_Click(object sender, EventArgs e)
64
        {
65
            // Get the current document and database, and start a transaction
66
            Autodesk.AutoCAD.ApplicationServices.Document acDoc = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument;
67
            Database acCurDb = acDoc.Database;
68
            Editor acDocEd = acDoc.Editor;
69
70
            // Request for objects to be selected in the drawing area
71
            PromptSelectionResult acSSPrompt = acDocEd.GetSelection();
72
73
            // If the prompt status is OK, objects were selected
74
            if (acSSPrompt.Status == PromptStatus.OK)
75
            {
76
                ObjectId[] selectedObjectIds = acSSPrompt.Value.GetObjectIds();
77
                // Get the last selected entity
78
79
                if (selectedObjectIds.Length > 0)
80
                {
81
                    ObjectId objectId = selectedObjectIds[0];
82
                    using (Transaction acTrans = acCurDb.TransactionManager.StartTransaction())
83
                    {
84
                        Entity entity = acTrans.GetObject(objectId, OpenMode.ForRead, true) as Entity;
85
                        if (entity != null)
86
                        {
87
                            Extents3d extents = entity.GeometricExtents;
88
                            double width = extents.MaxPoint.X - extents.MinPoint.X;
89
                            double height = extents.MaxPoint.Y - extents.MinPoint.Y;
90
91
                            if (width == 0 || height == 0)
92
                            {
93
                                MessageBox.Show("Please select one rectangle", "APID Converter", MessageBoxButtons.OK, MessageBoxIcon.Error);
94
                                return;
95
                            }
96
97
                            Settings.Default.DrawingX = width;
98
                            Settings.Default.DrawingY = height;
99
                            Settings.Default.Save();
100
                            textDrawingX.Text = Settings.Default.DrawingX.ToString();
101
                            textDrawingY.Text = Settings.Default.DrawingY.ToString();
102
103
                            MessageBox.Show("End Drawing Size Setting", "APID Converter", MessageBoxButtons.OK, MessageBoxIcon.Information);
104
                        }
105
                        else
106
                        {
107
                            MessageBox.Show("Please select one rectangle", "APID Converter", MessageBoxButtons.OK, MessageBoxIcon.Error);
108
                        }
109
                        acTrans.Commit();
110
                    }
111
                }
112
                else
113
                {
114
                    MessageBox.Show("Please select one rectangle", "APID Converter", MessageBoxButtons.OK, MessageBoxIcon.Error);
115
                }
116
            }
117
        }
118 88cb9898 gaqhf
    }
119
}
클립보드 이미지 추가 (최대 크기: 500 MB)