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(); }
public void AddCommandMgr() { AddTaskPane(); ICommandGroup cmdGroup; BitmapHandler iBmp = new BitmapHandler(); Assembly thisAssembly; thisAssembly = System.Reflection.Assembly.GetAssembly(this.GetType()); cmdGroup = iCmdMgr.CreateCommandGroup(1, "FTL AMF Visualizer", "FTL AMF Visualizer", "", -1); cmdGroup.LargeIconList = iBmp.CreateFileFromResourceBitmap("qwe.ToolbarLarge.bmp", thisAssembly); cmdGroup.SmallIconList = iBmp.CreateFileFromResourceBitmap("qwe.ToolbarSmall.bmp", thisAssembly); cmdGroup.LargeMainIcon = iBmp.CreateFileFromResourceBitmap("qwe.ToolbarLarge.bmp", thisAssembly); cmdGroup.SmallMainIcon = iBmp.CreateFileFromResourceBitmap("qwe.ToolbarSmall.bmp", thisAssembly); //cmdGroup.AddCommandItem("CreateCube", -1, "Create a cube", "Create cube", 0, "CreateCube", "", 0); //cmdGroup.AddCommandItem("Show PMP", -1, "Display sample property manager", "Show PMP", 2, "ShowPMP", "EnablePMP", 2); cmdGroup.AddCommandItem("ImportDMC", -1, "Import a DMC file", "Import a DMC file", 0, "importDMC", "", 0); //cmdGroup.AddCommandItem("AddTaskPane", -1, "Adds Features and Taskpane and Toolbars", "Adds Features and Taskpane and Toolbars", 2, "AddTaskPane", "", 2); cmdGroup.HasToolbar = true; cmdGroup.HasMenu = true; cmdGroup.Activate(); thisAssembly = null; iBmp.Dispose(); }
public void AddCommandMgr() { var iBmp = new BitmapHandler(); const string title = "MrDoors"; const string toolTip = "MrDoors addin"; var docTypes = new[] { (int) swDocumentTypes_e.swDocASSEMBLY, (int) swDocumentTypes_e.swDocDRAWING, (int) swDocumentTypes_e.swDocPART }; Assembly thisAssembly = Assembly.GetAssembly(GetType()); ICommandGroup cmdGroup = _iCmdMgr.CreateCommandGroup(1, title, toolTip, "", -1); cmdGroup.LargeIconList = iBmp.CreateFileFromResourceBitmap("Furniture.ToolbarLarge.bmp", thisAssembly); cmdGroup.SmallIconList = iBmp.CreateFileFromResourceBitmap("Furniture.ToolbarSmall.bmp", thisAssembly); cmdGroup.LargeMainIcon = iBmp.CreateFileFromResourceBitmap("Furniture.MainIconLarge.bmp", thisAssembly); cmdGroup.SmallMainIcon = iBmp.CreateFileFromResourceBitmap("Furniture.MainIconSmall.bmp", thisAssembly); int cmdIndex00 = cmdGroup.AddCommandItem("MrDoors ���", -1, "", "", -1, "ShowSetParameters", "ShowSetParametersEnable", 0); int cmdIndex0 = cmdGroup.AddCommandItem("����������� ��������� ����������", -1, "", "", 0, "SaveAsComponents", "SaveAsComponentsEnable", 0); int cmdIndex1 = cmdGroup.AddCommandItem("����������� ������������ �������", -1, "", "", 2, "RecalculateRanges", "RecalculateRangesEnable", 0); int cmdIndex7 = cmdGroup.AddCommandItem("����������� ��������� ��� ������(�� �������)", -1, "", "", 2, "CutOffDetail", "SaveAsComponentsEnable", 0); int cmdIndex2 = cmdGroup.AddCommandItem("������� ��������� ��� ���������", -1, "", "", -1, "CutOff", "CutOffEnable", 0); int cmdIndex3 = cmdGroup.AddCommandItem("���������� �������", -1, "", "", -1, "CopyDrawings", "CopyDrawingsEnable", 0); int cmdIndex4 = cmdGroup.AddCommandItem("", -1, "", "", -1, "ShowOptions", "", 0); int cmdIndex5 = cmdGroup.AddCommandItem("���������", -1, "", "", 0, "ShowOptions", "", 0); int cmdIndex6 = cmdGroup.AddCommandItem("������� ��� �������", -1, "", "", -1, "OpenDrawings", "OpenDrawingsEnable", 0); cmdGroup.HasToolbar = true; cmdGroup.HasMenu = true; cmdGroup.Activate(); bool bResult; foreach (int type in docTypes) { ICommandTab cmdTab = _iCmdMgr.GetCommandTab(type, title); if (cmdTab == null) { cmdTab = _iCmdMgr.AddCommandTab(type, title); CommandTabBox cmdBox = cmdTab.AddCommandTabBox(); var cmdIDs = new int[6]; var 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.ToolbarId; System.Diagnostics.Debug.Print(cmdIDs[4].ToString()); textType[4] = (int)swCommandTabButtonTextDisplay_e.swCommandTabButton_TextHorizontal | (int)swCommandTabButtonFlyoutStyle_e.swCommandTabButton_ActionFlyout; cmdIDs[5] = cmdGroup.get_CommandID(cmdIndex6); System.Diagnostics.Debug.Print(cmdGroup.get_CommandID(cmdIndex6).ToString()); textType[5] = (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() { 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(); }