private void AddCmdbox(List <Dictionary <int, KeyValuePair <CommandType, int> > > tabIdList, ref ICommandGroup cmdGroup, ref CommandTab cmdTab)
        {
            int index = 0;

            foreach (var boxIds in tabIdList)
            {
                List <int> cmdIDs   = new List <int>();
                List <int> TextType = new List <int>();

                CommandTabBox cmdBox = cmdTab.AddCommandTabBox();
                foreach (var cmdId in boxIds)
                {
                    switch (cmdId.Value.Key)
                    {
                    case CommandType.Command:
                        cmdIDs.Add(cmdGroup.get_CommandID(cmdId.Key));
                        break;

                    case CommandType.FlyoutCommand:
                        cmdIDs.Add(cmdId.Key);
                        break;
                    }
                    TextType.Add(cmdId.Value.Value);
                    index++;
                }
                bool result = cmdBox.AddCommands(cmdIDs.ToArray(), TextType.ToArray());
            }
        }
Esempio n. 2
0
        /// <summary>
        /// /Создание нового таббокса
        /// </summary>
        /// <param name="cmdTab">Лента Союз-PLM</param>
        private static void CreateNewTab(CommandTab cmdTab)
        {
            CommandTabBox cmdBox  = cmdTab.AddCommandTabBox();
            bool          bResult = cmdBox.AddCommands(cmdIDs, TextType);

            Debug.Print(bResult.ToString());
            cmdTab.Active = true;
        }
        public void SetupCommands()
        {
            BitmapHandler imageManager = new BitmapHandler();
            Assembly thisAssembly;
            int cmdIndex0, cmdIndex1, cmdIndex2, cmdIndex3, cmdIndex4, cmdIndex5;
            string Title = "Gazebo", ToolTip = "Tools for exporting this assembly as a robot for simulation in Gazebo";

            int cmdGroupErr = 0;
            bool ignorePrevious = false;

            object registryIDs;
            //get the ID information stored in the registry
            bool getDataResult = iCmdMgr.GetGroupDataFromRegistry(cmdGroupID, out registryIDs);

            int[] knownIDs = new int[3] {settingsItemID, manageRobotItemID, exportItemID};

            if (getDataResult)
            {
                if (!CompareIDs((int[])registryIDs, knownIDs)) //if the IDs don't match, reset the commandGroup
                {
                    ignorePrevious = true;
                }
            }
            ignorePrevious = true;

            //Get a reference to the current assembly and load bitmaps form it into a new command group
            thisAssembly = System.Reflection.Assembly.GetAssembly(this.GetType());
            cmdGroup = iCmdMgr.CreateCommandGroup2(cmdGroupID, Title, ToolTip, "", -1, ignorePrevious, ref cmdGroupErr);
            cmdGroup.LargeIconList = imageManager.CreateFileFromResourceBitmap("GazeboExporter.Images.ToolbarLarge.bmp", thisAssembly);
            cmdGroup.SmallIconList = imageManager.CreateFileFromResourceBitmap("GazeboExporter.Images.ToolbarSmall.bmp", thisAssembly);
            cmdGroup.LargeMainIcon = imageManager.CreateFileFromResourceBitmap("GazeboExporter.Images.MainIconLarge.bmp", thisAssembly);
            cmdGroup.SmallMainIcon = imageManager.CreateFileFromResourceBitmap("GazeboExporter.Images.MainIconSmall.bmp", thisAssembly);
            GazeboLogo = Image.FromFile(imageManager.CreateFileFromResourceBitmap("GazeboExporter.Images.Gazebo.png", thisAssembly));
            MotorPic = Image.FromFile(imageManager.CreateFileFromResourceBitmap("GazeboExporter.Images.motor.png", thisAssembly));
            EncoderPic = Image.FromFile(imageManager.CreateFileFromResourceBitmap("GazeboExporter.Images.QuadratureEncoder.png", thisAssembly));
            PotPic = Image.FromFile(imageManager.CreateFileFromResourceBitmap("GazeboExporter.Images.AnalogPotentiometer.png", thisAssembly));
            GyroPic = Image.FromFile(imageManager.CreateFileFromResourceBitmap("GazeboExporter.Images.Gyro.png", thisAssembly));
            RangefinderPic = Image.FromFile(imageManager.CreateFileFromResourceBitmap("GazeboExporter.Images.Ultrasonic.png", thisAssembly));
            CameraPic = Image.FromFile(imageManager.CreateFileFromResourceBitmap("GazeboExporter.Images.Camera.png", thisAssembly));
            ExtLimitSwitchPic = Image.FromFile(imageManager.CreateFileFromResourceBitmap("GazeboExporter.Images.LimitSwitch_E.png", thisAssembly));
            IntLimitSwitchPic = Image.FromFile(imageManager.CreateFileFromResourceBitmap("GazeboExporter.Images.LimitSwitch_I.png", thisAssembly));
            PistonPic = Image.FromFile(imageManager.CreateFileFromResourceBitmap("GazeboExporter.Images.Piston.png", thisAssembly));
            NewLinkPic = Image.FromFile(imageManager.CreateFileFromResourceBitmap("GazeboExporter.Images.NewLinkIcon.png", thisAssembly));
            NewJointPic = Image.FromFile(imageManager.CreateFileFromResourceBitmap("GazeboExporter.Images.NewJointIcon.png", thisAssembly));

            int menuToolbarOption = (int)(swCommandItemType_e.swMenuItem | swCommandItemType_e.swToolbarItem);
            cmdIndex3 = cmdGroup.AddCommandItem2("Exporter Settings", -1, "Change exporter plugin settings", "Exporter settings", 0, "settingsCB", "settingsEN", settingsItemID, menuToolbarOption);
            cmdIndex4 = cmdGroup.AddCommandItem2("Manage Robot", -1, "Manage robot paramters", "Manage Robot", 1, "manageRobotCB", "manageRobotEN", manageRobotItemID, menuToolbarOption);
            cmdIndex5 = cmdGroup.AddCommandItem2("Export", -1, "Save this robot as a Gazebo package", "Export", 2, "exportCB", "exportEN", exportItemID, menuToolbarOption);

            cmdGroup.HasToolbar = true;
            cmdGroup.HasMenu = true;
            cmdGroup.Activate();

            cmdTab = iCmdMgr.GetCommandTab((int)swDocumentTypes_e.swDocASSEMBLY, Title);

            if (cmdTab != null & !getDataResult | ignorePrevious)//if tab exists, but we have ignored the registry info (or changed command group ID), re-create the tab.  Otherwise the ids won't matchup and the tab will be blank
            {
                bool res = iCmdMgr.RemoveCommandTab(cmdTab);
                cmdTab = null;
            }

            //if cmdTab is null, must be first load (possibly after reset), add the commands to the tabs
            if (cmdTab == null)
            {
                cmdTab = iCmdMgr.AddCommandTab((int)swDocumentTypes_e.swDocASSEMBLY, Title);

                cmdBox = cmdTab.AddCommandTabBox();

                int[] cmdIDs = new int[3];
                int[] TextType = new int[3];

                cmdIDs[0] = cmdGroup.get_CommandID(cmdIndex3);
                cmdIDs[1] = cmdGroup.get_CommandID(cmdIndex4);
                cmdIDs[2] = cmdGroup.get_CommandID(cmdIndex5);

                TextType[0] = (int)swCommandTabButtonTextDisplay_e.swCommandTabButton_TextBelow;
                TextType[1] = (int)swCommandTabButtonTextDisplay_e.swCommandTabButton_TextBelow;
                TextType[2] = (int)swCommandTabButtonTextDisplay_e.swCommandTabButton_TextBelow;
                /*int[] cmdIDs = new int[2];
                int[] TextType = new int[2];

                cmdIDs[0] = cmdGroup.get_CommandID(cmdIndex4);
                cmdIDs[1] = cmdGroup.get_CommandID(cmdIndex5);

                TextType[0] = (int)swCommandTabButtonTextDisplay_e.swCommandTabButton_TextBelow;
                TextType[1] = (int)swCommandTabButtonTextDisplay_e.swCommandTabButton_TextBelow;*/

                cmdBox.AddCommands(cmdIDs, TextType);
            }

            thisAssembly = null;
            imageManager.Dispose();
        }
