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
        public void AddCommandMgr()
        {
            if (iBmp == null)
            {
                iBmp = new BitmapHandler();
            }
            Assembly thisAssembly;
            int      cmdIndex0, cmdIndex1;
            string   Title = "CAPP 插件", ToolTip = "CAPP 插件";


            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[1] {
                mainItemID1
            };                                          // 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("Kingdee.CAPP.Solidworks.RoutingPlugIn.ToolbarLarge.bmp", thisAssembly);
            cmdGroup.SmallIconList = iBmp.CreateFileFromResourceBitmap("Kingdee.CAPP.Solidworks.RoutingPlugIn.ToolbarSmall.bmp", thisAssembly);
            cmdGroup.LargeMainIcon = iBmp.CreateFileFromResourceBitmap("Kingdee.CAPP.Solidworks.RoutingPlugIn.MainIconLarge.bmp", thisAssembly);
            cmdGroup.SmallMainIcon = iBmp.CreateFileFromResourceBitmap("Kingdee.CAPP.Solidworks.RoutingPlugIn.MainIconSmall.bmp", thisAssembly);

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

            //增加菜单
            cmdIndex0 = cmdGroup.AddCommandItem2("关联零件到工艺路线", -1, "关联零件到工艺路线", "关联零件到工艺路线", 0, "Routing", "EnableRouting", mainItemID1, menuToolbarOption);
            cmdIndex1 = cmdGroup.AddCommandItem2("关联草图到工序", -1, "关联草图到工序", "关联草图到工序", 0, "SketchToProcess", "EnableRouting", mainItemID2, menuToolbarOption);
            //cmdIndex1 = cmdGroup.AddCommandItem2("Show PMP", -1, "Display sample property manager", "Show PMP", 2, "ShowPMP", "EnablePMP", mainItemID2, menuToolbarOption);
            //cmdIndex1 = cmdGroup.AddCommandItem2("WinFormInFeatureMgr", -1, "Add Windows Form In FeatureManager", "WinFormInFeatureMgr", 2, "WinFormInFeatureMgr", "", mainItemID1, 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. 3
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();
        }
Esempio n. 4
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();
        }