private void SetupUI() { int errors = 0; // gather up the icons string folder = System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetAssembly(this.GetType()).Location); // create command group ICommandGroup commandGroup = _cmdMgr.CreateCommandGroup2(_mainCmdGrpId, "Custom Addin", "My custom add-in", "", -1, true, ref errors); // set the icon lists commandGroup.IconList = new string[] { System.IO.Path.Combine(folder, "Icons", "icons.bmp") }; commandGroup.MainIconList = new string[] { System.IO.Path.Combine(folder, "Icons", "icons.bmp") }; // add the commands to the command group // this is just an example for demo purposes*** List <int> commandItems = new List <int>(); for (int i = 0; i < 10; i++) { // you wouldn't add your commands like this. // you would obviously create them one at a time // for example, in this demo, we're adding 10 commands, but they all call the same method ExucuteAction... that would be a dumb addin commandItems.Add(commandGroup.AddCommandItem2("Action " + i, -1, "Action " + i, "Action " + i, i, "ExecuteAction", "CanExecuteAction", _menuItemId1 + i, (int)swCommandItemType_e.swMenuItem | (int)swCommandItemType_e.swToolbarItem)); } // activate command group commandGroup.HasToolbar = true; commandGroup.HasMenu = true; commandGroup.Activate(); // create the command tab foreach (int docType in new int[] { (int)swDocumentTypes_e.swDocASSEMBLY, (int)swDocumentTypes_e.swDocPART, (int)swDocumentTypes_e.swDocDRAWING }) { ICommandTab commandTab = _cmdMgr.GetCommandTab(docType, "Custom Addin"); if (commandTab != null) { // recreate the command tab _cmdMgr.RemoveCommandTab((CommandTab)commandTab); commandTab = null; } // add the command tab commandTab = _cmdMgr.AddCommandTab(docType, "Custom Addin"); // create a command box ICommandTabBox commandTabBox = commandTab.AddCommandTabBox(); // add commands to command tab List <int> cmds = new List <int>(); List <int> textTypes = new List <int>(); foreach (var cmdItem in commandItems) { cmds.Add(commandGroup.CommandID[cmdItem]); textTypes.Add((int)swCommandTabButtonTextDisplay_e.swCommandTabButton_TextBelow); } bool result = commandTabBox.AddCommands(cmds.ToArray(), textTypes.ToArray()); commandTab.AddSeparator((CommandTabBox)commandTabBox, cmds.First()); } }
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; }
/// <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; }
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(); }
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; }
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; }
public ICommandGroup AddCommandGroup(GroupData groupData, ILifetimeScope scope) { ICommandGroup cmdGroup; int mainCmdGroupID = 0; int cmdGroupErr = 0; object registryIDs; _addinCommand.CmdGroupIDs.Add(mainCmdGroupID); var config = groupData.TabStyles.Select(p => p.GetProperties().Select(q => new KeyValuePair <int, Type[]>(q.GetCustomAttribute <BoxOrderAttribute>()?.Order ?? 1, q.GetCustomAttribute <CommandCollectionAttribute>()?.Commands)). OrderBy(r => r.Key)); //计算按钮数量 int cmdCount = 0; foreach (var doc in config) { foreach (var properties in doc) { cmdCount = cmdCount + properties.Value.Length; } } //thisAssembly = System.Reflection.Assembly.GetAssembly(this.GetType()); //get the ID information stored in the registry getDataResult = iCmdMgr.GetGroupDataFromRegistry(mainCmdGroupID, out registryIDs); //_addinCommand.CommandInstances = new Dictionary<string, object>(); int[] knownIDs = new int[cmdCount]; for (int i = 0; i < knownIDs.Length; i++) { knownIDs[i] = i; } if (getDataResult) { if (!CompareIDs((int[])registryIDs, knownIDs)) //if the IDs don't match, reset the commandGroup { ignorePrevious = true; } } ignorePrevious = true; cmdGroup = iCmdMgr.CreateCommandGroup2(mainCmdGroupID, groupData.Title, groupData.ToolTip, groupData.Hint, -1, ignorePrevious, ref cmdGroupErr); cmdGroup.LargeIconList = iBmp.CreateFileFromResourceBitmap(groupData.Icons[0], groupData.IconAssembly); cmdGroup.SmallIconList = iBmp.CreateFileFromResourceBitmap(groupData.Icons[1], groupData.IconAssembly); cmdGroup.LargeMainIcon = iBmp.CreateFileFromResourceBitmap(groupData.Icons[2], groupData.IconAssembly); cmdGroup.SmallMainIcon = iBmp.CreateFileFromResourceBitmap(groupData.Icons[3], groupData.IconAssembly); //添加按钮 int CommandIndex = 0; int j = 0; List <Dictionary <int, KeyValuePair <CommandType, int> > >[] tabIds = new List <Dictionary <int, KeyValuePair <CommandType, int> > > [3]; foreach (var docConfig in config)//文档 { tabIds[j] = new List <Dictionary <int, KeyValuePair <CommandType, int> > >(); foreach (var properties in docConfig)//属性 { Dictionary <int, KeyValuePair <CommandType, int> > boxIds = new Dictionary <int, KeyValuePair <CommandType, int> >(); foreach (var item in properties.Value)//Commands { var keyvalue = AddCommnad(scope, item, ref cmdGroup, CommandIndex); boxIds.Add(keyvalue.Key, keyvalue.Value); CommandIndex++; } if (boxIds.Count > 0) { tabIds[j].Add(boxIds); } } j++; } cmdGroup.HasToolbar = true; cmdGroup.HasMenu = true; cmdGroup.Activate(); //cmdGroup.sho //排列按钮 foreach (var type in docTypes) { //此种文档类型无按钮,则跳出 int arrayIndex = 0; switch (type) { case swDocumentTypes_e.swDocPART: arrayIndex = 0; break; case swDocumentTypes_e.swDocASSEMBLY: arrayIndex = 1; break; case swDocumentTypes_e.swDocDRAWING: arrayIndex = 2; break; default: throw new InvalidOperationException($"Can not add CommandTabBox with {type.ToString()}"); } if (tabIds[arrayIndex].Count < 1) { break; } CommandTab cmdTab; cmdTab = iCmdMgr.GetCommandTab(type.SWToInt(), groupData.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 == null) { cmdTab = iCmdMgr.AddCommandTab(type.SWToInt(), groupData.Title); switch (type) { case swDocumentTypes_e.swDocPART: AddCmdbox(tabIds[0], ref cmdGroup, ref cmdTab); break; case swDocumentTypes_e.swDocASSEMBLY: AddCmdbox(tabIds[1], ref cmdGroup, ref cmdTab); break; case swDocumentTypes_e.swDocDRAWING: AddCmdbox(tabIds[2], ref cmdGroup, ref cmdTab); break; default: throw new InvalidOperationException($"Can not add CommandTabBox with {type.ToString()}"); } cmdTab.Visible = true; cmdTab.Active = true; var obj = cmdTab.CommandTabBoxes() as object[]; int count = cmdTab.GetCommandTabBoxCount(); foreach (CommandTabBox item in obj) { item.GetCommands(out object ids, out object styles); } } } return(cmdGroup); }
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; }
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(); }