Esempio n. 4
0
        public void AddCommandMgr()
        {
            ICommandGroup cmdGroup;

            if (iBmp == null)
            {
                iBmp = new BitmapHandler();
            }
            Assembly thisAssembly;
            int      cmdIndex0, cmdIndex1;
            string   Title = "C# Addin", ToolTip = "C# Addin";


            int[] docTypes = new int[] { (int)swDocumentTypes_e.swDocASSEMBLY,
                                         (int)swDocumentTypes_e.swDocDRAWING,
                                         (int)swDocumentTypes_e.swDocPART };

            thisAssembly = System.Reflection.Assembly.GetAssembly(this.GetType());


            int  cmdGroupErr    = 0;
            bool ignorePrevious = false;

            object registryIDs;
            //get the ID information stored in the registry
            bool getDataResult = iCmdMgr.GetGroupDataFromRegistry(mainCmdGroupID, out registryIDs);

            int[] knownIDs = new int[2] {
                mainItemID1, mainItemID2
            };

            if (getDataResult)
            {
                if (!CompareIDs((int[])registryIDs, knownIDs)) //if the IDs don't match, reset the commandGroup
                {
                    ignorePrevious = true;
                }
            }

            cmdGroup = iCmdMgr.CreateCommandGroup2(mainCmdGroupID, Title, ToolTip, "", -1, ignorePrevious, ref cmdGroupErr);
            cmdGroup.LargeIconList = iBmp.CreateFileFromResourceBitmap("SolidWorks_AddIn_Example.ToolbarLarge.bmp", thisAssembly);
            cmdGroup.SmallIconList = iBmp.CreateFileFromResourceBitmap("SolidWorks_AddIn_Example.ToolbarSmall.bmp", thisAssembly);
            cmdGroup.LargeMainIcon = iBmp.CreateFileFromResourceBitmap("SolidWorks_AddIn_Example.MainIconLarge.bmp", thisAssembly);
            cmdGroup.SmallMainIcon = iBmp.CreateFileFromResourceBitmap("SolidWorks_AddIn_Example.MainIconSmall.bmp", thisAssembly);

            int menuToolbarOption = (int)(swCommandItemType_e.swMenuItem | swCommandItemType_e.swToolbarItem);

            cmdIndex0 = cmdGroup.AddCommandItem2("CreateCube", -1, "Create a cube", "Create cube", 0, "CreateCube", "", mainItemID1, menuToolbarOption);
            cmdIndex1 = cmdGroup.AddCommandItem2("Show PMP", -1, "Display sample property manager", "Show PMP", 2, "ShowPMP", "EnablePMP", mainItemID2, menuToolbarOption);

            cmdGroup.HasToolbar = true;
            cmdGroup.HasMenu    = true;
            cmdGroup.Activate();

            bool bResult;



            FlyoutGroup flyGroup = iCmdMgr.CreateFlyoutGroup(flyoutGroupID, "Dynamic Flyout", "Flyout Tooltip", "Flyout Hint",
                                                             cmdGroup.SmallMainIcon, cmdGroup.LargeMainIcon, cmdGroup.SmallIconList, cmdGroup.LargeIconList, "FlyoutCallback", "FlyoutEnable");


            flyGroup.AddCommandItem("FlyoutCommand 1", "test", 0, "FlyoutCommandItem1", "FlyoutEnableCommandItem1");

            flyGroup.FlyoutType = (int)swCommandFlyoutStyle_e.swCommandFlyoutStyle_Simple;


            foreach (int type in docTypes)
            {
                CommandTab cmdTab;

                cmdTab = iCmdMgr.GetCommandTab(type, Title);

                if (cmdTab != null & !getDataResult | ignorePrevious)//if tab exists, but we have ignored the registry info (or changed command group ID), re-create the tab.  Otherwise the ids won't matchup and the tab will be blank
                {
                    bool res = iCmdMgr.RemoveCommandTab(cmdTab);
                    cmdTab = null;
                }

                //if cmdTab is null, must be first load (possibly after reset), add the commands to the tabs
                if (cmdTab == null)
                {
                    cmdTab = iCmdMgr.AddCommandTab(type, Title);

                    CommandTabBox cmdBox = cmdTab.AddCommandTabBox();

                    int[] cmdIDs   = new int[3];
                    int[] TextType = new int[3];

                    cmdIDs[0] = cmdGroup.get_CommandID(cmdIndex0);

                    TextType[0] = (int)swCommandTabButtonTextDisplay_e.swCommandTabButton_TextHorizontal;

                    cmdIDs[1] = cmdGroup.get_CommandID(cmdIndex1);

                    TextType[1] = (int)swCommandTabButtonTextDisplay_e.swCommandTabButton_TextHorizontal;

                    cmdIDs[2] = cmdGroup.ToolbarId;

                    TextType[2] = (int)swCommandTabButtonTextDisplay_e.swCommandTabButton_TextHorizontal | (int)swCommandTabButtonFlyoutStyle_e.swCommandTabButton_ActionFlyout;

                    bResult = cmdBox.AddCommands(cmdIDs, TextType);



                    CommandTabBox cmdBox1 = cmdTab.AddCommandTabBox();
                    cmdIDs   = new int[1];
                    TextType = new int[1];

                    cmdIDs[0]   = flyGroup.CmdID;
                    TextType[0] = (int)swCommandTabButtonTextDisplay_e.swCommandTabButton_TextBelow | (int)swCommandTabButtonFlyoutStyle_e.swCommandTabButton_ActionFlyout;

                    bResult = cmdBox1.AddCommands(cmdIDs, TextType);

                    cmdTab.AddSeparator(cmdBox1, cmdIDs[0]);
                }
            }
            thisAssembly = null;
        }
Esempio n. 5
0
        public void CreerOnglet()
        {
            try
            {
                foreach (eTypeDoc T in Enum.GetValues(typeof(eTypeDoc)))
                {
                    var Liste = new List <List <Cmde> >();

                    // Liste les cmds à afficher dans cet onglet pour ce type de document
                    foreach (var listeCmd in ListeGrp)
                    {
                        var liste = new List <Cmde>();
                        foreach (var Cmd in listeCmd)
                        {
                            if (Cmd.Type.HasFlag(T))
                            {
                                liste.Add(Cmd);
                            }
                        }

                        if (liste.Count > 0)
                        {
                            Liste.Add(liste);
                        }
                    }

                    // Si la liste comprend des cmds
                    if (Liste.Count > 0)
                    {
                        CommandTab cmdTab = CmdMgr.GetCommandTab((int)Sw.eGetSwTypeDoc(T), Titre);
                        if (cmdTab.IsRef())
                        {
                            CmdMgr.RemoveCommandTab(cmdTab);
                        }

                        cmdTab = CmdMgr.AddCommandTab((int)Sw.eGetSwTypeDoc(T), Titre);

                        Boolean sep = false;

                        foreach (var ListeCmd in Liste)
                        {
                            var ListeId       = new List <int>();
                            var ListePosition = new List <int>();

                            // Liste les cmds, on recupère les Id et la position des textes
                            foreach (var Cmd in ListeCmd)
                            {
                                ListeId.Add(Cmd.CommandId);
                                ListePosition.Add((int)Cmd.PositionTexte);
                            }

                            // On ajoute les cmds
                            CommandTabBox cmdBox = cmdTab.AddCommandTabBox();
                            cmdBox.AddCommands(ListeId.ToArray(), ListePosition.ToArray());

                            // Si c'est le deuxième groupe, on ajoute un séparateur
                            // !!!! On ne peut ajouter un séparateur que devant un nouveau CommandTabBox
                            if (sep)
                            {
                                cmdTab.AddSeparator(cmdBox, ListeId[0]);
                            }

                            sep = true;
                        }
                    }
                }
            }
            catch (Exception e)
            { this.LogMethode(new Object[] { e }); }
        }
