프로젝트

일반

사용자정보

통계
| 개정판:

hytos / DTI_PID / APIDConverter / ConverterRibbonUI.cs @ 74a0c9d6

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

1
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

    
37
                ribbon.Tabs.Insert(0, tab);
38
                ribbon.ActiveTab = tab;
39
            }
40
        }
41

    
42
        public static RibbonPanel AddConverterPanel()
43
        {
44
            RibbonButton rb;
45
            RibbonPanelSource rps = new RibbonPanelSource();
46
            rps.Title = "APID Converter";
47
            RibbonPanel rp = new RibbonPanel();
48
            rp.Source = rps;
49

    
50
            rb = new RibbonButton();
51
            rb.Name = "Converter";
52
            rb.ShowText = true;
53
            rb.Text = "Converter";
54
            rb.CommandHandler = new RibbonCommandHandler();
55
            rb.CommandParameter = "ConverterForm";
56
            rps.Items.Add(rb);
57

    
58
            rb = new RibbonButton();
59
            rb.Name = "Project Setting";
60
            rb.ShowText = true;
61
            rb.Text = "Project\nSetting";
62
            rb.CommandHandler = new RibbonCommandHandler();
63
            rb.CommandParameter = "ProjectForm";
64
            rps.Items.Add(rb);
65
            return rp;
66
        }
67

    
68
        public class RibbonCommandHandler : System.Windows.Input.ICommand
69
        {
70
            public event EventHandler CanExecuteChanged;
71

    
72
            public bool CanExecute(object parameter)
73
            {
74
                RibbonCommandItem btn = parameter as RibbonCommandItem;
75
                if (btn != null)
76
                    return true;
77
                else
78
                    return false;
79
            }
80

    
81
            public void Execute(object parameter)
82
            {
83
                RibbonCommandItem btn = parameter as RibbonCommandItem;
84

    
85
                if (btn != null)
86
                {
87
                    //execute an AutoCAD command, or your custom command defined by [CommandMethod]
88
                    Document dwg = Application.DocumentManager.MdiActiveDocument;
89
                    dwg.SendStringToExecute((string)btn.CommandParameter + " ", true, false, true);
90
                }
91
            }
92
        }
93
    }
94
}
클립보드 이미지 추가 (최대 크기: 500 MB)