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