Esempio n. 6
0
        /// <summary>
        /// 添加命令栏
        /// </summary>
        public void AddCommandMgr()
        {
            ICommandGroup cmdGroup;

            if (iBmp == null)
            {
                iBmp = new BitmapHandler();
            }
            Assembly thisAssembly;
            int      cmdIndex0;
            int      cmdIndex1;
            int      cmdIndex2;
            int      cmdIndex3;
            int      cmdIndex4;
            string   Title = "ZQ插件", ToolTip = "ZQ插件";

            int[] docTypes = new int[] { (int)swDocumentTypes_e.swDocASSEMBLY, (int)swDocumentTypes_e.swDocDRAWING, (int)swDocumentTypes_e.swDocPART };
            thisAssembly = System.Reflection.Assembly.GetAssembly(this.GetType());

            int  cmdGroupErr    = 0;
            bool ignorePrevious = false;

            object registryIDs;
            //get the ID information stored in the registry
            bool getDataResult = iCmdMgr.GetGroupDataFromRegistry(mainCmdGroupID, out registryIDs);

            int[] knownIDs = new int[5] {
                mainItemID1, mainItemID2, mainItemID3, mainItemID4, mainItemID5
            };

            if (getDataResult)
            {
                //if the IDs don't match, reset the commandGroup
                if (!CompareIDs((int[])registryIDs, knownIDs))
                {
                    ignorePrevious = true;
                }
            }
            //定义图标的显示(SwCSharpAddin1.icon.ToolbarLarge.bmp代表项目目录,→)
            cmdGroup = iCmdMgr.CreateCommandGroup2(mainCmdGroupID, Title, ToolTip, "", -1, ignorePrevious, ref cmdGroupErr);
            cmdGroup.LargeIconList = iBmp.CreateFileFromResourceBitmap("ZQaddin.icon.ToolbarLarge.bmp", thisAssembly);
            cmdGroup.SmallIconList = iBmp.CreateFileFromResourceBitmap("ZQaddin.icon.ToolbarSmall.bmp", thisAssembly);
            cmdGroup.LargeMainIcon = iBmp.CreateFileFromResourceBitmap("ZQaddin.icon.MainIconLarge.bmp", thisAssembly);
            cmdGroup.SmallMainIcon = iBmp.CreateFileFromResourceBitmap("ZQaddin.icon.MainIconSmall.bmp", thisAssembly);

            int menuToolbarOption = (int)(swCommandItemType_e.swMenuItem | swCommandItemType_e.swToolbarItem);

            //工具栏1:申请编码
            cmdIndex0 = cmdGroup.AddCommandItem2("申请编码", -1, "申请编码", "申请编码", 0, "GetMyCode", "申请编码", mainItemID1, menuToolbarOption);
            //工具栏2:打印图纸
            cmdIndex1 = cmdGroup.AddCommandItem2("打印图纸", -1, "打印图纸", "打印图纸", 1, "MyPrinter", "打印图纸", mainItemID5, menuToolbarOption);
            //工具栏3:查找缺失文件
            cmdIndex2 = cmdGroup.AddCommandItem2("查找缺失文件", -1, "查找缺失文件", "查找缺失文件", 2, "MySearch", "查找缺失文件", mainItemID3, menuToolbarOption);
            //工具栏4:模型打包
            cmdIndex3 = cmdGroup.AddCommandItem2("模型打包", -1, "模型打包", "模型打包", 3, "MyPackage", "模型打包", mainItemID4, menuToolbarOption);

            cmdGroup.HasToolbar = true; //显示工具栏
            cmdGroup.HasMenu    = true; //显示菜单栏
            cmdGroup.Activate();

            bool bResult;

            foreach (int type in docTypes)
            {
                CommandTab cmdTab;

                cmdTab = iCmdMgr.GetCommandTab(type, Title);

                if (cmdTab != null & !getDataResult | ignorePrevious)//if tab exists, but we have ignored the registry info (or changed command group ID), re-create the tab.  Otherwise the ids won't matchup and the tab will be blank
                {
                    bool res = iCmdMgr.RemoveCommandTab(cmdTab);
                    cmdTab = null;
                }

                //if cmdTab is null, must be first load (possibly after reset), add the commands to the tabs
                if (cmdTab == null)
                {
                    cmdTab = iCmdMgr.AddCommandTab(type, Title);

                    CommandTabBox cmdBox = cmdTab.AddCommandTabBox();

                    int[] cmdIDs   = new int[5];
                    int[] TextType = new int[5];
                    //工具栏1
                    cmdIDs[0]   = cmdGroup.get_CommandID(cmdIndex0);
                    TextType[0] = (int)swCommandTabButtonTextDisplay_e.swCommandTabButton_TextBelow;
                    //工具栏2
                    cmdIDs[1]   = cmdGroup.get_CommandID(cmdIndex1);
                    TextType[1] = (int)swCommandTabButtonTextDisplay_e.swCommandTabButton_TextBelow;
                    //工具栏3
                    cmdIDs[2]   = cmdGroup.get_CommandID(cmdIndex2);
                    TextType[2] = (int)swCommandTabButtonTextDisplay_e.swCommandTabButton_TextBelow;
                    //工具栏4
                    cmdIDs[3]   = cmdGroup.get_CommandID(cmdIndex3);
                    TextType[3] = (int)swCommandTabButtonTextDisplay_e.swCommandTabButton_TextBelow;

                    //cmdIDs[2] = cmdGroup.ToolbarId;
                    //TextType[2] = (int)swCommandTabButtonTextDisplay_e.swCommandTabButton_TextHorizontal | (int)swCommandTabButtonFlyoutStyle_e.swCommandTabButton_ActionFlyout;

                    bResult = cmdBox.AddCommands(cmdIDs, TextType);

                    CommandTabBox cmdBox1 = cmdTab.AddCommandTabBox();
                    cmdIDs   = new int[1];
                    TextType = new int[1];

                    //cmdIDs[0] = flyGroup.CmdID;
                    //TextType[0] = (int)swCommandTabButtonTextDisplay_e.swCommandTabButton_TextBelow | (int)swCommandTabButtonFlyoutStyle_e.swCommandTabButton_ActionFlyout;

                    bResult = cmdBox1.AddCommands(cmdIDs, TextType);
                    cmdTab.AddSeparator(cmdBox1, cmdIDs[0]);
                }
            }
            thisAssembly = null;
        }
