zoukankan      html  css  js  c++  java
  • 使用C#语言,如何实现EPLAN二次开发 Api插件及菜单展示

    上期我们谈谈了谈EPLAN电气制图二次开发,制图软件EPLAN的安装和破解,今天我们来说说使用C#语言,如何实现Api插件及菜单,今天它来了!!!

    关于项目环境的搭建请参考:https://blog.csdn.net/Laity07/article/details/109215518

    下面我们一起来看看

    我们就以我写的一个例子来看

    首先建立一个这样的类,

    using Eplan.EplApi.ApplicationFramework;
    using Eplan.EplApi.DataModel;
    using Eplan.EplApi.HEServices;
    using Frm_Eplan_EplanApi;
    using Frm_Eplan_EplanApi.ViewModel;
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using System.Threading.Tasks;
    using System.Windows;
    using System.Windows.Forms;
    
    namespace Eplan_EplanApi
    {
        public class MyAction : IEplAction, IEplActionEnable
        {
            //public delegate //PathFileAcross pathFile;
            public bool Execute(ActionCallingContext ctx)
            {
                
                return true;
    
            }
    
            public bool OnRegister(ref string Name, ref int Ordinal)
            {
                Name = "功能配置";
                Ordinal = 20;
                return true;
            }
    
            public void GetActionProperties(ref ActionProperties actionProperties)
            {
                // actionProperties.Description = "Action test with parameters."; 
            }
    
            public bool Enabled(string strActionName, ActionCallingContext actionContext)
            { 
                return true;
            }
        }
    }
    MyAction

    第二步,我们再建一个这样的类

    using Eplan.EplApi.Base;
    using Eplan.EplApi.Gui;
    using System;
    using System.Collections.Generic;
    using System.Drawing;
    using System.Linq;
    using System.Reflection;
    using System.Text;
    using System.Threading.Tasks;
    using System.Windows.Forms;
    using ContextMenu = System.Windows.Forms.ContextMenu;
    
    namespace Eplan_EplanApi
    {
        public class AddInModule : Eplan.EplApi.ApplicationFramework.IEplAddIn
        {
            public bool OnExit()
            {
                return true;
            }
            public bool OnInit()
            {
                return true;
            }
    
            public bool OnInitGui()
            {
                //菜单栏菜单
                Eplan.EplApi.Gui.Menu oMenu = new Eplan.EplApi.Gui.Menu();
              //一级菜单
                uint num1 = oMenu.AddMainMenu("Test", Eplan.EplApi.Gui.Menu.MainMenuName.eMainMenuHelp, "项目配置", "MyAction", "项目配置", 0);
                
                
                #region 单功能配置显示二级菜单
                  //我们在一级菜单的基础上新增新的菜单,并在二级菜单显示新的子菜单
               //此处的“功能配置”为二级菜单名称
                uint menu3 = oMenu.AddPopupMenuItem("功能配置", "此处都为你二级菜单下子菜单的Action类(例如:电源进线)", "电源进线", "电源进线", num1, 1, false, false);
                oMenu.AddMenuItem("控制电源", "此处都为你二级菜单下子菜单的Action类(例如:控制电源)", "控制电源", menu3, 1, true, false); 
                #endregion 
                return true;
            }
    
            public bool OnRegister(ref bool bLoadOnStart)
            {
                bLoadOnStart = true;
                return true;
            }
    
            public bool OnUnregister()
            {
                return true;
            }
        }
    }
    AddInModule

    最后一定要把  右击-打开项目属性的程序集名称修改为这样的格式 EPLAN.EplAddin.MyAddIn

    这些都设置好了,我们下面看看将生成的.dll的程序集加载到EPLAN中后的效果吧

    最后这个东西吧,还是要好好阅读API文档,看懂了就明白了。

    https://blog.csdn.net/Laity07/article/details/109236645

    Nothing that has meaning is easy.
    凡是有意义的事都不简单。

  • 相关阅读:
    JavaScript对象模型执行模型
    jQuery+CSS实现的图片滚动效果
    js笔记作用域(执行上下文[execution context],活动对象) 闭包
    JavaScript中的值类型和引用类型
    程序员第一定律:关于技能与收入
    JavaScript 秘密花园 http://bonsaiden.github.com/JavaScriptGarden/zh/
    程序员三大世界观 如何看待HTML5
    10 条建议让你创建更好的 jQuery 插件
    html 打印
    面向对象的 Javascript (声明篇)
  • 原文地址:https://www.cnblogs.com/wj1107/p/13955961.html
Copyright © 2011-2022 走看看