hytos / DTI_PID / APIDConverter / APIDConverterExplorer.cs @ f71d5768
이력 | 보기 | 이력해설 | 다운로드 (4.32 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 | APIDConverter form = new APIDConverter(); |
||
37 | if (AcadApp.ShowModalDialog(form) == DialogResult.OK) |
||
38 | { |
||
39 | f71d5768 | gaqhf | System.Data.DataTable avevaSymbolTable = Project_DB.SelectSymbolTable(); |
40 | 495bb8f5 | gaqhf | |
41 | 14540282 | gaqhf | foreach (var item in form.Documents) |
42 | { |
||
43 | 495bb8f5 | gaqhf | AutoModeling autoModeling = new AutoModeling(item, avevaSymbolTable); |
44 | 1c5bd296 | gaqhf | autoModeling.CreateDrawing(); |
45 | 14540282 | gaqhf | } |
46 | 73152510 | gaqhf | |
47 | MessageBox.Show("End Conversion", "APID Converter", MessageBoxButtons.OK, MessageBoxIcon.Information); |
||
48 | 09a2e00c | gaqhf | } |
49 | } |
||
50 | f71d5768 | gaqhf | |
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 | 88cb9898 | gaqhf | } |
107 | } |