Esempio n. 7
0
        public void AddCommandMgr()
        {
            ICommandGroup cmdGroup;
            BitmapHandler iBmp = new BitmapHandler();
            Assembly      thisAssembly;
            int           cmdIndex0, cmdIndex1, cmdIndex2;
            string        Title = "EDS设计平台", ToolTip = "EDS设计平台";


            int[] docTypes = new int[] { (int)swDocumentTypes_e.swDocASSEMBLY,
                                         (int)swDocumentTypes_e.swDocDRAWING,
                                         (int)swDocumentTypes_e.swDocPART };

            thisAssembly = System.Reflection.Assembly.GetAssembly(this.GetType());

            cmdGroup = iCmdMgr.CreateCommandGroup(1, Title, ToolTip, "", -1);
            cmdGroup.LargeIconList = iBmp.CreateFileFromResourceBitmap("CAD3dSW.Resources.ToolbarLarge.bmp", thisAssembly);
            cmdGroup.SmallIconList = iBmp.CreateFileFromResourceBitmap("CAD3dSW.Resources.ToolbarSmall.bmp", thisAssembly);
            cmdGroup.LargeMainIcon = iBmp.CreateFileFromResourceBitmap("CAD3dSW.Resources.MainIconLarge.bmp", thisAssembly);
            cmdGroup.SmallMainIcon = iBmp.CreateFileFromResourceBitmap("CAD3dSW.Resources.MainIconSmall.bmp", thisAssembly);

            cmdIndex0 = cmdGroup.AddCommandItem("重命名组件", -1, "重命名组件", "重命名组件", 3, "RenameComponent", "", 0);
            cmdIndex1 = cmdGroup.AddCommandItem("启动CAD工作站", -1, "启动CAD工作站,自动处理任务", "CAD工作站", 2, "RunCADworkstation", "EnablePMP", 1);
            cmdIndex2 = cmdGroup.AddCommandItem("修改为此配置", -1, "修改全部尺寸为此配置", "修改为此配置", 1, "Testing", "", 2);

            //cmdIndex3 = cmdGroup.AddCommandItem("功能测试", -1, "开发中功能测试", "功能测试", 1, "Test", "", 3);

            cmdGroup.HasToolbar = true;
            cmdGroup.HasMenu    = true;
            cmdGroup.Activate();

            bool bResult;

            foreach (int type in docTypes)
            {
                ICommandTab cmdTab;

                cmdTab = iCmdMgr.GetCommandTab(type, Title);

                if (cmdTab == null)
                {
                    cmdTab = (ICommandTab)iCmdMgr.AddCommandTab(type, Title);

                    CommandTabBox cmdBox = cmdTab.AddCommandTabBox();

                    int[] cmdIDs   = new int[4];
                    int[] TextType = new int[4];


                    cmdIDs[0] = cmdGroup.get_CommandID(cmdIndex0);
                    System.Diagnostics.Debug.Print(cmdGroup.get_CommandID(cmdIndex0).ToString());
                    TextType[0] = (int)swCommandTabButtonTextDisplay_e.swCommandTabButton_TextHorizontal;

                    cmdIDs[1] = cmdGroup.get_CommandID(cmdIndex1);
                    System.Diagnostics.Debug.Print(cmdGroup.get_CommandID(cmdIndex1).ToString());
                    TextType[1] = (int)swCommandTabButtonTextDisplay_e.swCommandTabButton_TextHorizontal;

                    cmdIDs[2] = cmdGroup.get_CommandID(cmdIndex2);
                    System.Diagnostics.Debug.Print(cmdGroup.get_CommandID(cmdIndex2).ToString());
                    TextType[2] = (int)swCommandTabButtonTextDisplay_e.swCommandTabButton_TextHorizontal;

                    bResult = cmdBox.AddCommands(cmdIDs, TextType);

                    CommandTabBox cmdBox1 = cmdTab.AddCommandTabBox();
                    cmdIDs   = new int[1];
                    TextType = new int[1];

                    //cmdIDs[0] = cmdGroup.ToolbarId;
                    //TextType[0] = (int)swCommandTabButtonTextDisplay_e.swCommandTabButton_TextBelow | (int)swCommandTabButtonFlyoutStyle_e.swCommandTabButton_ActionFlyout;

                    bResult = cmdBox1.AddCommands(cmdIDs, TextType);
                    cmdTab.AddSeparator(cmdBox1, cmdGroup.ToolbarId);
                }
            }
            thisAssembly = null;
            iBmp.Dispose();
        }
