void CreateNavigationCommands(Commands commands) { var previousCmd = commands.AddNamedCommand( m_addIn, "GotoPrevious", "goto previous location", "Goto the previous location in the current navigation list.", false, 0, vsCommandDisabledFlagsValue: (int) vsCommandStatus.vsCommandStatusEnabled | (int) vsCommandStatus.vsCommandStatusSupported ); previousCmd.Bindings = "Global::Alt+Left Arrow"; var nextCmd = commands.AddNamedCommand( m_addIn, "GotoNext", "goto next location", "Goto the next location in the current navigation list.", false, 0, vsCommandDisabledFlagsValue: (int) vsCommandStatus.vsCommandStatusEnabled | (int) vsCommandStatus.vsCommandStatusSupported ); nextCmd.Bindings = "Global::Alt+Right Arrow"; }
/// <summary> /// Implements the OnConnection method of the IDTExtensibility2 interface. /// Receives notification that the Add-in is being loaded. /// </summary> /// <param term='application'> /// Root object of the host application. /// </param> /// <param term='connectMode'> /// Describes how the Add-in is being loaded. /// </param> /// <param term='addInInst'> /// Object representing this Add-in. /// </param> /// <seealso class='IDTExtensibility2' /> public void OnConnection(object application, Extensibility.ext_ConnectMode connectMode, object addInInst, ref System.Array custom) { Debug.WriteLine("DemoAddin: OnConnection() method called"); applicationObject = (_DTE)application; addInInstance = (AddIn)addInInst; if (connectMode == Extensibility.ext_ConnectMode.ext_cm_UISetup) { object [] contextGUIDS = new object[] { }; Commands commands = applicationObject.Commands; _CommandBars commandBars = applicationObject.CommandBars; // When run, the Add-in wizard prepared the registry for the Add-in. // At a later time, the Add-in or its commands may become unavailable for reasons such as: // 1) You moved this project to a computer other than which is was originally created on. // 2) You chose 'Yes' when presented with a message asking if you wish to remove the Add-in. // 3) You add new commands or modify commands already defined. // You will need to re-register the Add-in by building the DemoAddinSetup project, // right-clicking the project in the Solution Explorer, and then choosing install. // Alternatively, you could execute the ReCreateCommands.reg file the Add-in Wizard generated in // the project directory, or run 'devenv /setup' from a command prompt. try { Command command = commands.AddNamedCommand(addInInstance, "DemoAddin", "DemoAddin", "Executes the command for DemoAddin", true, 59, ref contextGUIDS, (int)vsCommandStatus.vsCommandStatusSupported + (int)vsCommandStatus.vsCommandStatusEnabled); CommandBar commandBar = (CommandBar)commandBars["Tools"]; CommandBarControl commandBarControl = command.AddControl(commandBar, 1); } catch (System.Exception /*e*/) { } } }
/// <summary> /// Creates a Named command. /// </summary> /// <param name="addInInstance">Addin Instance</param> /// <param name="cmdCollectionContainer">Collection of Command objects</param> /// <param name="strCtrlName">The control name</param> /// <param name="strCtrlCaption">The control caption</param> /// <param name="strCtrlToolTip">Text for tool tip</param> /// <param name="contextGUIDS"></param> /// <returns>Returns a newly create Command object or null if it fails</returns> protected Command CreateNamedCommand(AddIn addInInstance, Commands cmdCollectionContainer, string strCtrlName, string strCtrlCaption, string strCtrlToolTip, ref object[] contextGUIDS) { Command cmdRetVal = null; try { cmdRetVal = cmdCollectionContainer.AddNamedCommand( addInInstance, strCtrlName, strCtrlCaption, strCtrlToolTip, true, 0, ref contextGUIDS, (int)vsCommandStatus.vsCommandStatusSupported + (int)vsCommandStatus.vsCommandStatusEnabled ); } catch (System.Exception exc) { Trace.WriteLine(String.Format("Exception caught in Adding Command1:\n {0}", exc.Message)); Trace.WriteLine(String.Format("Number of commands:\n {0}", cmdCollectionContainer.Count)); } return(cmdRetVal); }
void add_or_replace_command(int iconStartNumber) { object [] contextGUIDS = new object[] { }; Commands commands = applicationObject.Commands; _CommandBars commandBars = applicationObject.CommandBars; try { System.Collections.IEnumerator enm = commands.GetEnumerator(); while (enm.MoveNext()) { Command cmd = (Command)enm.Current; if (cmd.Name == "MultiLineFindReplace.Connect.MultiLineFindReplace") { cmd.Delete(); } } System.Diagnostics.Debug.WriteLine("---> iconNumber = " + iconNumber.ToString()); System.Diagnostics.Debug.WriteLine("---> iconStartNumber = " + iconStartNumber.ToString()); if (iconNumber < iconStartNumber) { iconNumber = iconStartNumber; } Command command = commands.AddNamedCommand(addInInstance, "MultiLineFindReplace", "Find and Replace (Multi-line)", "Find and Replace with multi-line search and replacement strings", true, /*1202*/ iconNumber++, ref contextGUIDS, (int)vsCommandStatus.vsCommandStatusSupported + (int)vsCommandStatus.vsCommandStatusEnabled); CommandBar commandBar = (CommandBar)commandBars["Edit"]; CommandBarControl commandBarControl = command.AddControl(commandBar, 1); } catch (System.Exception e /*e*/) { MessageBox.Show("Exception in MultiLineFindReplace add_or_replace_command: " + e.Message); } }
private void AddCommand(CommandBar commandBar, string name, string buttonText, string toolTip, bool addToCommandBar, int bitMap, string bindings, bool beginGroup) { object [] contextGUIDS = new object[] { }; Commands commands = DebugInfo.applicationObject.Commands; Command command = null; try //try to retrieve the command with the name { command = commands.Item(addInInstance.ProgID + "." + name, -1); } catch {} if (command == null) //if not retrieved, add the command with the name { if (bitMap == 0) { command = commands.AddNamedCommand(addInInstance, name, buttonText, toolTip, true, 59, ref contextGUIDS, (int)vsCommandStatus.vsCommandStatusEnabled); } else { command = commands.AddNamedCommand(addInInstance, name, buttonText, toolTip, false, bitMap, ref contextGUIDS, (int)vsCommandStatus.vsCommandStatusEnabled); } } try { if (bindings != "") { command.Bindings = bindings; } } catch {} if (addToCommandBar) { CommandBarButton commandBarButton = (CommandBarButton)command.AddControl(commandBar, commandBar.Controls.Count + 1); commandBarButton.Tag = "TachyExtension.Connect." + name; commandBarButton.Style = MsoButtonStyle.msoButtonIcon; commandBarButton.BeginGroup = beginGroup; } }
/// <summary>Implements the OnConnection method of the IDTExtensibility2 interface. Receives notification that the Add-in is being loaded.</summary> /// <param term='application'>Root object of the host application.</param> /// <param term='connectMode'>Describes how the Add-in is being loaded.</param> /// <param term='addInInst'>Object representing this Add-in.</param> /// <seealso class='IDTExtensibility2' /> public void OnConnection(object application, ext_ConnectMode connectMode, object addInInst, ref Array custom) { _applicationObject = (DTE2)application; _addInInstance = (AddIn)addInInst; if (connectMode == ext_ConnectMode.ext_cm_UISetup) { object[] contextGUIDS = new object[] { }; Commands commands = _applicationObject.Commands; CommandBars commandBars = ((CommandBars)_applicationObject.CommandBars); // When run, the Add-in wizard prepared the registry for the Add-in. // At a later time, the Add-in or its commands may become unavailable for reasons such as: // 1) You moved this project to a computer other than which is was originally created on. // 2) You chose 'Yes' when presented with a message asking if you wish to remove the Add-in. // 3) You add new commands or modify commands already defined. // You will need to re-register the Add-in by building the FunctionsAddInSetup project, // right-clicking the project in the Solution Explorer, and then choosing install. // Alternatively, you could execute the ReCreateCommands.reg file the Add-in Wizard generated in // the project directory, or run 'devenv /setup' from a command prompt. try { CommandBar commandBar = (CommandBar)commandBars["Code Window"]; Command command; CommandBarControl commandBarControl; command = commands.AddNamedCommand(_addInInstance, "RunTest", "Run Test", "Build the project and run the selected test or tests.", true, 186, ref contextGUIDS, (int)vsCommandStatus.vsCommandStatusSupported + (int)vsCommandStatus.vsCommandStatusEnabled); commandBarControl = ((CommandBarControl)command.AddControl(commandBar, 1)); command = commands.AddNamedCommand(_addInInstance, "StopTest", "Stop Test", "Stop the currently running test.", true, 184, ref contextGUIDS, (int)vsCommandStatus.vsCommandStatusSupported + (int)vsCommandStatus.vsCommandStatusEnabled); commandBarControl = ((CommandBarControl)command.AddControl(commandBar, 1)); } catch (Exception /*e*/) { } } }
public static EnvDTE.Command ReplaceCommandInMenu( EnvDTE.AddIn addInInstance, EnvDTE._DTE applicationObject, int iconNumber, string progID, string commandName, string commandButtonText, string commandDescription, string commandBarName ) { object [] contextGUIDS = new object[] { }; Commands commands = applicationObject.Commands; _CommandBars commandBars = applicationObject.CommandBars; try { Command command = FindCommand(commands, progID + "." + commandName); if (command != null) // if we found one { command.Delete(); // delete it as we're going to replace it } // call commands.AddNamedCommand to add it command = commands.AddNamedCommand( addInInstance, commandName, commandButtonText, commandDescription, true, iconNumber, ref contextGUIDS, (int)vsCommandStatus.vsCommandStatusSupported + (int)vsCommandStatus.vsCommandStatusEnabled); CommandBar commandBar = (CommandBar)commandBars[commandBarName]; CommandBarControl commandBarControl = command.AddControl(commandBar, 1); return(command); } catch (System.Exception e) { MessageBox.Show("Exception in ReplaceCommandInMenu: " + e.Message); return(null); } }
/// <summary> /// Creates a Named command. /// </summary> /// <param name="addInInstance">Addin Instance</param> /// <param name="cmdCollectionContainer">Collection of Command objects</param> /// <param name="strCtrlName">The control name</param> /// <param name="strCtrlCaption">The control caption</param> /// <param name="strCtrlToolTip">Text for tool tip</param> /// <param name="contextGUIDS"></param> /// <returns>Returns a newly create Command object or null if it fails</returns> protected Command CreateNamedCommand(AddIn addInInstance, Commands cmdCollectionContainer, string strCtrlName, string strCtrlCaption, string strCtrlToolTip, ref object[] contextGUIDS) { Command cmdRetVal = null; try { cmdRetVal = cmdCollectionContainer.AddNamedCommand( addInInstance, strCtrlName, strCtrlCaption, strCtrlToolTip, true, 0, ref contextGUIDS, (int)vsCommandStatus.vsCommandStatusSupported + (int)vsCommandStatus.vsCommandStatusEnabled ); } catch (System.Exception exc) { Trace.WriteLine(String.Format("Exception caught in Adding Command1:\n {0}", exc.Message)); Trace.WriteLine(String.Format("Number of commands:\n {0}", cmdCollectionContainer.Count)); } return cmdRetVal; }
public void registerCommands() { registerCommandBar(); registerPrjCommandBar(); registerSlnCommandBar(); object[] contextGUIDS = new object[] { }; try { CommandBar cmdBar = qtPopup.CommandBar; CommandBar cmdPrjBar = prjPopup.CommandBar; CommandBar cmdSlnBar = slnPopup.CommandBar; if (cmdBar == null) { throw new Qt4VSException(SR.GetString("CommandBarNotFound")); } int disableFlags = (int)vsCommandStatus.vsCommandStatusSupported + (int)vsCommandStatus.vsCommandStatusEnabled; Command cmd = null; int posBeforeProperties = cmdProjectContext.Controls.Count - 1; // Launch Designer command cmd = cmds.AddNamedCommand(Connect._addInInstance, Res.LaunchDesigner, SR.GetString("LaunchDesignerButtonText"), SR.GetString("LaunchDesignerToolTip"), false, Res.DesignerBitmapID, ref contextGUIDS, disableFlags); CommandBarButton ctrl = (CommandBarButton)cmd.AddControl(cmdBar, cmdBar.Controls.Count + 1); ctrl.Caption = SR.GetString("LaunchDesignerButtonText"); // Launch Linguist command cmd = cmds.AddNamedCommand(Connect._addInInstance, Res.LaunchLinguist, SR.GetString("LaunchLinguistButtonText"), SR.GetString("LaunchLinguistToolTip"), false, Res.LinguistBitmapID, ref contextGUIDS, disableFlags); ctrl = (CommandBarButton)cmd.AddControl(cmdBar, cmdBar.Controls.Count + 1); ctrl.Caption = SR.GetString("LaunchLinguistButtonText"); // Launch Assistant command cmd = cmds.AddNamedCommand(Connect._addInInstance, Res.LaunchAssistant, SR.GetString("LaunchAssistantButtonText"), SR.GetString("LaunchAssistantToolTip"), false, Res.AssistantBitmapID, ref contextGUIDS, disableFlags); ctrl = (CommandBarButton)cmd.AddControl(cmdBar, cmdBar.Controls.Count + 1); ctrl.Caption = SR.GetString("LaunchAssistantButtonText"); // Import pro file command cmd = cmds.AddNamedCommand(Connect._addInInstance, Res.ImportProFile, SR.GetString("ImportProFileButtonText"), SR.GetString("ImportProFileToolTip"), false, Res.ImportProFileBitmapID, ref contextGUIDS, disableFlags); ctrl = (CommandBarButton)cmd.AddControl(cmdBar, cmdBar.Controls.Count + 1); ctrl.BeginGroup = true; ctrl.Caption = SR.GetString("ImportProFileButtonText"); // Import pri file command cmd = cmds.AddNamedCommand(Connect._addInInstance, Res.ImportPriFile, SR.GetString("ImportPriFileButtonText"), SR.GetString("ImportPriFileToolTip"), false, Res.ImportPriFileBitmapID, ref contextGUIDS, disableFlags); ctrl = (CommandBarButton)cmd.AddControl(cmdPrjBar, cmdPrjBar.Controls.Count + 1); ctrl.Caption = SR.GetString("ImportPriFileButtonText"); ctrl.BeginGroup = true; ctrl = (CommandBarButton)cmd.AddControl(cmdBar, cmdBar.Controls.Count + 1); ctrl.Caption = SR.GetString("ImportPriFileButtonText"); // Export pri file command cmd = cmds.AddNamedCommand(Connect._addInInstance, Res.ExportPriFile, SR.GetString("ExportPriFileButtonText"), SR.GetString("ExportPriFileToolTip"), false, Res.ExportPriFileBitmapID, ref contextGUIDS, disableFlags); ctrl = (CommandBarButton)cmd.AddControl(cmdPrjBar, cmdPrjBar.Controls.Count + 1); ctrl.Caption = SR.GetString("ExportPriFileButtonText"); ctrl = (CommandBarButton)cmd.AddControl(cmdBar, cmdBar.Controls.Count + 1); ctrl.Caption = SR.GetString("ExportPriFileButtonText"); // Export pro file command cmd = cmds.AddNamedCommand(Connect._addInInstance, Res.ExportProFile, SR.GetString("ExportProFileButtonText"), SR.GetString("ExportProFileToolTip"), false, Res.ExportProFileBitmapID, ref contextGUIDS, disableFlags); ctrl = (CommandBarButton)cmd.AddControl(cmdPrjBar, cmdPrjBar.Controls.Count + 1); ctrl.Caption = SR.GetString("ExportProFileButtonText"); ctrl = (CommandBarButton)cmd.AddControl(cmdBar, cmdBar.Controls.Count + 1); ctrl.Caption = SR.GetString("ExportProFileButtonText"); // Create new translation file command cmd = cmds.AddNamedCommand(Connect._addInInstance, Res.CreateNewTranslationFile, SR.GetString("CreateNewTranslationFileButtonText"), SR.GetString("CreateNewTranslationFileToolTip"), false, Res.CreateNewTranslationFileBitmapID, ref contextGUIDS, disableFlags); ctrl = (CommandBarButton)cmd.AddControl(cmdPrjBar, cmdPrjBar.Controls.Count + 1); ctrl.Caption = SR.GetString("CreateNewTranslationFileButtonText"); ctrl.BeginGroup = true; ctrl = (CommandBarButton)cmd.AddControl(cmdBar, cmdBar.Controls.Count + 1); ctrl.Caption = SR.GetString("CreateNewTranslationFileButtonText"); ctrl.BeginGroup = true; // lupdateProject command cmd = cmds.AddNamedCommand(Connect._addInInstance, Res.lupdateProject, SR.GetString("lupdateProjectButtonText"), null, false, Res.LinguistBitmapID, ref contextGUIDS, disableFlags); ctrl = (CommandBarButton)cmd.AddControl(cmdPrjBar, cmdPrjBar.Controls.Count + 1); ctrl.Caption = SR.GetString("lupdateProjectButtonText"); // lreleaseProject command cmd = cmds.AddNamedCommand(Connect._addInInstance, Res.lreleaseProject, SR.GetString("lreleaseProjectButtonText"), null, false, Res.LinguistBitmapID, ref contextGUIDS, disableFlags); ctrl = (CommandBarButton)cmd.AddControl(cmdPrjBar, cmdPrjBar.Controls.Count + 1); ctrl.Caption = SR.GetString("lreleaseProjectButtonText"); // lupdateSolution command cmd = cmds.AddNamedCommand(Connect._addInInstance, Res.lupdateSolution, SR.GetString("lupdateSolutionButtonText"), null, false, Res.LinguistBitmapID, ref contextGUIDS, disableFlags); ctrl = (CommandBarButton)cmd.AddControl(cmdSlnBar, cmdSlnBar.Controls.Count + 1); ctrl.Caption = SR.GetString("lupdateSolutionButtonText"); ctrl.BeginGroup = true; // lreleaseSolution command cmd = cmds.AddNamedCommand(Connect._addInInstance, Res.lreleaseSolution, SR.GetString("lreleaseSolutionButtonText"), null, false, Res.LinguistBitmapID, ref contextGUIDS, disableFlags); ctrl = (CommandBarButton)cmd.AddControl(cmdSlnBar, cmdSlnBar.Controls.Count + 1); ctrl.Caption = SR.GetString("lreleaseSolutionButtonText"); // ConvertToQt command cmd = cmds.AddNamedCommand(Connect._addInInstance, Res.ConvertToQt, SR.GetString("ConvertToQtButtonText"), SR.GetString("ConvertToQtToolTip"), false, Res.ProjectQtSettingsBitmapID, ref contextGUIDS, disableFlags); ctrl = (CommandBarButton)cmd.AddControl(cmdPrjBar, cmdPrjBar.Controls.Count + 1); ctrl.Caption = SR.GetString("ConvertToQtButtonText"); ctrl.BeginGroup = true; ctrl = (CommandBarButton)cmd.AddControl(cmdBar, cmdBar.Controls.Count + 1); ctrl.Caption = SR.GetString("ConvertToQtButtonText"); // ConvertToQMake command cmd = cmds.AddNamedCommand(Connect._addInInstance, Res.ConvertToQMake, SR.GetString("ConvertToQMakeButtonText"), SR.GetString("ConvertToQMakeToolTip"), false, Res.ProjectQtSettingsBitmapID, ref contextGUIDS, disableFlags); ctrl = (CommandBarButton)cmd.AddControl(cmdPrjBar, cmdPrjBar.Controls.Count + 1); ctrl.Caption = SR.GetString("ConvertToQMakeButtonText"); ctrl.BeginGroup = true; ctrl = (CommandBarButton)cmd.AddControl(cmdBar, cmdBar.Controls.Count + 1); ctrl.Caption = SR.GetString("ConvertToQMakeButtonText"); // ProjectQtSettings command cmd = cmds.AddNamedCommand(Connect._addInInstance, Res.ProjectQtSettings, SR.GetString("ProjectQtSettingsButtonText"), SR.GetString("ProjectQtSettingsToolTip"), false, Res.ProjectQtSettingsBitmapID, ref contextGUIDS, disableFlags); ctrl = (CommandBarButton)cmd.AddControl(cmdPrjBar, cmdPrjBar.Controls.Count + 1); ctrl.Caption = SR.GetString("ProjectQtSettingsButtonText"); ctrl.BeginGroup = true; ctrl = (CommandBarButton)cmd.AddControl(cmdBar, cmdBar.Controls.Count + 1); ctrl.Caption = SR.GetString("ProjectQtSettingsButtonText"); // ChangeProjectQtVersion command cmd = cmds.AddNamedCommand(Connect._addInInstance, Res.ChangeProjectQtVersion, SR.GetString("ChangeProjectQtVersionButtonText"), null, false, Res.ChangeProjectQtVersionBitmapID, ref contextGUIDS, disableFlags); ctrl = (CommandBarButton)cmd.AddControl(cmdPrjBar, cmdPrjBar.Controls.Count + 1); ctrl.Caption = SR.GetString("ChangeProjectQtVersionButtonText"); ctrl.BeginGroup = true; ctrl = (CommandBarButton)cmd.AddControl(cmdBar, cmdBar.Controls.Count + 1); ctrl.Caption = SR.GetString("ChangeProjectQtVersionButtonText"); // VSQtOptions command cmd = cmds.AddNamedCommand(Connect._addInInstance, Res.VSQtOptions, SR.GetString("VSQtOptionsButtonText"), SR.GetString("VSQtOptionsToolTip"), false, Res.VSQtOptionsBitmapID, ref contextGUIDS, disableFlags); ctrl = (CommandBarButton)cmd.AddControl(cmdBar, cmdBar.Controls.Count + 1); ctrl.Caption = SR.GetString("VSQtOptionsButtonText"); ctrl.BeginGroup = true; // Change Soltuion Qt version command cmd = cmds.AddNamedCommand(Connect._addInInstance, Res.ChangeSolutionQtVersion, SR.GetString("ChangeSolutionQtVersionButtonText"), SR.GetString("ChangeSolutionQtVersionToolTip"), false, Res.QtBitmapID, ref contextGUIDS, disableFlags); ctrl = (CommandBarButton)cmd.AddControl(cmdSlnBar, cmdSlnBar.Controls.Count + 1); ctrl.Caption = SR.GetString("ChangeSolutionQtVersionButtonText"); ctrl.BeginGroup = true; cmd = cmds.AddNamedCommand(Connect._addInInstance, "lupdate", "lupdate", "lupdate", false, Res.LinguistBitmapID, ref contextGUIDS, disableFlags); posBeforeProperties = cmdItemContext.Controls.Count; ctrl = (CommandBarButton)cmd.AddControl(cmdItemContext, posBeforeProperties++); ctrl.Caption = "lupdate"; ctrl.BeginGroup = true; cmd = cmds.AddNamedCommand(Connect._addInInstance, "lrelease", "lrelease", "lrelease", false, Res.LinguistBitmapID, ref contextGUIDS, disableFlags); posBeforeProperties = cmdItemContext.Controls.Count; ctrl = (CommandBarButton)cmd.AddControl(cmdItemContext, posBeforeProperties++); ctrl.Caption = "lrelease"; } catch (System.Exception e) { MessageBox.Show(SR.GetString("CommandsNotRegistered") + " : " + e.Message + "\r\n" + e.StackTrace.ToString()); } }
void CreateNavigationModeCommands(Commands commands) { foreach (var item in NavigationTargetList.Default.Values) { var cmd = commands.AddNamedCommand( m_addIn, string.Format("Navigate{0}", item.Name), string.Format("Navigate {0}", item.Name), string.Format("Change the navigation mode to '{0}'", item.Description), false, 0, vsCommandDisabledFlagsValue: (int) vsCommandStatus.vsCommandStatusEnabled | (int) vsCommandStatus.vsCommandStatusSupported ); cmd.Bindings = new object[] { string.Format("Global::ALT+N,ALT+{0}", item.Key), string.Format("Global::ALT+N,{0}", item.Key) }; } }
void CreateRegisterCommands(Commands commands) { foreach (var item in EmacsRegisterList.Default.Values) { var copyCmdName = string.Format("CopyRegister{0}", item.Name); var copyCmd = commands.AddNamedCommand( m_addIn, copyCmdName, string.Format("Copy Register {0}", item.Name), string.Format("Copy Register {0}", item.Name), false, 0, vsCommandDisabledFlagsValue: (int) vsCommandStatus.vsCommandStatusEnabled | (int) vsCommandStatus.vsCommandStatusSupported ); var pasteCmd = commands.AddNamedCommand( m_addIn, string.Format("PasteRegister{0}", item.Name), string.Format("Paste Register {0}", item.Name), string.Format("Paste Register {0}", item.Name), false, 0, vsCommandDisabledFlagsValue: (int) vsCommandStatus.vsCommandStatusEnabled | (int) vsCommandStatus.vsCommandStatusSupported ); if (item.Key != null) { copyCmd.Bindings = new object[] { String.Format("Global::ALT+C, ALT+{0}", item.Key), String.Format("Global::ALT+C, {0}", item.Key) }; pasteCmd.Bindings = new object[] { String.Format("Global::ALT+V, ALT+{0}", item.Key), String.Format("Global::ALT+V, {0}", item.Key) }; } } }
/// <summary> /// Implements the OnConnection method of the IDTExtensibility2 interface. /// Receives notification that the Add-in is being loaded. /// </summary> /// <param term='application'> /// Root object of the host application. /// </param> /// <param term='connectMode'> /// Describes how the Add-in is being loaded. /// </param> /// <param term='addInInst'> /// Object representing this Add-in. /// </param> /// <seealso class='IDTExtensibility2' /> public void OnConnection(object application, Extensibility.ext_ConnectMode connectMode, object addInInst, ref System.Array custom) { applicationObject = (_DTE)application; addInInstance = (AddIn)addInInst; //if(connectMode == Extensibility.ext_ConnectMode.ext_cm_Startup) if (true) { object [] contextGUIDS = new object[] { }; Commands commands = applicationObject.Commands; _CommandBars commandBars = applicationObject.CommandBars; // When run, the Add-in wizard prepared the registry for the Add-in. // At a later time, the Add-in or its commands may become unavailable for reasons such as: // 1) You moved this project to a computer other than which is was originally created on. // 2) You chose 'Yes' when presented with a message asking if you wish to remove the Add-in. // 3) You add new commands or modify commands already defined. // You will need to re-register the Add-in by building the MultiLineFindReplaceSetup project, // right-clicking the project in the Solution Explorer, and then choosing install. // Alternatively, you could execute the ReCreateCommands.reg file the Add-in Wizard generated in // the project directory, or run 'devenv /setup' from a command prompt. try { /*Command command = commands.Item("MultiLineFindReplace.Connect.MultiLineFindReplace", 0); * if (command != null) * { * command.Delete(); * }*/ System.Collections.IEnumerator enm = commands.GetEnumerator(); while (enm.MoveNext()) { Command cmd = (Command)enm.Current; if (cmd.Name == "MultiLineFindReplace.Connect.MultiLineFindReplace") { cmd.Delete(); } // System.Diagnostics.Debug.WriteLine(cmd.Name + ":" + cmd.ID.ToString() + ":" + cmd.ToString()); } Command command = commands.AddNamedCommand(addInInstance, "MultiLineFindReplace", "Find and Replace (Multi-line)", "Find and Replace with multi-line search and replacement strings", true, /*140=binocular w/file*/ /*183=binocular w/doc*/ /* 621 star w/data model *//* 570 binocular w/arrow*/ 570, ref contextGUIDS, (int)vsCommandStatus.vsCommandStatusSupported + (int)vsCommandStatus.vsCommandStatusEnabled); CommandBar commandBar = (CommandBar)commandBars["Edit"]; foreach (CommandBar cb in commandBars) { if (cb.Name[0] == 'F') { Debug.WriteLine(cb.Name + ":::"); } } //CommandBar commandBar2 = (CommandBar)commandBars["Find and Replace"]; foreach (CommandBarControl c in commandBar.Controls) { Debug.WriteLine(c.Tag + ":::" + c.TooltipText + ":::" + c.Type.ToString()); } CommandBarControl commandBarControl = command.AddControl(commandBar, 1); } catch (System.Exception e /*e*/) { MessageBox.Show("Exception in MultiLineFindReplace OnConnection: " + e.Message); } } }