/// <summary> /// Initializes a new instance of the <see cref="VSMenuCommand"/> class. /// </summary> /// <param name="name">The name.</param> /// <param name="displayName">The display name.</param> /// <param name="description">The description.</param> public VSMenuCommand(VSMenu menu, string name, string displayName, string description) { _menu = menu; _name = name; _displayName = displayName; _description = description; object[] contextGUIDS = new object[] { }; Commands2 commands = (Commands2)menu.VSAddin.ApplicationObject.Commands; try { _command = commands.AddNamedCommand2(menu.VSAddin.AddInInstance, name, displayName, description, true, 0, ref contextGUIDS, (int)vsCommandStatus.vsCommandStatusSupported + (int)vsCommandStatus.vsCommandStatusEnabled, (int)vsCommandStyle.vsCommandStylePictAndText, vsCommandControlType.vsCommandControlTypeButton); } catch { // If we get here then the command name probably already exists. _command = commands.Item(menu.VSAddin.AddInInstance.ProgID + "." + name, 0); } _button = (CommandBarButton)_command.AddControl(_menu.Popup.CommandBar, 1); }
public virtual void OnConnection(object Application, ext_ConnectMode connectMode, object AddInInst, ref Array custom) { this._applicationObject = (DTE2)Application; this._addInInstance = (AddIn)AddInInst; this._connectMode = connectMode; if (this.ConnectMode == ext_ConnectMode.ext_cm_Startup) { this._rootMenu = this.SetupMenuItems(); } }
public VSMenuCommand(VSMenu menu, string name, string displayName, string description) { this._menu = menu; this._name = name; this._displayName = displayName; this._description = description; object[] array = new object[0]; Commands2 commands = (Commands2)menu.VSAddin.ApplicationObject.Commands; try { this._command = commands.AddNamedCommand2(menu.VSAddin.AddInInstance, name, displayName, description, true, 0, ref array, 3, 3, vsCommandControlType.vsCommandControlTypeButton); } catch { this._command = commands.Item(menu.VSAddin.AddInInstance.ProgID + "." + name, 0); } this._button = (CommandBarButton)this._command.AddControl(this._menu.Popup.CommandBar, 1); }
protected override VSMenu SetupMenuItems() { VSMenu vSMenu = new VSMenu(this, "Build Version Increment"); VSMenuCommand vSMenuCommand = vSMenu.AddCommand("OnlineVersionCheck", "Check for a new version.", "Check online for a new version of this addin."); vSMenuCommand.Execute += new EventHandler(this.MenuVersionCheck_Execute); VSMenuCommand vSMenuCommand2 = vSMenu.AddCommand("BuildVersionIncrementSettings", "Settings", "Configure BuildVersionIncrement."); vSMenuCommand2.Execute += new EventHandler(this.DisplayAddinSettings); vSMenuCommand2.QueryStatus += new EventHandler<VSMenuQueryStatusEventArgs>(this.MenuSettingsQueryStatus); return vSMenu; }