Esempio n. 8
0
        public void AddCommandMgr()
        {
            ICommandGroup cmdGroup;

            if (m_iBmp == null)
            {
                m_iBmp = new BitmapHandler();
            }
            Assembly thisAssembly;
            int      cmdIndex0, cmdIndex1;
            string   Title = "C# Addin", ToolTip = "C# Addin";


            int[] docTypes = new int[] { (int)swDocumentTypes_e.swDocASSEMBLY,
                                         (int)swDocumentTypes_e.swDocDRAWING,
                                         (int)swDocumentTypes_e.swDocPART };

            thisAssembly = System.Reflection.Assembly.GetAssembly(this.GetType());


            int  cmdGroupErr    = 0;
            bool ignorePrevious = false;

            object registryIDs;
            //get the ID information stored in the registry
            bool getDataResult = m_iCmdMgr.GetGroupDataFromRegistry(mainCmdGroupID, out registryIDs);

            int[] knownIDs = new int[2] {
                mainItemID1, mainItemID2
            };

            if (getDataResult)
            {
                if (!CompareIDs((int[])registryIDs, knownIDs)) //if the IDs don't match, reset the commandGroup
                {
                    ignorePrevious = true;
                }
            }

            cmdGroup = m_iCmdMgr.CreateCommandGroup2(mainCmdGroupID, Title, ToolTip, "", -1, ignorePrevious, ref cmdGroupErr);

            // Add bitmaps to your project and set them as embedded resources or provide a direct path to the bitmaps.
            icons[0] = m_iBmp.CreateFileFromResourceBitmap("SwCSharpAddin1.toolbar20x.png", thisAssembly);
            icons[1] = m_iBmp.CreateFileFromResourceBitmap("SwCSharpAddin1.toolbar32x.png", thisAssembly);
            icons[2] = m_iBmp.CreateFileFromResourceBitmap("SwCSharpAddin1.toolbar40x.png", thisAssembly);
            icons[3] = m_iBmp.CreateFileFromResourceBitmap("SwCSharpAddin1.toolbar64x.png", thisAssembly);
            icons[4] = m_iBmp.CreateFileFromResourceBitmap("SwCSharpAddin1.toolbar96x.png", thisAssembly);
            icons[5] = m_iBmp.CreateFileFromResourceBitmap("SwCSharpAddin1.toolbar128x.png", thisAssembly);

            mainIcons[0] = m_iBmp.CreateFileFromResourceBitmap("SwCSharpAddin1.mainicon_20.png", thisAssembly);
            mainIcons[1] = m_iBmp.CreateFileFromResourceBitmap("SwCSharpAddin1.mainicon_32.png", thisAssembly);
            mainIcons[2] = m_iBmp.CreateFileFromResourceBitmap("SwCSharpAddin1.mainicon_40.png", thisAssembly);
            mainIcons[3] = m_iBmp.CreateFileFromResourceBitmap("SwCSharpAddin1.mainicon_64.png", thisAssembly);
            mainIcons[4] = m_iBmp.CreateFileFromResourceBitmap("SwCSharpAddin1.mainicon_96.png", thisAssembly);
            mainIcons[5] = m_iBmp.CreateFileFromResourceBitmap("SwCSharpAddin1.mainicon_128.png", thisAssembly);

            cmdGroup.MainIconList = mainIcons;
            cmdGroup.IconList     = icons;

            int menuToolbarOption = (int)(swCommandItemType_e.swMenuItem | swCommandItemType_e.swToolbarItem);

            cmdIndex0 = cmdGroup.AddCommandItem2("CreateCube", -1, "Create a cube", "Create cube", 0, "CreateCube", "", mainItemID1, menuToolbarOption);
            cmdIndex1 = cmdGroup.AddCommandItem2("Show PMP", -1, "Display sample property manager", "Show PMP", 2, "ShowPMP", "EnablePMP", mainItemID2, menuToolbarOption);

            cmdGroup.HasToolbar = true;
            cmdGroup.HasMenu    = true;
            cmdGroup.Activate();

            bool bResult;



            FlyoutGroup flyGroup = m_iCmdMgr.CreateFlyoutGroup2(flyoutGroupID, "Dynamic Flyout", "Flyout Tooltip", "Flyout Hint",
                                                                cmdGroup.MainIconList, cmdGroup.IconList, "FlyoutCallback", "FlyoutEnable");


            flyGroup.AddCommandItem("FlyoutCommand 1", "test", 0, "FlyoutCommandItem1", "FlyoutEnableCommandItem1");

            flyGroup.FlyoutType = (int)swCommandFlyoutStyle_e.swCommandFlyoutStyle_Simple;


            foreach (int type in docTypes)
            {
                CommandTab cmdTab;

                cmdTab = m_iCmdMgr.GetCommandTab(type, Title);

                if (cmdTab != null & !getDataResult | ignorePrevious)//if tab exists, but we have ignored the registry info (or changed command group ID), re-create the tab.  Otherwise the ids won't matchup and the tab will be blank
                {
                    bool res = m_iCmdMgr.RemoveCommandTab(cmdTab);
                    cmdTab = null;
                }

                //if cmdTab is null, must be first load (possibly after reset), add the commands to the tabs
                if (cmdTab == null)
                {
                    cmdTab = m_iCmdMgr.AddCommandTab(type, Title);

                    CommandTabBox cmdBox = cmdTab.AddCommandTabBox();

                    int[] cmdIDs   = new int[3];
                    int[] TextType = new int[3];

                    cmdIDs[0] = cmdGroup.get_CommandID(cmdIndex0);

                    TextType[0] = (int)swCommandTabButtonTextDisplay_e.swCommandTabButton_TextHorizontal;

                    cmdIDs[1] = cmdGroup.get_CommandID(cmdIndex1);

                    TextType[1] = (int)swCommandTabButtonTextDisplay_e.swCommandTabButton_TextHorizontal;

                    cmdIDs[2] = cmdGroup.ToolbarId;

                    TextType[2] = (int)swCommandTabButtonTextDisplay_e.swCommandTabButton_TextHorizontal | (int)swCommandTabButtonFlyoutStyle_e.swCommandTabButton_ActionFlyout;

                    bResult = cmdBox.AddCommands(cmdIDs, TextType);



                    CommandTabBox cmdBox1 = cmdTab.AddCommandTabBox();
                    cmdIDs   = new int[1];
                    TextType = new int[1];

                    cmdIDs[0]   = flyGroup.CmdID;
                    TextType[0] = (int)swCommandTabButtonTextDisplay_e.swCommandTabButton_TextBelow | (int)swCommandTabButtonFlyoutStyle_e.swCommandTabButton_ActionFlyout;

                    bResult = cmdBox1.AddCommands(cmdIDs, TextType);

                    cmdTab.AddSeparator(cmdBox1, cmdIDs[0]);
                }
            }

            // Create a third-party icon in the context-sensitive menus of faces in parts
            // To see this menu, right click on any face in the part
            Frame swFrame;

            swFrame = m_iSwApp.Frame();
            bResult = swFrame.AddMenuPopupIcon3((int)swDocumentTypes_e.swDocPART, (int)swSelectType_e.swSelFACES, "third-party context-sensitive CSharp", m_addinID,
                                                "PopupCallbackFunction", "PopupEnable", "", cmdGroup.MainIconList);

            // create and register the shortcut menu
            registerID = m_iSwApp.RegisterThirdPartyPopupMenu();

            // add a menu break at the top of the shortcut menu
            bResult = m_iSwApp.AddItemToThirdPartyPopupMenu2(registerID, (int)swDocumentTypes_e.swDocPART, "Menu Break", m_addinID, "", "", "", "", "", (int)swMenuItemType_e.swMenuItemType_Break);

            // add a couple of items to the shortcut menu
            bResult = m_iSwApp.AddItemToThirdPartyPopupMenu2(registerID, (int)swDocumentTypes_e.swDocPART, "Test1", m_addinID, "TestCallback", "EnableTest", "", "Test1", mainIcons[0], (int)swMenuItemType_e.swMenuItemType_Default);
            bResult = m_iSwApp.AddItemToThirdPartyPopupMenu2(registerID, (int)swDocumentTypes_e.swDocPART, "Test2", m_addinID, "TestCallback", "EnableTest", "", "Test2", mainIcons[0], (int)swMenuItemType_e.swMenuItemType_Default);

            // add a separator bar to the shortcut menu
            bResult = m_iSwApp.AddItemToThirdPartyPopupMenu2(registerID, (int)swDocumentTypes_e.swDocPART, "separator", m_addinID, "", "", "", "", "", (int)swMenuItemType_e.swMenuItemType_Separator);

            // add another item to the shortcut menu
            bResult = m_iSwApp.AddItemToThirdPartyPopupMenu2(registerID, (int)swDocumentTypes_e.swDocPART, "Test3", m_addinID, "TestCallback", "EnableTest", "", "Test3", mainIcons[0], (int)swMenuItemType_e.swMenuItemType_Default);

            // add an icon to a menu bar of the shortcut menu
            bResult = m_iSwApp.AddItemToThirdPartyPopupMenu2(registerID, (int)swDocumentTypes_e.swDocPART, "", m_addinID, "TestCallback", "EnableTest", "", "NoOp", mainIcons[0], (int)swMenuItemType_e.swMenuItemType_Default);

            thisAssembly = null;
        }
