public void SetupCommands() { CommandID commandId = new CommandID(GuidList.guidEditorExtensionsCmdSet, (int)PkgCmdIDList.ReferenceJs); OleMenuCommand menuCommand = new OleMenuCommand((s, e) => Execute(), commandId); menuCommand.BeforeQueryStatus += menuCommand_BeforeQueryStatus; _mcs.AddCommand(menuCommand); }
public void SetupCommands(OleMenuCommandService commandService) { if (Package.DocumentManager == null) { return; } var guid = typeof(RestoreTabsListCommandIds).GUID; var commandId = new CommandID(guid, (int)RestoreTabsListCommandIds.RestoreTabsListPlaceholder); var command = new OleMenuCommand(null, commandId); command.BeforeQueryStatus += RestoreTabsListPlaceholderCommandOnBeforeQueryStatus; commandService.AddCommand(command); for (var i = (int)RestoreTabsListCommandIds.RestoreTabsListStart; i <= (int)RestoreTabsListCommandIds.RestoreTabsListEnd; i++) { commandId = new CommandID(guid, i); command = new OleMenuCommand(ExecuteRestoreTabsCommand, commandId); command.BeforeQueryStatus += RestoreTabsCommandOnBeforeQueryStatus; commandService.AddCommand(command); var index = GetGroupIndex(command); Package.Environment.SetKeyBindings(command, $"Global::Ctrl+D,{index}", $"Text Editor::Ctrl+D,{index}"); } }
public static void Register(MenuCommandService mcs) { var cmdId = new CommandID(VSCommandTable.PackageGuids.VSPackageCmdSetGuid, VSCommandTable.CommandIds.CreateServiceCode); var menu = new OleMenuCommand(MenuItemCallbackHandler, cmdId); menu.BeforeQueryStatus += BeforeQueryStatus; mcs.AddCommand(menu); }
public void SetupCommands() { CommandID cmd = new CommandID(CommandGuids.guidImageCmdSet, (int)CommandId.SpriteImage); OleMenuCommand menuCmd = new OleMenuCommand(async (s, e) => await MakeSpriteAsync(), cmd); menuCmd.BeforeQueryStatus += BeforeQueryStatus; _mcs.AddCommand(menuCmd); }
protected override void Initialize() { base.Initialize(); _logger = new Logger(); _dte = GetGlobalService(typeof(DTE)) as DTE; if (_dte == null) return; // Add our command handlers for menu (commands must exist in the .vsct file) OleMenuCommandService mcs = GetService(typeof(IMenuCommandService)) as OleMenuCommandService; if (mcs != null) { // Create the command for the tool window CommandID windowCommandId = new CommandID(GuidList.GuidReportDeployerCmdSet, (int)PkgCmdIdList.CmdidReportDeployerWindow); OleMenuCommand windowItem = new OleMenuCommand(ShowToolWindow, windowCommandId); mcs.AddCommand(windowItem); // Create the command for the menu item. CommandID publishCommandId = new CommandID(GuidList.GuidItemMenuCommandsCmdSet, (int)PkgCmdIdList.CmdidReportDeployerPublish); OleMenuCommand publishMenuItem = new OleMenuCommand(PublishItemCallback, publishCommandId); publishMenuItem.BeforeQueryStatus += PublishItem_BeforeQueryStatus; publishMenuItem.Visible = false; mcs.AddCommand(publishMenuItem); } }
public void SetupCommands() { CommandID commandId = new CommandID(CommandGuids.guidDiffCmdSet, (int)CommandId.RunDiff); OleMenuCommand menuCommand = new OleMenuCommand((s, e) => PerformDiff(), commandId); menuCommand.BeforeQueryStatus += BeforeQueryStatus; _mcs.AddCommand(menuCommand); }
protected override void Initialize() { base.Initialize(); _dte = GetService(typeof(DTE)) as DTE2; _activityLogger = new ActivityLogger(GetService(typeof(SVsActivityLog)) as IVsActivityLog); OleMenuCommandService mcs = GetService(typeof(IMenuCommandService)) as OleMenuCommandService; if (null != mcs) { CommandID cmdId = new CommandID(GuidList.guidTemplatePackCmdSet, (int)PkgCmdIDList.cmdidMyCommand); OleMenuCommand button = new OleMenuCommand(ButtonClicked, cmdId); button.BeforeQueryStatus += button_BeforeQueryStatus; mcs.AddCommand(button); CommandID menuCommandID = new CommandID(GuidList.guidMenuOptionsCmdSet, (int)PkgCmdIDList.SWMenuGroup); OleMenuCommand menuItem = new OleMenuCommand(OpenSettings, menuCommandID); mcs.AddCommand(menuItem); } System.Threading.Tasks.Task.Run(async () => { await System.Threading.Tasks.Task.Delay(100); try { new DynamicTemplateBuilder(_dte, _activityLogger).ProcessTemplates(); } catch (Exception ex) { _activityLogger.Error(ex.ToString()); _dte.StatusBar.Text = @"An error occured while updating templates, check the activity log"; // Leave this for now until we are sure activity logger above works well System.Windows.MessageBox.Show(ex.ToString()); } }); }
private void TestStatus(OleMenuCommand cmd) { _lp.IsFeedbackPermitted.Returns(false); cmd.Should().BeInvisibleAndDisabled(); _lp.IsFeedbackPermitted.Returns(true); cmd.Should().BeEnabled(); }
public void SetupCommands() { CommandID commandId = new CommandID(GuidList.guidDiffCmdSet, (int)PkgCmdIDList.cmdDiff); OleMenuCommand menuCommand = new OleMenuCommand((s, e) => Sort(), commandId); menuCommand.BeforeQueryStatus += menuCommand_BeforeQueryStatus; _mcs.AddCommand(menuCommand); }
/// <summary> /// Define a command handler. /// When the user press the button corresponding to the CommandID /// the EventHandler will be called. /// </summary> /// <param name="id">The CommandID (Guid/ID pair) as defined in the .vsct file</param> /// <param name="handler">Method that should be called to implement the command</param> /// <returns>The menu command. This can be used to set parameter such as the default visibility once the package is loaded</returns> internal MsVsShell.OleMenuCommand DefineCommandHandler(EventHandler handler, CommandID id) { // if the package is zombied, we don't want to add commands if (Zombied) { return(null); } // Make sure we have the service if (menuService == null) { // Get the OleCommandService object provided by the MPF; this object is the one // responsible for handling the collection of commands implemented by the package. menuService = GetService(typeof(IMenuCommandService)) as MsVsShell.OleMenuCommandService; } MsVsShell.OleMenuCommand command = null; if (null != menuService) { // Add the command handler command = new MsVsShell.OleMenuCommand(handler, id); menuService.AddCommand(command); } return(command); }
private InsertGuidCommand() { // Instance initialization _commandID = new CommandID(new Guid("3020eb2e-3b3d-4e0c-b165-5b8bd559a3cb"), 0x0100); _menuCommand = new OleMenuCommand(Execute, null, BeforeQueryStatus, _commandID); _visible = true; }
void CreateConfigCommand() { var configureCommandId = new CommandID(cmdSet, 1); configureCommand = new OleMenuCommand(delegate { configureMenuCallback.ConfigureCallback(); }, configureCommandId); configureCommand.BeforeQueryStatus += delegate { menuStatusChecker.ConfigureCommandStatusCheck(configureCommand); }; menuCommandService.AddCommand(configureCommand); }
private void RegisterCommand(ToolbarCommand id, EventHandler callback) { var menuCommandID = new CommandID(PackageConstants.GuidTortoiseGitToolbarCmdSet, (int)id); var menuItem = new OleMenuCommand(callback, menuCommandID); menuItem.Visible = false; _commandService.AddCommand(menuItem); }
protected override void QueryStatusInternal(OleMenuCommand command) { command.Enabled = false; command.Visible = false; if (this.propertyManager == null) { return; } IList<Project> projects = this.propertyManager .GetSelectedProjects() .ToList(); if (projects.Any() && projects.All(x => Language.ForProject(x).IsSupported)) { IList<bool?> properties = projects.Select(x => this.propertyManager.GetBooleanProperty(x, PropertyName)).ToList(); command.Enabled = true; command.Visible = true; // Checked if all projects have the same value, and that value is // the same as the value this instance is responsible for. command.Checked = properties.AllEqual() && (properties.First() == this.commandPropertyValue); } }
protected override void Initialize() { base.Initialize(); var mcs = GetService(typeof(IMenuCommandService)) as OleMenuCommandService; if (null != mcs) { var id = new CommandID(GuidList.GuidCmdSet, (int)PkgCmdIDList.FormatDocumentCommand); _formatDocMenuCommand = new OleMenuCommand(FormatDocumentCallback, id); mcs.AddCommand(_formatDocMenuCommand); _formatDocMenuCommand.BeforeQueryStatus += OnBeforeQueryStatus; id = new CommandID(GuidList.GuidCmdSet, (int)PkgCmdIDList.FormatSelectionCommand); _formatSelMenuCommand = new OleMenuCommand(FormatSelectionCallback, id); mcs.AddCommand(_formatSelMenuCommand); _formatSelMenuCommand.BeforeQueryStatus += OnBeforeQueryStatus; } _dte = (DTE)GetService(typeof(DTE)); _documentEventListener = new DocumentEventListener(this); _documentEventListener.BeforeSave += OnBeforeDocumentSave; if (_dte.RegistryRoot.Contains("VisualStudio")) { _isCSharpEnabled = true; } _props = _dte.Properties["AStyle Formatter", "General"]; _props.Item("IsCSarpEnabled").Value = _isCSharpEnabled; }
public NuGetSearchTask(NuGetSearchProvider provider, uint cookie, IVsSearchQuery searchQuery, IVsSearchProviderCallback searchCallback, OleMenuCommand managePackageDialogCommand, OleMenuCommand managePackageForSolutionDialogCommand) { if (provider == null) { throw new ArgumentNullException("provider"); } if (searchQuery == null) { throw new ArgumentNullException("searchQuery"); } if (searchCallback == null) { throw new ArgumentNullException("searchCallback"); } if (managePackageDialogCommand == null) { throw new ArgumentNullException("managePackageDialogCommand"); } if (managePackageForSolutionDialogCommand == null) { throw new ArgumentNullException("managePackageForSolutionDialogCommand"); } _provider = provider; _searchCallback = searchCallback; _managePackageDialogCommand = managePackageDialogCommand; _managePackageForSolutionDialogCommand = managePackageForSolutionDialogCommand; SearchQuery = searchQuery; Id = cookie; ErrorCode = 0; SetStatus(VsSearchTaskStatus.Created); }
/// <summary> /// Initialization of the package; this method is called right after the package is sited, so this is the place /// where you can put all the initialization code that rely on services provided by VisualStudio. /// </summary> protected override void Initialize() { base.Initialize(); // Add our command handlers for menu (commands must exist in the .vsct file) OleMenuCommandService mcs = GetService(typeof(IMenuCommandService)) as OleMenuCommandService; if (null != mcs) { // Create the command for the menu items. CommandID pluginMenuCommandId1 = new CommandID(GuidList.guidMenuCommandsCmdSet, (int)PkgCmdIDList.cmdidAddItem1); OleMenuCommand pluginMenuItem1 = new OleMenuCommand(MenuItem1Callback, pluginMenuCommandId1); pluginMenuItem1.BeforeQueryStatus += menuItem1_BeforeQueryStatus; mcs.AddCommand(pluginMenuItem1); CommandID pluginMenuCommandId2 = new CommandID(GuidList.guidMenuCommandsCmdSet, (int)PkgCmdIDList.cmdidAddItem2); OleMenuCommand pluginMenuItem2 = new OleMenuCommand(MenuItem2Callback, pluginMenuCommandId2); pluginMenuItem2.BeforeQueryStatus += menuItem2_BeforeQueryStatus; mcs.AddCommand(pluginMenuItem2); CommandID pluginMenuCommandId3 = new CommandID(GuidList.guidMenuCommandsCmdSet, (int)PkgCmdIDList.cmdidAddItem3); OleMenuCommand pluginMenuItem3 = new OleMenuCommand(MenuItem3Callback, pluginMenuCommandId3); pluginMenuItem3.BeforeQueryStatus += menuItem3_BeforeQueryStatus; mcs.AddCommand(pluginMenuItem3); } }
public void SetupCommands() { CommandID commandSol = new CommandID(GuidList.guidDiffCmdSet, (int)PkgCmdIDList.cmdSolutionColors); OleMenuCommand menuCommandSol = new OleMenuCommand((s, e) => ApplySolutionSettings(), commandSol); menuCommandSol.BeforeQueryStatus += SolutionBeforeQueryStatus; _mcs.AddCommand(menuCommandSol); }
/// <summary> /// Initialization of the package; this method is called right after the package is sited, so this is the place /// where you can put all the initialization code that rely on services provided by VisualStudio. /// </summary> protected override void Initialize() { base.Initialize(); InitializeDTE(); // Add our command handlers for menu (commands must exist in the .vsct file) OleMenuCommandService mcs = GetService(typeof(IMenuCommandService)) as OleMenuCommandService; if (null != mcs) { CommandID restartCommandSingleID = new CommandID(GuidList.TopLevelMenuGuid, (int)MenuId.Restart); OleMenuCommand restartSingleMenuItem = new OleMenuCommand(RestartMenuItemCallback, restartCommandSingleID); mcs.AddCommand(restartSingleMenuItem); restartSingleMenuItem.BeforeQueryStatus += OnBeforeQueryStatusSingle; // Create the command for the menu item. CommandID restartElevatedCommandID = new CommandID(GuidList.RestartElevatedGroupGuid, (int)MenuId.RestartAsAdmin); OleMenuCommand restartElevatedMenuItem = new OleMenuCommand(RestartMenuItemCallback, restartElevatedCommandID); mcs.AddCommand(restartElevatedMenuItem); restartElevatedMenuItem.BeforeQueryStatus += OnBeforeQueryStatusGroup; CommandID restartCommandID = new CommandID(GuidList.RestartElevatedGroupGuid, (int)MenuId.Restart); OleMenuCommand restartMenuItem = new OleMenuCommand(RestartMenuItemCallback, restartCommandID); mcs.AddCommand(restartMenuItem); restartMenuItem.BeforeQueryStatus += OnBeforeQueryStatusGroup; } }
/// <summary> /// Standard constructor for the tool window. /// </summary> public MyToolWindow() : base(null) { // Set the window title reading it from the resources. this.Caption = Resources.ToolWindowTitle; // Set the image that will appear on the tab of the window frame // when docked with an other window // The resource ID correspond to the one defined in the resx file // while the Index is the offset in the bitmap strip. Each image in // the strip being 16x16. this.BitmapResourceID = 301; this.BitmapIndex = 1; // Create the toolbar. this.ToolBar = new CommandID(GuidList.GuidCroolPackageCmdSet, PkgCmdIDList.ToolbarID); this.ToolBarLocation = (int)VSTWT_LOCATION.VSTWT_TOP; // Create the handlers for the toolbar commands. var mcs = GetService(typeof(IMenuCommandService)) as OleMenuCommandService; if (null != mcs) { // Command for the combo's list var comboListCmdID = new CommandID(GuidList.GuidCroolPackageCmdSet, PkgCmdIDList.CmdidWindowsMediaFilenameGetList); var comboMenuList = new OleMenuCommand(new EventHandler(this.ComboListHandler), comboListCmdID); mcs.AddCommand(comboMenuList); } // This is the user control hosted by the tool window; Note that, even if this class implements IDisposable, // we are not calling Dispose on this object. This is because ToolWindowPane calls Dispose on // the object returned by the Content property. this.Content = new MyControl(); }
public static void Register(DTE2 dte, MenuCommandService mcs) { _dte = dte; CommandID nestAllId = new CommandID(GuidList.guidFileNestingCmdSet, (int)PkgCmdIDList.cmdRunNesting); OleMenuCommand menuNestAll = new OleMenuCommand(NestAll, nestAllId); mcs.AddCommand(menuNestAll); }
internal void InitializeResetInteractiveFromProjectCommand() { var resetInteractiveFromProjectCommand = new OleMenuCommand( (sender, args) => { ResetInteractiveCommand.Value.ExecuteResetInteractive(); }, GetResetInteractiveFromProjectCommandID()); resetInteractiveFromProjectCommand.Supported = true; resetInteractiveFromProjectCommand.BeforeQueryStatus += (_, __) => { EnvDTE.Project project; FrameworkName frameworkName; GetActiveProject(out project, out frameworkName); var available = ResetInteractiveCommand != null && project != null && project.Kind == ProjectKind && frameworkName != null && frameworkName.Identifier == ".NETFramework"; resetInteractiveFromProjectCommand.Enabled = available; resetInteractiveFromProjectCommand.Supported = available; resetInteractiveFromProjectCommand.Visible = available; }; _menuCommandService.AddCommand(resetInteractiveFromProjectCommand); }
/// <summary> /// Define a command handler. /// When the user presses the button corresponding to the CommandID, /// then the EventHandler will be called. /// </summary> /// <param name="id">The CommandID (Guid/ID pair) as defined in the .vsct file</param> /// <param name="handler">Method that should be called to implement the command</param> /// <returns>The menu command. This can be used to set parameter such as the default visibility once the package is loaded</returns> private MsVsShell.OleMenuCommand DefineCommandHandler(EventHandler handler, CommandID id) { // First add it to the package. This is to keep the visibility // of the command on the toolbar constant when the tool window does // not have focus. In addition, it creates the command object for us. PackageToolWindow package = (PackageToolWindow)this.Package; MsVsShell.OleMenuCommand command = package.DefineCommandHandler(handler, id); // Verify that the command was added if (command == null) { return(command); } // Get the OleCommandService object provided by the base window pane class; this object is the one // responsible for handling the collection of commands implemented by the package. MsVsShell.OleMenuCommandService menuService = GetService(typeof(IMenuCommandService)) as MsVsShell.OleMenuCommandService; if (null != menuService) { // Add the command handler menuService.AddCommand(command); } return(command); }
public static void Register(MenuCommandService mcs) { CommandID nestId = new CommandID(GuidList.guidFileNestingCmdSet, (int)PkgCmdIDList.cmdNest); OleMenuCommand menuNest = new OleMenuCommand(Nest, nestId); mcs.AddCommand(menuNest); menuNest.BeforeQueryStatus += BeforeNest; }
public void SetupCommands() { CommandID cid = new CommandID(CommandGuids.guidEditorExtensionsCmdSet, (int)CommandId.AddGrunt); OleMenuCommand cmd = new OleMenuCommand((s, e) => Execute(), cid); cmd.BeforeQueryStatus += BeforeQueryStatus; _mcs.AddCommand(cmd); }
/// <summary> /// Initialization of the package; this method is called right after the package is sited, so this is the place /// where you can put all the initilaization code that rely on services provided by VisualStudio. /// </summary> protected override void Initialize() { Trace.WriteLine(string.Format(CultureInfo.CurrentCulture, "Entering Initialize() of: {0}", this.ToString())); base.Initialize(); OleMenuCommandService mcs = GetService(typeof(IMenuCommandService)) as OleMenuCommandService; if (mcs != null) { // Create the command to generate the missing steps skeleton CommandID menuCommandID = new CommandID(GuidList.guidSpecFlowGenerateOption, (int)PkgCmdIDList.cmdidGenerate); //Create a menu item corresponding to that command IFileHandler fileHandler = new FileHandler(); StepFileGenerator stepFileGen = new StepFileGenerator(fileHandler); OleMenuCommand menuItem = new OleMenuCommand(stepFileGen.GenerateStepFileMenuItemCallback, menuCommandID); //Add an event handler to the menu item menuItem.BeforeQueryStatus += stepFileGen.QueryStatusMenuCommandBeforeQueryStatus; mcs.AddCommand(menuItem); } }
protected override void Initialize() { base.Initialize(); _dte = GetService(typeof(DTE)) as DTE2; OleMenuCommandService mcs = GetService(typeof(IMenuCommandService)) as OleMenuCommandService; CommandID cmdCustom = new CommandID(GuidList.guidOpenCommandLineCmdSet, (int)PkgCmdIDList.cmdidOpenCommandLine); OleMenuCommand customItem = new OleMenuCommand(OpenCustom, cmdCustom); customItem.BeforeQueryStatus += BeforeQueryStatus; mcs.AddCommand(customItem); CommandID cmdCmd = new CommandID(GuidList.guidOpenCommandLineCmdSet, (int)PkgCmdIDList.cmdidOpenCmd); MenuCommand cmdItem = new MenuCommand(OpenCmd, cmdCmd); mcs.AddCommand(cmdItem); CommandID cmdPowershell = new CommandID(GuidList.guidOpenCommandLineCmdSet, (int)PkgCmdIDList.cmdidOpenPowershell); MenuCommand powershellItem = new MenuCommand(OpenPowershell, cmdPowershell); mcs.AddCommand(powershellItem); CommandID cmdOptions = new CommandID(GuidList.guidOpenCommandLineCmdSet, (int)PkgCmdIDList.cmdidOpenOptions); MenuCommand optionsItem = new MenuCommand((s, e) => { ShowOptionPage(typeof(Options)); }, cmdOptions); mcs.AddCommand(optionsItem); CommandID cmdExe = new CommandID(GuidList.guidOpenCommandLineCmdSet, (int)PkgCmdIDList.cmdExecuteCmd); OleMenuCommand exeItem = new OleMenuCommand(ExecuteFile, cmdExe); exeItem.BeforeQueryStatus += BeforeExeQuery; mcs.AddCommand(exeItem); }
protected void Initialize(Guid menuGroup, int commandId) { var cmdId = new CommandID(menuGroup, commandId); Command = new OleMenuCommand(this.OnInvoke, cmdId); Command.BeforeQueryStatus += OnBeforeQueryStatus; CommandService.AddCommand(Command); }
public void SetupCommands() { CommandID cmd = new CommandID(CommandGuids.guidImageCmdSet, (int)CommandId.CompressImage); OleMenuCommand menuCmd = new OleMenuCommand((s, e) => StartCompress(), cmd); menuCmd.BeforeQueryStatus += BeforeQueryStatus; _mcs.AddCommand(menuCmd); }
private CompilerOutputCmds(DevUtilsPackage package) { this.package = package; // Add our command handlers for menu (commands must exist in the .vsct file) OleMenuCommandService mcs = serviceProvider.GetService(typeof (IMenuCommandService)) as OleMenuCommandService; if (null != mcs) { // Create the command for the menu item. CommandID menuCommandID = new CommandID(guidDevUtilsCmdSet, cmdShowAssembly); var cmd = new OleMenuCommand((s, e) => showCppOutput(1), changeHandler, beforeQueryStatus, menuCommandID); cmd.Properties["lang"] = "C/C++"; mcs.AddCommand(cmd); menuCommandID = new CommandID(guidDevUtilsCmdSet, cmdShowPreprocessed); cmd = new OleMenuCommand((s, e) => showCppOutput(2), changeHandler, beforeQueryStatus, menuCommandID); cmd.Properties["lang"] = "C/C++"; mcs.AddCommand(cmd); menuCommandID = new CommandID(guidDevUtilsCmdSet, cmdShowDecompiledCSharp); cmd = new OleMenuCommand((s, e) => showDecompiledCSharp(), changeHandler, beforeQueryStatus, menuCommandID); cmd.Properties["lang"] = "CSharp"; mcs.AddCommand(cmd); } }
private AddInheritDocCommand(Package package) { this.package = package; OleMenuCommandService commandService = this.ServiceProvider.GetService(typeof(IMenuCommandService)) as OleMenuCommandService; if (commandService != null) { var menuCommandId = new CommandID(CommandSet, CommandId); var menuItem = new OleMenuCommand(MenuItemCallback, menuCommandId); commandService.AddCommand(menuItem); menuItem.BeforeQueryStatus += (sender, e) => { bool visible = false; var dte = (DTE)Package.GetGlobalService(typeof(SDTE)); var classElem = SearchService.FindClass(dte); if (classElem != null) { List<CodeElement> codeElements = SearchService.FindCodeElements(dte); if (classElem.ImplementedInterfaces.Count > 0) { visible = true; } else { visible = codeElements.Any(elem => elem.IsInherited() || elem.OverridesSomething()); } } ((OleMenuCommand)sender).Visible = visible; }; } }
protected override void Initialize() { base.Initialize(); _logger = new Logger(); _dte = GetGlobalService(typeof(DTE)) as DTE; if (_dte == null) return; OleMenuCommandService mcs = GetService(typeof(IMenuCommandService)) as OleMenuCommandService; if (mcs != null) { CommandID publishCommandId = new CommandID(GuidList.GuidItemMenuCommandsCmdSet, (int)PkgCmdIdList.CmdidWebResourceDeployerPublish); OleMenuCommand publishMenuItem = new OleMenuCommand(PublishItemCallback, publishCommandId); publishMenuItem.BeforeQueryStatus += PublishItem_BeforeQueryStatus; publishMenuItem.Visible = false; mcs.AddCommand(publishMenuItem); CommandID editorPublishCommandId = new CommandID(GuidList.GuidEditorCommandsCmdSet, (int)PkgCmdIdList.CmdidWebResourceEditorPublish); OleMenuCommand editorPublishMenuItem = new OleMenuCommand(PublishItemCallback, editorPublishCommandId); editorPublishMenuItem.BeforeQueryStatus += PublishItem_BeforeQueryStatus; editorPublishMenuItem.Visible = false; mcs.AddCommand(editorPublishMenuItem); } }
public async Task NoDialogShownWhenTargetIsAlreadyRunning() { var ui = await ReAttachUi.InitAsync(_mocks.MockReAttachPackage.Object); _mocks.MockReAttachDebugger.Setup(d => d.ReAttach(It.IsAny <ReAttachTarget>())).Returns(true); _mocks.MockReAttachHistoryItems.AddFirst(new ReAttachTarget(123, "path", "user")); var id = new CommandID(ReAttachConstants.ReAttachPackageCmdSet, ReAttachConstants.ReAttachCommandId); var command = new VsShell.OleMenuCommand((sender, args) => { }, id); await ui.ReAttachCommandClickedAsync(command, null); _mocks.MockReAttachDebugger.Verify(d => d.ReAttach(It.IsAny <ReAttachTarget>()), Times.Once()); Assert.AreEqual(0, _mocks.MockReAttachReporter.ErrorCount, "Unexpected number of ReAttach errors."); Assert.AreEqual(0, _mocks.MockReAttachReporter.WarningCount, "Unexpected number of ReAttach warnings."); }
public async Task WillDoReAttachIfHistoryItemsArePresent() { var ui = await ReAttachUi.InitAsync(_mocks.MockReAttachPackage.Object); _mocks.MockReAttachDebugger.Setup(d => d.ReAttach(It.IsAny <ReAttachTarget>())).Returns(true); for (var i = 1; i < 5; i++) { _mocks.MockReAttachHistoryItems.AddLast(new ReAttachTarget(i, "path" + i, "user" + i)); } Assert.AreEqual(1, _mocks.MockReAttachHistoryItems[0].ProcessId, "Wrong target on top of ReAttach list."); var id = new CommandID(ReAttachConstants.ReAttachPackageCmdSet, ReAttachConstants.ReAttachCommandId + 3); var command = new VsShell.OleMenuCommand((sender, args) => { }, id); await ui.ReAttachCommandClickedAsync(command, null); _mocks.MockReAttachDebugger.Verify(d => d.ReAttach(_mocks.MockReAttachHistoryItems[3]), Times.Once()); Assert.AreEqual(0, _mocks.MockReAttachReporter.ErrorCount, "Unexpected number of ReAttach errors."); Assert.AreEqual(0, _mocks.MockReAttachReporter.WarningCount, "Unexpected number of ReAttach warnings."); }
/// <summary> /// This is called after our control has been created and sited. /// This is a good place to initialize the control with data gathered /// from Visual Studio services. /// </summary> public override void OnToolWindowCreated() { base.OnToolWindowCreated(); PackageToolWindow package = (PackageToolWindow)this.Package; // Set the text that will appear in the title bar of the tool window. // Note that because we need access to the package for localization, // we have to wait to do this here. If we used a constant string, // we could do this in the consturctor. this.Caption = package.GetResourceString("@100"); // Add the handler for our toolbar button CommandID id = new CommandID(GuidsList.guidClientCmdSet, PkgCmdId.cmdidRefreshWindowsList); MsVsShell.OleMenuCommand command = DefineCommandHandler(new EventHandler(this.RefreshList), id); // Get the selection tracking service and pass it to the control so that it can push the // active selection. Only needed if you want to display something in the Properties window. // Note that this service is only available for windows (not in the global service provider) // Additionally, each window has its own (so you should not be sharing one between multiple windows) control.TrackSelection = (ITrackSelection)this.GetService(typeof(STrackSelection)); // Ensure the control's handle has been created; otherwise, BeginInvoke cannot be called. // Note that during runtime this should have no effect when running inside Visual Studio, // as the control's handle should already be created, but unit tests can end up calling // this method without the control being created. control.InitializeComponent(); // Delay initialization of the list until other tool windows have also had a chance to be // initialized control.Dispatcher.BeginInvoke((Action) delegate { // Populate the list view this.RefreshList(this, null); }); }
public void OnBeforeQueryCommandStatus(VsShell.OleMenuCommand command) { }
public void OnBeforeQueryCommandStatus(VsShell.OleMenuCommand command) { command.Enabled = _sessionManagerToolWindowState.SelectedSession != null; }