프로젝트

일반

사용자정보

통계
| 개정판:

hytos / DTI_PID / APIDConverter / ConverterRibbonUI.cs @ 31cd836b

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