Esempio n. 9
0
        public void AddCommandMgr()
        {
            ICommandGroup cmdGroup;

            if (iBmp == null)
            {
                iBmp = new BitmapHandler();
            }
            Assembly thisAssembly;
            int      cmdIndex0, cmdIndex1, cmdIndex2, cmdIndex3, cmdIndex4, cmdIndex5, cmdIndex6, cmdIndex7;
            string   Title = "WATEASY", ToolTip = "fast and easy";


            int[] docTypes = new int[] { (int)swDocumentTypes_e.swDocASSEMBLY,
                                         (int)swDocumentTypes_e.swDocDRAWING,
                                         (int)swDocumentTypes_e.swDocPART };

            thisAssembly = System.Reflection.Assembly.GetAssembly(this.GetType());


            int  cmdGroupErr    = 0;
            bool ignorePrevious = false;

            object registryIDs;
            //get the ID information stored in the registry
            bool getDataResult = iCmdMgr.GetGroupDataFromRegistry(mainCmdGroupID, out registryIDs);

            int[] knownIDs = new int[2] {
                mainItemID1, mainItemID2
            };

            if (getDataResult)
            {
                if (!CompareIDs((int[])registryIDs, knownIDs)) //if the IDs don't match, reset the commandGroup
                {
                    ignorePrevious = true;
                }
            }

            cmdGroup = iCmdMgr.CreateCommandGroup2(mainCmdGroupID, Title, ToolTip, "", -1, ignorePrevious, ref cmdGroupErr);
            cmdGroup.LargeIconList = iBmp.CreateFileFromResourceBitmap("SwCSharpAddinByStanley.ToolbarLarge.bmp", thisAssembly);
            cmdGroup.SmallIconList = iBmp.CreateFileFromResourceBitmap("SwCSharpAddinByStanley.ToolbarSmall.bmp", thisAssembly);
            cmdGroup.LargeMainIcon = iBmp.CreateFileFromResourceBitmap("SwCSharpAddinByStanley.MainIconLarge.bmp", thisAssembly);
            cmdGroup.SmallMainIcon = iBmp.CreateFileFromResourceBitmap("SwCSharpAddinByStanley.MainIconSmall.bmp", thisAssembly);

            int menuToolbarOption = (int)(swCommandItemType_e.swMenuItem | swCommandItemType_e.swToolbarItem);

            cmdIndex0 = cmdGroup.AddCommandItem2("清空属性", -1, "清空属性", "清空属性", 0, "PropertyClear", "", mainItemID1, menuToolbarOption);
            //cmdIndex0 = cmdGroup.AddCommandItem2("CreateCube", -1, "Create a cube", "Create cube", 0, "CreateCube", "", mainItemID1, menuToolbarOption);
            //cmdIndex1 = cmdGroup.AddCommandItem2("Show PMP", -1, "Display sample property manager", "Show PMP", 2, "ShowPMP", "EnablePMP", mainItemID2, menuToolbarOption);
            cmdIndex1 = cmdGroup.AddCommandItem2("填写图号", -1, "填写图号", "填写图号", 1, "DrawingNoInput", "", mainItemID2, menuToolbarOption);
            cmdIndex2 = cmdGroup.AddCommandItem2("配置插件", -1, "配置插件", "配置插件", 2, "ConfigModify", "", mainItemID3, menuToolbarOption);
            cmdIndex3 = cmdGroup.AddCommandItem2("随机颜色", -1, "随机颜色", "随机颜色", 3, "PartDye", "", mainItemID4, menuToolbarOption);
            cmdIndex4 = cmdGroup.AddCommandItem2("检查配孔", -1, "检查配孔", "检查配孔", 4, "HoleCheck", "", mainItemID5, menuToolbarOption);
            cmdIndex5 = cmdGroup.AddCommandItem2("外包尺寸", -1, "外包尺寸", "外包尺寸", 5, "GetBoundingBox", "", mainItemID6, menuToolbarOption);
            cmdIndex6 = cmdGroup.AddCommandItem2("关联打开", -1, "关联打开", "关联打开", 7, "OpenRelvantFile", "", mainItemID7, menuToolbarOption);
            cmdIndex7 = cmdGroup.AddCommandItem2("关于我", -1, "关于我", "关于我", 6, "SaveAs", "", mainItemID8, menuToolbarOption);

            cmdGroup.HasToolbar = true;
            cmdGroup.HasMenu    = true;
            cmdGroup.Activate();

            bool bResult;



            FlyoutGroup flyGroup = iCmdMgr.CreateFlyoutGroup(flyoutGroupID, "Dynamic Flyout", "Flyout Tooltip", "Flyout Hint",
                                                             cmdGroup.SmallMainIcon, cmdGroup.LargeMainIcon, cmdGroup.SmallIconList, cmdGroup.LargeIconList, "FlyoutCallback", "FlyoutEnable");


            flyGroup.AddCommandItem("FlyoutCommand 1", "test", 0, "FlyoutCommandItem1", "FlyoutEnableCommandItem1");

            flyGroup.FlyoutType = (int)swCommandFlyoutStyle_e.swCommandFlyoutStyle_Simple;


            foreach (int type in docTypes)
            {
                CommandTab cmdTab;

                cmdTab = iCmdMgr.GetCommandTab(type, Title);

                if (cmdTab != null & !getDataResult | ignorePrevious)//if tab exists, but we have ignored the registry info (or changed command group ID), re-create the tab.  Otherwise the ids won't matchup and the tab will be blank
                {
                    bool res = iCmdMgr.RemoveCommandTab(cmdTab);
                    cmdTab = null;
                }

                //if cmdTab is null, must be first load (possibly after reset), add the commands to the tabs
                //TODO: 将命令添加到tab上
                if (cmdTab == null)
                {
                    cmdTab = iCmdMgr.AddCommandTab(type, Title);

                    CommandTabBox cmdBox = cmdTab.AddCommandTabBox();

                    int[] cmdIDs   = new int[8];
                    int[] TextType = new int[8];

                    cmdIDs[0] = cmdGroup.get_CommandID(cmdIndex0);

                    TextType[0] = (int)swCommandTabButtonTextDisplay_e.swCommandTabButton_TextHorizontal;

                    cmdIDs[1] = cmdGroup.get_CommandID(cmdIndex1);

                    TextType[1] = (int)swCommandTabButtonTextDisplay_e.swCommandTabButton_TextHorizontal;
                    cmdIDs[2]   = cmdGroup.get_CommandID(cmdIndex2);

                    TextType[2] = (int)swCommandTabButtonTextDisplay_e.swCommandTabButton_TextHorizontal;
                    cmdIDs[3]   = cmdGroup.get_CommandID(cmdIndex3);

                    TextType[3] = (int)swCommandTabButtonTextDisplay_e.swCommandTabButton_TextHorizontal;
                    cmdIDs[4]   = cmdGroup.get_CommandID(cmdIndex4);

                    TextType[4] = (int)swCommandTabButtonTextDisplay_e.swCommandTabButton_TextHorizontal;
                    cmdIDs[5]   = cmdGroup.get_CommandID(cmdIndex5);

                    TextType[5] = (int)swCommandTabButtonTextDisplay_e.swCommandTabButton_TextHorizontal;
                    cmdIDs[6]   = cmdGroup.get_CommandID(cmdIndex6);

                    TextType[6] = (int)swCommandTabButtonTextDisplay_e.swCommandTabButton_TextHorizontal;
                    cmdIDs[7]   = cmdGroup.get_CommandID(cmdIndex7);

                    TextType[7] = (int)swCommandTabButtonTextDisplay_e.swCommandTabButton_TextHorizontal;

                    //cmdIDs[2] = cmdGroup.ToolbarId;

                    //TextType[2] = (int)swCommandTabButtonTextDisplay_e.swCommandTabButton_TextHorizontal | (int)swCommandTabButtonFlyoutStyle_e.swCommandTabButton_ActionFlyout;

                    bResult = cmdBox.AddCommands(cmdIDs, TextType);



                    CommandTabBox cmdBox1 = cmdTab.AddCommandTabBox();
                    cmdIDs   = new int[1];
                    TextType = new int[1];

                    cmdIDs[0]   = flyGroup.CmdID;
                    TextType[0] = (int)swCommandTabButtonTextDisplay_e.swCommandTabButton_TextBelow | (int)swCommandTabButtonFlyoutStyle_e.swCommandTabButton_ActionFlyout;

                    bResult = cmdBox1.AddCommands(cmdIDs, TextType);

                    cmdTab.AddSeparator(cmdBox1, cmdIDs[0]);
                }
            }
            thisAssembly = null;
        }
