Esempio n. 1
0
        public void FlyoutCallback()
        {
            FlyoutGroup flyGroup = iCmdMgr.GetFlyoutGroup(flyoutGroupID);

            flyGroup.RemoveAllCommandItems();

            flyGroup.AddCommandItem(System.DateTime.Now.ToLongTimeString(), "test", 0, "FlyoutCommandItem1", "FlyoutEnableCommandItem1");
        }
Esempio n. 2
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. 3
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. 4
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. 5
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;
        }