用C#创建了一个solidworks的插件,自带例子代码。在注释了相关代码后,界面有没发生改变
public void AddCommandMgr()
{
ICommandGroup cmdGroup;
if (iBmp == null)
iBmp = new BitmapHandler();
Assembly thisAssembly;
int cmdIndex0, cmdIndex1;
string Title = "制造云软件", ToolTip = "制造云软件";
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("DrawingTransformExpert.ToolbarLarge.bmp", thisAssembly);
cmdGroup.SmallIconList = iBmp.CreateFileFromResourceBitmap("DrawingTransformExpert.ToolbarSmall.bmp", thisAssembly);
cmdGroup.LargeMainIcon = iBmp.CreateFileFromResourceBitmap("DrawingTransformExpert.MainIconLarge.bmp", thisAssembly);
cmdGroup.SmallMainIcon = iBmp.CreateFileFromResourceBitmap("DrawingTransformExpert.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_TextBelow;
cmdIDs[1] = cmdGroup.get_CommandID(cmdIndex1);
TextType[1] = (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;
}
上述代码,我注释的部分应该不显示
上图中红色圈中的应该不显示呢