Esempio n. 10
0
        public void AddCommandMgr()
        {
            ICommandGroup commnadGroup;

            if (iBmp == null)
            {
                iBmp = new BitmapHandler();
            }
            //we will need an Assembly object to create the bitmaps for the command group items
            Assembly thisAssembly;

            //these integers are references to the command group buttons. we will use these references to add those buttons to a command tab
            int commandIndex0;
            int commnadIndex1;

            //these are strings that we will use to make command group and command tab
            //this one is the name you see for this command group once you access from Tools menu
            string titleOfCommandGroup = "This is title of Command Group";
            string ToolTip             = "C# Addin";
            //this is the text you see in the command tab for example 'Features' would be the tile of Feature Tab
            string TitleOfCommandTab = "Title of Command Tab";
            //if you create a command group item in a command tab this text would be its tool-tip
            string toolTipOfCommandGroup = "Tooltip of command group";

            //we will use this array to add the command tab to each document type
            int[] documentTypes = new int[] { (int)swDocumentTypes_e.swDocASSEMBLY,
                                              (int)swDocumentTypes_e.swDocDRAWING,
                                              (int)swDocumentTypes_e.swDocPART };


            thisAssembly = System.Reflection.Assembly.GetAssembly(this.GetType());
            int  commandGroupError = 0;
            bool ignorePrevious    = false;

            //get the ID information stored in the registry
            object registryIDs;
            bool   getDataResult = _commandManager.GetGroupDataFromRegistry(mainCmdGroupID, out registryIDs);

            int[] knownIDs = new int[2] {
                mainItemID1, mainItemID2
            };

            //if the IDs don't match, reset the commandGroup
            if (getDataResult)
            {
                if (!CompareIDs((int[])registryIDs, knownIDs))
                {
                    ignorePrevious = true;
                }
            }
            //a command group is a button that once clicked on, shows a list of other commands in it. it also gets listed in the Tools menu if you want
            commnadGroup = _commandManager.CreateCommandGroup2(mainCmdGroupID, titleOfCommandGroup, toolTipOfCommandGroup, "", -1, ignorePrevious, ref commandGroupError);
            //after creating the command group you should add the bitmap photos to it. for this you should use a BitMapHandler object
            commnadGroup.LargeIconList = iBmp.CreateFileFromResourceBitmap("HymmaSampleAddin.ToolbarLarge.bmp", thisAssembly);
            commnadGroup.SmallIconList = iBmp.CreateFileFromResourceBitmap("HymmaSampleAddin.ToolbarSmall.bmp", thisAssembly);
            commnadGroup.LargeMainIcon = iBmp.CreateFileFromResourceBitmap("HymmaSampleAddin.MainIconLarge.bmp", thisAssembly);
            commnadGroup.SmallMainIcon = iBmp.CreateFileFromResourceBitmap("HymmaSampleAddin.MainIconSmall.bmp", thisAssembly);

            //Here we make the buttons in the command group. They have the callback functions names as strings
            int menuToolbarOption = (int)(swCommandItemType_e.swMenuItem | swCommandItemType_e.swToolbarItem);

            commandIndex0 = commnadGroup.AddCommandItem2("CreateCube", -1, "Create a cube", "Create cube", 0, "CreateCube", "", mainItemID1, menuToolbarOption);
            //ShowPMP is the call back function here which will use UserPMPage to create a new property manager page
            commnadIndex1 = commnadGroup.AddCommandItem2("Show PMP", -1, "Display sample property manager", "Show PMP", 2, nameof(ShowPMP), nameof(EnablePMP), mainItemID2, menuToolbarOption);
            //with this you get the command group listed under the Tools menu
            commnadGroup.HasToolbar = true;
            commnadGroup.HasMenu    = true;
            commnadGroup.Activate();

            // a fly-out-group is a button that when you click on it shows a list of other commands in it
            //with command groups we had to use a separate property called LargIconList and SmallIconList to assign the bitmaps to the buttons
            //here we just use those same properties and use them for this flyout group as well
            FlyoutGroup flyGroup = _commandManager.CreateFlyoutGroup(flyoutGroupID, "Dynamic Flyout", "Flyout Tooltip", "Flyout Hint",
                                                                     commnadGroup.SmallMainIcon, commnadGroup.LargeMainIcon, commnadGroup.SmallIconList, commnadGroup.LargeIconList, "FlyoutCallback", "FlyoutEnable");

            flyGroup.AddCommandItem("FlyoutCommand 1", "hint string", 0, "FlyoutCommandItem1", "FlyoutEnableCommandItem1");
            flyGroup.FlyoutType = (int)swCommandFlyoutStyle_e.swCommandFlyoutStyle_Simple;

            bool result;

            foreach (int type in documentTypes)
            {
                CommandTab commandTab;
                commandTab = _commandManager.GetCommandTab(type, TitleOfCommandTab);

                //this code removes older tabs I had created
                try
                {
                    _commandManager.RemoveCommandTab(_commandManager.GetCommandTab(type, "New Tab"));
                    _commandManager.RemoveCommandTab(_commandManager.GetCommandTab(type, "C# Addin"));
                }
                catch { }
                //if tab exists, but we have ignored the registry info (or changed command group ID), re-create the tab.  Otherwise the ids won't match-up and the tab will be blank
                if (commandTab != null & !getDataResult | ignorePrevious)
                {
                    bool res = _commandManager.RemoveCommandTab(commandTab);
                    commandTab = null;
                }

                //if cmdTab is null, must be first load (possibly after reset), add the commands to the tabs
                if (commandTab == null)
                {
                    commandTab = _commandManager.AddCommandTab(type, TitleOfCommandTab);
                    CommandTabBox commandBox0 = commandTab.AddCommandTabBox();
                    //we will use these to add the command to a command box
                    // we will get the command ids from the command group items references (i.e. commnadIndex* we defined earlier)
                    int[] commandIds = new int[3];
                    int[] TextType   = new int[3];

                    commandIds[0] = commnadGroup.get_CommandID(commandIndex0);

                    TextType[0] = (int)swCommandTabButtonTextDisplay_e.swCommandTabButton_TextHorizontal;

                    commandIds[1] = commnadGroup.get_CommandID(commnadIndex1);

                    TextType[1] = (int)swCommandTabButtonTextDisplay_e.swCommandTabButton_TextHorizontal;

                    commandIds[2] = commnadGroup.ToolbarId;

                    TextType[2] = (int)swCommandTabButtonTextDisplay_e.swCommandTabButton_TextHorizontal | (int)swCommandTabButtonFlyoutStyle_e.swCommandTabButton_ActionFlyout;

                    result = commandBox0.AddCommands(commandIds, TextType);

                    CommandTabBox commandBox1 = commandTab.AddCommandTabBox();
                    commandIds = new int[1];
                    TextType   = new int[1];

                    commandIds[0] = flyGroup.CmdID;
                    TextType[0]   = (int)swCommandTabButtonTextDisplay_e.swCommandTabButton_TextBelow | (int)swCommandTabButtonFlyoutStyle_e.swCommandTabButton_ActionFlyout;
                    result        = commandBox1.AddCommands(commandIds, TextType);
                    commandTab.AddSeparator(commandBox1, commandIds[0]);
                }
            }
            thisAssembly = null;
        }
