C#在PDMS中创建按钮

Addins.cs

using Aveva.ApplicationFramework;
using Aveva.ApplicationFramework.Presentation;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Drawing;
using System.Windows.Forms;

namespace PDMSPlugin
{
    public class Addins : IAddin
    {
        public string Description
        {
            get { return "Addins"; }
        }

        public string Name
        {
            get { return "Addins"; }
        }

        private static ServiceManager sServiceManager;
        private static CommandManager sCommandManager;
        private static CommandBarManager sCommandBarManager;

        public void Start(ServiceManager serviceManager)
        {
            sServiceManager = serviceManager;
            sCommandManager = (CommandManager)sServiceManager.GetService(typeof(CommandManager));
            sCommandBarManager = (CommandBarManager)sServiceManager.GetService(typeof(CommandBarManager));

            sCommandManager.Commands.Add(new LoadButton());
            //sCommandManager.Commands.Add(new MySecondButton());
            //sCommandManager.Commands.Add(new MyList());
            //sCommandManager.Commands.Add(new MyMenu());

            //Key,名称,图标,ID
            ButtonTool button = sCommandBarManager.RootTools.AddButtonTool("ButtonKey", "按钮", null, "ButtonKey");
            //ButtonTool button2 = sCommandBarManager.RootTools.AddButtonTool("Second", "MySecondButton", null, "Second");
            //ComboBoxTool List1 = sCommandBarManager.RootTools.AddComboBoxTool("List", "Example", null, "List");
            //MenuTool menu1 = sCommandBarManager.RootTools.AddMenuTool("MyMenu", "ExampleMenu", null, "MyMenu");

            CommandBar myTools = sCommandBarManager.CommandBars.AddCommandBar("PDMSPlugin");

            myTools.Tools.AddTool("ButtonKey");
            //myTools.Tools.AddTool("Second");
            //myTools.Tools.AddTool("List");
            //myTools.Tools.AddTool("MyMenu");
        }

        public void Stop()
        {
            throw new NotImplementedException();
        }
    }
}

LoadButton.cs

using Aveva.ApplicationFramework.Presentation;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace PDMSPlugin
{
    class LoadButton : Command
    {
        public LoadButton()
        {
            this.Key = "ButtonKey";
        }
        public override void Execute()
        {
            //执行按钮功能
        }
    }
}

猜你喜欢

转载自blog.csdn.net/u013179508/article/details/142562960