hytos / DTI_PID / APIDConverter / ConverterRibbonUI.cs @ 5598104a
이력 | 보기 | 이력해설 | 다운로드 (3.53 KB)
1 | 74a0c9d6 | gaqhf | using System; |
---|---|---|---|
2 | using System.Collections.Generic; |
||
3 | using System.Linq; |
||
4 | using System.Text; |
||
5 | using System.Threading.Tasks; |
||
6 | |||
7 | using Autodesk.AutoCAD.ApplicationServices; |
||
8 | using Autodesk.AutoCAD.DatabaseServices; |
||
9 | using Autodesk.AutoCAD.EditorInput; |
||
10 | using Autodesk.AutoCAD.Geometry; |
||
11 | using Autodesk.AutoCAD.Interop; |
||
12 | using Autodesk.AutoCAD.Interop.Common; |
||
13 | using Autodesk.AutoCAD.Runtime; |
||
14 | using Autodesk.AutoCAD.Ribbon; |
||
15 | using Autodesk.Windows; |
||
16 | using Autodesk.Windows.ToolBars; |
||
17 | using AcadApp = Autodesk.AutoCAD.ApplicationServices.Application; |
||
18 | |||
19 | namespace AVEVA.PID.CustomizationUtility |
||
20 | { |
||
21 | public class ConverterRibbonUI |
||
22 | { |
||
23 | public static void InitUI() |
||
24 | { |
||
25 | RibbonControl ribbon = ComponentManager.Ribbon; |
||
26 | RibbonTab tab = ribbon.FindTab("APIDConverter"); |
||
27 | if (tab != null) |
||
28 | ribbon.Tabs.Remove(tab); |
||
29 | else |
||
30 | { |
||
31 | tab = new RibbonTab(); |
||
32 | tab.Title = "APID Converter"; |
||
33 | tab.Id = "APIDConverter"; |
||
34 | |||
35 | tab.Panels.Add(AddConverterPanel()); |
||
36 | dc270d65 | gaqhf | tab.Panels.Add(AddMappingPanel()); |
37 | 74a0c9d6 | gaqhf | |
38 | ribbon.Tabs.Insert(0, tab); |
||
39 | ribbon.ActiveTab = tab; |
||
40 | } |
||
41 | } |
||
42 | |||
43 | public static RibbonPanel AddConverterPanel() |
||
44 | { |
||
45 | RibbonButton rb; |
||
46 | RibbonPanelSource rps = new RibbonPanelSource(); |
||
47 | rps.Title = "APID Converter"; |
||
48 | RibbonPanel rp = new RibbonPanel(); |
||
49 | rp.Source = rps; |
||
50 | |||
51 | rb = new RibbonButton(); |
||
52 | rb.Name = "Converter"; |
||
53 | rb.ShowText = true; |
||
54 | rb.Text = "Converter"; |
||
55 | rb.CommandHandler = new RibbonCommandHandler(); |
||
56 | rb.CommandParameter = "ConverterForm"; |
||
57 | rps.Items.Add(rb); |
||
58 | |||
59 | rb = new RibbonButton(); |
||
60 | rb.Name = "Project Setting"; |
||
61 | rb.ShowText = true; |
||
62 | dc270d65 | gaqhf | rb.Text = "Project Setting"; |
63 | 74a0c9d6 | gaqhf | rb.CommandHandler = new RibbonCommandHandler(); |
64 | rb.CommandParameter = "ProjectForm"; |
||
65 | rps.Items.Add(rb); |
||
66 | return rp; |
||
67 | } |
||
68 | |||
69 | dc270d65 | gaqhf | public static RibbonPanel AddMappingPanel() |
70 | { |
||
71 | RibbonButton rb; |
||
72 | RibbonPanelSource rps = new RibbonPanelSource(); |
||
73 | rps.Title = "Mapping"; |
||
74 | RibbonPanel rp = new RibbonPanel(); |
||
75 | rp.Source = rps; |
||
76 | |||
77 | rb = new RibbonButton(); |
||
78 | rb.Name = "Mapping"; |
||
79 | rb.ShowText = true; |
||
80 | rb.Text = "Mapping"; |
||
81 | rb.CommandHandler = new RibbonCommandHandler(); |
||
82 | rb.CommandParameter = "MappingForm"; |
||
83 | rps.Items.Add(rb); |
||
84 | return rp; |
||
85 | } |
||
86 | |||
87 | 74a0c9d6 | gaqhf | public class RibbonCommandHandler : System.Windows.Input.ICommand |
88 | { |
||
89 | public event EventHandler CanExecuteChanged; |
||
90 | |||
91 | public bool CanExecute(object parameter) |
||
92 | { |
||
93 | RibbonCommandItem btn = parameter as RibbonCommandItem; |
||
94 | if (btn != null) |
||
95 | return true; |
||
96 | else |
||
97 | return false; |
||
98 | } |
||
99 | |||
100 | public void Execute(object parameter) |
||
101 | { |
||
102 | RibbonCommandItem btn = parameter as RibbonCommandItem; |
||
103 | |||
104 | if (btn != null) |
||
105 | { |
||
106 | //execute an AutoCAD command, or your custom command defined by [CommandMethod] |
||
107 | Document dwg = Application.DocumentManager.MdiActiveDocument; |
||
108 | dwg.SendStringToExecute((string)btn.CommandParameter + " ", true, false, true); |
||
109 | } |
||
110 | } |
||
111 | } |
||
112 | } |
||
113 | } |