Esempio n. 11
0
        /// <summary>
        /// The add command mgr.
        /// </summary>
        public void AddCommandMgr()
        {
            if (this.iBmp == null)
            {
                this.iBmp = new BitmapHandler();
            }

            const string Title   = "Save PDF";
            const string ToolTip = "Save PDF";

            int[] docTypes =
            {
                (int)swDocumentTypes_e.swDocASSEMBLY, (int)swDocumentTypes_e.swDocDRAWING,
                (int)swDocumentTypes_e.swDocPART
            };

            Assembly thisAssembly = Assembly.GetAssembly(this.GetType());

            int  cmdGroupErr    = 0;
            bool ignorePrevious = false;

            object registryIDs;

            // get the ID information stored in the registry
            bool getDataResult = this.CmdMgr.GetGroupDataFromRegistry(MainCmdGroupId, out registryIDs);

            int[] knownIDs = { MainItemId1 };

            if (getDataResult)
            {
                if (!this.CompareIDs((int[])registryIDs, knownIDs))
                {
                    // if the IDs don't match, reset the commandGroup
                    ignorePrevious = true;
                }
            }

            ICommandGroup cmdGroup = this.CmdMgr.CreateCommandGroup2(
                MainCmdGroupId,
                Title,
                ToolTip,
                "",
                -1,
                ignorePrevious,
                ref cmdGroupErr);

            cmdGroup.LargeIconList = this.iBmp.CreateFileFromResourceBitmap("SavePDF.ToolbarLarge.bmp", thisAssembly);
            cmdGroup.SmallIconList = this.iBmp.CreateFileFromResourceBitmap("SavePDF.ToolbarSmall.bmp", thisAssembly);

            const int menuToolbarOption = (int)(swCommandItemType_e.swMenuItem | swCommandItemType_e.swToolbarItem);

            int cmdIndex0 = cmdGroup.AddCommandItem2(
                "Save PDF",
                -1,
                "Save PDF Options",
                "Save PDF Options",
                0,
                "ShowPMP",
                "EnablePMP",
                MainItemId1,
                menuToolbarOption);

            cmdGroup.HasToolbar = true;
            cmdGroup.HasMenu    = true;
            cmdGroup.Activate();

            foreach (int type in docTypes)
            {
                CommandTab cmdTab = this.CmdMgr.GetCommandTab(type, Title);

                if (cmdTab != null & !getDataResult | ignorePrevious)
                {
                    // if tab exists, but we have ignored the registry info (or changed command group ID), re-create the tab.  Otherwise the ids won't matchup and the tab will be blank
                    bool res = this.CmdMgr.RemoveCommandTab(cmdTab);
                    cmdTab = null;
                }

                // if cmdTab is null, must be first load (possibly after reset), add the commands to the tabs
                if (cmdTab == null)
                {
                    cmdTab = this.CmdMgr.AddCommandTab(type, Title);

                    CommandTabBox cmdBox = cmdTab.AddCommandTabBox();

                    var cmdIDs   = new int[1];
                    var textType = new int[1];

                    cmdIDs[0] = cmdGroup.CommandID[cmdIndex0];

                    textType[0] = (int)swCommandTabButtonTextDisplay_e.swCommandTabButton_TextHorizontal;

                    cmdBox.AddCommands(cmdIDs, textType);
                }
            }

            thisAssembly = null;
        }
Esempio n. 12
0
        public void AddCommandMgr()
        {
            BitmapHandler iBmp = new BitmapHandler();

            Assembly thisAssembly;
            int      cmdIndex0, cmdIndex1, cmdIndex2, cmdIndex3, cmdIndex4;
            string   Title = "DotNetControlsDemo", ToolTip = "DotNetControlsDemo";


            int[] docTypes = new int[] { (int)swDocumentTypes_e.swDocASSEMBLY,
                                         (int)swDocumentTypes_e.swDocDRAWING,
                                         (int)swDocumentTypes_e.swDocPART };

            thisAssembly = System.Reflection.Assembly.GetAssembly(this.GetType());

            cmdGroup = iCmdMgr.CreateCommandGroup(1, Title, ToolTip, "", -1);
            cmdGroup.LargeIconList = iBmp.CreateFileFromResourceBitmap("DotNetControlsDemo.ToolbarLarge.bmp", thisAssembly);
            cmdGroup.SmallIconList = iBmp.CreateFileFromResourceBitmap("DotNetControlsDemo.ToolbarSmall.bmp", thisAssembly);
            cmdGroup.LargeMainIcon = iBmp.CreateFileFromResourceBitmap("DotNetControlsDemo.MainIconLarge.bmp", thisAssembly);
            cmdGroup.SmallMainIcon = iBmp.CreateFileFromResourceBitmap("DotNetControlsDemo.MainIconSmall.bmp", thisAssembly);

            cmdIndex0 = cmdGroup.AddCommandItem("WinFromInTaskPane", -1, "Add Windows Form In Task Pane", "WinFormInTaskPane", 0, "WinFormInTaskPane", "EnableWinFormInTaskPane", 0);
            cmdIndex1 = cmdGroup.AddCommandItem("UserControlInModelView", -1, "Add User Control In Model View", "UserControlInModelView", 1, "UserControlInModelView", "EnableUserControlInModelView", 1);
            cmdIndex2 = cmdGroup.AddCommandItem("WPFInModelView", -1, "Add WPF In ModelView", "WPFInModelView", 2, "WPFInModelView", "EnableWPFInModelView", 2);
            cmdIndex3 = cmdGroup.AddCommandItem("WinFormInFeatureMgr", -1, "Add Windows Form In FeatureManager", "WinFormInFeatureMgr", 3, "WinFormInFeatureMgr", "EnableWinFormInFeatureMgr", 3);
            cmdIndex4 = cmdGroup.AddCommandItem("Show PMP", -1, "Display PropertyManager with .NET Controls", "Show PMP", 4, "ShowPMP", "EnablePMP", 4);

            cmdGroup.HasToolbar = true;
            cmdGroup.HasMenu    = true;
            cmdGroup.Activate();

            bool bResult;

            foreach (int type in docTypes)
            {
                ICommandTab cmdTab;

                cmdTab = iCmdMgr.GetCommandTab(type, Title);

                if (cmdTab == null)
                {
                    cmdTab = (ICommandTab)iCmdMgr.AddCommandTab(type, Title);

                    CommandTabBox cmdBox = cmdTab.AddCommandTabBox();

                    int[] cmdIDs   = new int[6];
                    int[] TextType = new int[6];


                    cmdIDs[0] = cmdGroup.get_CommandID(cmdIndex0);
                    System.Diagnostics.Debug.Print(cmdGroup.get_CommandID(cmdIndex0).ToString());
                    TextType[0] = (int)swCommandTabButtonTextDisplay_e.swCommandTabButton_TextHorizontal;

                    cmdIDs[1] = cmdGroup.get_CommandID(cmdIndex1);
                    System.Diagnostics.Debug.Print(cmdGroup.get_CommandID(cmdIndex1).ToString());
                    TextType[1] = (int)swCommandTabButtonTextDisplay_e.swCommandTabButton_TextHorizontal;

                    cmdIDs[2] = cmdGroup.get_CommandID(cmdIndex2);
                    System.Diagnostics.Debug.Print(cmdGroup.get_CommandID(cmdIndex2).ToString());
                    TextType[2] = (int)swCommandTabButtonTextDisplay_e.swCommandTabButton_TextHorizontal;

                    cmdIDs[3] = cmdGroup.get_CommandID(cmdIndex3);
                    System.Diagnostics.Debug.Print(cmdGroup.get_CommandID(cmdIndex3).ToString());
                    TextType[3] = (int)swCommandTabButtonTextDisplay_e.swCommandTabButton_TextHorizontal;


                    cmdIDs[4] = cmdGroup.get_CommandID(cmdIndex4);
                    System.Diagnostics.Debug.Print(cmdGroup.get_CommandID(cmdIndex4).ToString());
                    TextType[4] = (int)swCommandTabButtonTextDisplay_e.swCommandTabButton_TextHorizontal;

                    cmdIDs[5] = cmdGroup.ToolbarId;
                    System.Diagnostics.Debug.Print(cmdIDs[5].ToString());
                    TextType[5] = (int)swCommandTabButtonTextDisplay_e.swCommandTabButton_TextHorizontal | (int)swCommandTabButtonFlyoutStyle_e.swCommandTabButton_ActionFlyout;

                    bResult = cmdBox.AddCommands(cmdIDs, TextType);



                    CommandTabBox cmdBox1 = cmdTab.AddCommandTabBox();
                    cmdIDs   = new int[1];
                    TextType = new int[1];

                    cmdIDs[0]   = cmdGroup.ToolbarId;
                    TextType[0] = (int)swCommandTabButtonTextDisplay_e.swCommandTabButton_TextBelow | (int)swCommandTabButtonFlyoutStyle_e.swCommandTabButton_ActionFlyout;

                    bResult = cmdBox1.AddCommands(cmdIDs, TextType);

                    cmdTab.AddSeparator(cmdBox1, cmdGroup.ToolbarId);
                }
            }
            thisAssembly = null;
            iBmp.Dispose();
        }