public override bool RegisterGUI(OleMenuCommand vsCommand, CommandBar vsCommandbar, bool toolBarOnly) { if (!toolBarOnly) { _RegisterGuiContext(vsCommand, "Solution"); } return true; }
public override bool RegisterGUI(OleMenuCommand vsCommand, CommandBar vsCommandbar, bool toolBarOnly) { if (toolBarOnly) { _RegisterGUIBar(vsCommand, vsCommandbar); } else { _RegisterGuiContext(vsCommand, "Project"); _RegisterGuiContext(vsCommand, "Item"); _RegisterGuiContext(vsCommand, "Easy MDI Document Window"); } return true; }
protected override void CommandBeforeQueryStatus(EnvDTE80.DTE2 applicationObject, ConnectionData connectionData, OleMenuCommand menuCommand) { CommonHandlers.ActionBeforeQueryStatusActiveDocumentReport(applicationObject, menuCommand); }
protected override void CommandBeforeQueryStatus(EnvDTE80.DTE2 applicationObject, OleMenuCommand menuCommand) { CommonHandlers.ActionBeforeQueryStatusActiveDocumentJavaScript(applicationObject, menuCommand); CommonHandlers.CorrectCommandNameForConnectionName(applicationObject, menuCommand, Properties.CommandNames.CodeJavaScriptUpdateEntityMetadataFileWithSelectCommand); }
protected override void CommandBeforeQueryStatus(EnvDTE80.DTE2 applicationObject, OleMenuCommand menuCommand) { CommonHandlers.ActionBeforeQueryStatusConnectionIsNotReadOnly(applicationObject, menuCommand); CommonHandlers.ActionBeforeQueryStatusFilesToAdd(applicationObject, menuCommand); }
private void MenuItem_BeforeQueryStatus(object sender, EventArgs e) { OleMenuCommand oCommand = (OleMenuCommand)sender; oCommand.Visible = GetVisible(); }
protected override void CommandBeforeQueryStatus(EnvDTE80.DTE2 applicationObject, Tuple <ConnectionData, ConnectionData> connectionDataPair, OleMenuCommand menuCommand) { CommonHandlers.ActionBeforeQueryStatusActiveDocumentIsXmlWithRootWithAttribute( applicationObject , menuCommand , Intellisense.Model.IntellisenseContext.IntellisenseContextAttributeFormId , out var attribute , AbstractDynamicCommandXsdSchemas.FormXmlRoot ); }
protected override void Execute(OleMenuCommand Button) => Shuffle(TextSelection.GetSelection(Package, out int[] poses, out bool newLine)).ReplaceSelection(poses, newLine);
public void CommandBeforeQueryStatus(DTE2 applicationObject, OleMenuCommand menuCommand) { CommonHandlers.ActiveSolutionExplorerProjectSingle(applicationObject, menuCommand); }
protected override void CommandBeforeQueryStatus(EnvDTE80.DTE2 applicationObject, OpenFilesType openFilesType, OleMenuCommand menuCommand) { var selectedFileType = _selectedFileTypeForOpenFilesType[openFilesType]; _sourceSelectedFiles.CommandBeforeQueryStatus(applicationObject, menuCommand, selectedFileType); }
protected override void CommandBeforeQueryStatus(EnvDTE80.DTE2 applicationObject, OleMenuCommand menuCommand) { CommonHandlers.ActiveSolutionExplorerProjectAny(applicationObject, menuCommand); }
protected override void QueryStatusInternal(OleMenuCommand command) { this.queryStatusFunc?.Invoke(command); }
protected override async System.Threading.Tasks.Task InitializeAsync(CancellationToken cancellationToken, IProgress <ServiceProgressData> progress) { await base.InitializeAsync(cancellationToken, progress); _dte2 = await GetServiceAsync(typeof(DTE)) as DTE2; Assumes.Present(_dte2); if (_dte2 == null) { return; } var oleMenuCommandService = await GetServiceAsync(typeof(IMenuCommandService)) as OleMenuCommandService; await ThreadHelper.JoinableTaskFactory.SwitchToMainThreadAsync(); if (oleMenuCommandService != null) { var menuCommandId3 = new CommandID(GuidList.guidDbContextPackageCmdSet, (int)PkgCmdIDList.cmdidDgmlBuild); var menuItem3 = new OleMenuCommand(async(s, e) => await OnProjectContextMenuInvokeHandlerAsync(s, e), null, async(s, e) => await OnProjectMenuBeforeQueryStatusAsync(s, e), menuCommandId3); oleMenuCommandService.AddCommand(menuItem3); var menuCommandId4 = new CommandID(GuidList.guidDbContextPackageCmdSet, (int)PkgCmdIDList.cmdidReverseEngineerDgml); var menuItem4 = new OleMenuCommand(async(s, e) => await OnProjectContextMenuInvokeHandlerAsync(s, e), null, async(s, e) => await OnProjectMenuBeforeQueryStatusAsync(s, e), menuCommandId4); oleMenuCommandService.AddCommand(menuItem4); var menuCommandId5 = new CommandID(GuidList.guidDbContextPackageCmdSet, (int)PkgCmdIDList.cmdidReverseEngineerCodeFirst); var menuItem5 = new OleMenuCommand(async(s, e) => await OnProjectContextMenuInvokeHandlerAsync(s, e), null, async(s, e) => await OnProjectMenuBeforeQueryStatusAsync(s, e), menuCommandId5); oleMenuCommandService.AddCommand(menuItem5); var menuCommandId7 = new CommandID(GuidList.guidDbContextPackageCmdSet, (int)PkgCmdIDList.cmdidAbout); var menuItem7 = new OleMenuCommand(async(s, e) => await OnProjectContextMenuInvokeHandlerAsync(s, e), null, async(s, e) => await OnProjectMenuBeforeQueryStatusAsync(s, e), menuCommandId7); oleMenuCommandService.AddCommand(menuItem7); var menuCommandId8 = new CommandID(GuidList.guidDbContextPackageCmdSet, (int)PkgCmdIDList.cmdidDgmlNuget); var menuItem8 = new OleMenuCommand(async(s, e) => await OnProjectContextMenuInvokeHandlerAsync(s, e), null, async(s, e) => await OnProjectMenuBeforeQueryStatusAsync(s, e), menuCommandId8); oleMenuCommandService.AddCommand(menuItem8); var menuCommandId9 = new CommandID(GuidList.guidDbContextPackageCmdSet, (int)PkgCmdIDList.cmdidSqlBuild); var menuItem9 = new OleMenuCommand(async(s, e) => await OnProjectContextMenuInvokeHandlerAsync(s, e), null, async(s, e) => await OnProjectMenuBeforeQueryStatusAsync(s, e), menuCommandId9); oleMenuCommandService.AddCommand(menuItem9); var menuCommandId10 = new CommandID(GuidList.guidDbContextPackageCmdSet, (int)PkgCmdIDList.cmdidDebugViewBuild); var menuItem10 = new OleMenuCommand(async(s, e) => await OnProjectContextMenuInvokeHandlerAsync(s, e), null, async(s, e) => await OnProjectMenuBeforeQueryStatusAsync(s, e), menuCommandId10); oleMenuCommandService.AddCommand(menuItem10); var menuCommandId11 = new CommandID(GuidList.guidDbContextPackageCmdSet, (int)PkgCmdIDList.cmdidMigrationStatus); var menuItem11 = new OleMenuCommand(async(s, e) => await OnProjectContextMenuInvokeHandlerAsync(s, e), null, async(s, e) => await OnProjectMenuBeforeQueryStatusAsync(s, e), menuCommandId11); oleMenuCommandService.AddCommand(menuItem11); } typeof(Microsoft.Xaml.Behaviors.Behavior).ToString(); typeof(Microsoft.VisualStudio.ProjectSystem.ProjectCapabilities).ToString(); //Boot Telemetry Telemetry.Enabled = false; if (Telemetry.Enabled) { Telemetry.Initialize(Dte2, System.Reflection.Assembly.GetExecutingAssembly().GetName().Version.ToString(), VisualStudioVersion.ToString(), "00dac4de-337c-4fed-a835-70db30078b2a"); } Telemetry.TrackEvent("Platform: Visual Studio " + VisualStudioVersion.ToString(1)); }
protected override void Initialize() { base.Initialize(); _dte = GetGlobalService(typeof(DTE)) as DTE; if (_dte == null) { return; } StartupTasks.Run(_dte); ExLogger.LogToFile(Logger, Resource.TraceInfo_InitializingExtension, LogLevel.Info); AdviseSolutionEvents(); var events = _dte.Events; BindSolutionEvents(events); if (!(GetService(typeof(IMenuCommandService)) is OleMenuCommandService mcs)) { return; } //Plug-in Deployer CommandID pdWindowCommandId = new CommandID(PackageGuids.GuidD365DevExCmdSet, PackageIds.CmdidPluginDeployerWindow); OleMenuCommand pdWindowItem = new OleMenuCommand(ShowToolWindow <PluginDeployerHost>, pdWindowCommandId); mcs.AddCommand(pdWindowItem); //Web Resource Deployer CommandID wrdWindowCommandId = new CommandID(PackageGuids.GuidD365DevExCmdSet, PackageIds.CmdidWebResourceDeployerWindow); OleMenuCommand wrdWindowItem = new OleMenuCommand(ShowToolWindow <WebResourceDeployerHost>, wrdWindowCommandId); mcs.AddCommand(wrdWindowItem); //Solution Packager CommandID spWindowCommandId = new CommandID(PackageGuids.GuidD365DevExCmdSet, PackageIds.CmdidSolutionPackagerWindow); OleMenuCommand spWindowItem = new OleMenuCommand(ShowToolWindow <SolutionPackagerHost>, spWindowCommandId); mcs.AddCommand(spWindowItem); //Plug-in Trace Viewer CommandID ptvWindowCommandId = new CommandID(PackageGuids.GuidD365DevExCmdSet, PackageIds.CmdidPluginTraceViewerWindow); OleMenuCommand ptvWindowItem = new OleMenuCommand(ShowToolWindow <PluginTraceViewerHost>, ptvWindowCommandId); mcs.AddCommand(ptvWindowItem); //CRM Intellisense On CommandID crmIntellisenseOnCommandId = new CommandID(PackageGuids.GuidD365DevExCmdSet, PackageIds.CmdidCrmIntellisenseOn); OleMenuCommand crmIntellisenseOnItem = new OleMenuCommand(ToggleCrmIntellisense, crmIntellisenseOnCommandId) { Visible = false }; crmIntellisenseOnItem.BeforeQueryStatus += DisplayCrmIntellisense; mcs.AddCommand(crmIntellisenseOnItem); //CRM Intellisense Off CommandID crmIntellisenseOffCommandId = new CommandID(PackageGuids.GuidD365DevExCmdSet, PackageIds.CmdidCrmIntellisenseOff); OleMenuCommand crmIntellisenseOffItem = new OleMenuCommand(ToggleCrmIntellisense, crmIntellisenseOffCommandId) { Visible = false }; crmIntellisenseOffItem.BeforeQueryStatus += DisplayCrmIntellisense; mcs.AddCommand(crmIntellisenseOffItem); //NuGet SDK Tools - Core Tools CommandID nugetSdkToolsCoreCommandId = new CommandID(PackageGuids.GuidD365DevExCmdSet, PackageIds.CmdidNuGetSdkToolsCore); OleMenuCommand nugetSdkToolsCoreItem = new OleMenuCommand(InstallNuGetCliPackage, nugetSdkToolsCoreCommandId); mcs.AddCommand(nugetSdkToolsCoreItem); //NuGet SDK Tools - Plug-in Registration Tool CommandID nugetSdkToolsPrtCommandId = new CommandID(PackageGuids.GuidD365DevExCmdSet, PackageIds.CmdidNuGetSdkToolsPrt); OleMenuCommand nugetSdkToolsPrtItem = new OleMenuCommand(InstallNuGetCliPackage, nugetSdkToolsPrtCommandId); mcs.AddCommand(nugetSdkToolsPrtItem); }
public void ProjectTestPropertySetCommand_Invoke_MultipleProjects_MixedPropValues_SetsValues() { // Arrange OleMenuCommand command = CommandHelper.CreateRandomOleMenuCommand(); command.Enabled = true; var p1 = new ProjectMock("good1.proj"); var p2 = new ProjectMock("good2.proj"); var p3 = new ProjectMock("good2.proj"); p1.SetCSProjectKind(); p2.SetCSProjectKind(); p3.SetCSProjectKind(); this.projectSystem.SelectedProjects = new[] { p1, p2, p3 }; // Test case 1: test (true) // Arrange var testSubject1 = new ProjectTestPropertySetCommand(serviceProvider, true); this.SetTestProperty(p1, null); this.SetTestProperty(p2, true); this.SetTestProperty(p3, false); // Act testSubject1.Invoke(command, null); // Assert this.VerifyTestProperty(p1, true); this.VerifyTestProperty(p2, true); this.VerifyTestProperty(p3, true); // Test case 2: non-test (false) var testSubject2 = new ProjectTestPropertySetCommand(serviceProvider, false); this.SetTestProperty(p1, null); this.SetTestProperty(p2, true); this.SetTestProperty(p3, false); // Act testSubject2.Invoke(command, null); // Assert this.VerifyTestProperty(p1, false); this.VerifyTestProperty(p2, false); this.VerifyTestProperty(p3, false); // Test case 3: auto detect (null) var testSubject3 = new ProjectTestPropertySetCommand(serviceProvider, null); this.SetTestProperty(p1, null); this.SetTestProperty(p2, true); this.SetTestProperty(p3, false); // Act testSubject3.Invoke(command, null); // Assert this.VerifyTestProperty(p1, null); this.VerifyTestProperty(p2, null); this.VerifyTestProperty(p3, null); }
protected override void QueryStatusInternal(OleMenuCommand command) { command.Enabled = (this.teamExplorer != null); }
protected override void CommandBeforeQueryStatus(EnvDTE80.DTE2 applicationObject, ConnectionData connectionData, OleMenuCommand menuCommand) { CommonHandlers.ActionBeforeQueryStatusActiveDocumentIsXmlWithRoot(applicationObject, menuCommand, out var doc, AbstractDynamicCommandXsdSchemas.RootSiteMap); }
/// <summary> /// Function called when the window frame is set on this tool window. /// </summary> public override void OnToolWindowCreated() { // Call the base class's implementation. base.OnToolWindowCreated(); // Register this object as command filter for the text view so that it will // be possible to intercept some command. IOleCommandTarget originalFilter; Microsoft.VisualStudio.ErrorHandler.ThrowOnFailure( textView.AddCommandFilter((IOleCommandTarget)this, out originalFilter)); // Create a command service that will use the previous command target // as parent target and will route to it the commands that it can not handle. if (null == originalFilter) { commandService = new OleMenuCommandService(this); } else { commandService = new OleMenuCommandService(this, originalFilter); } // Add the command handler for RETURN. CommandID id = new CommandID( typeof(Microsoft.VisualStudio.VSConstants.VSStd2KCmdID).GUID, (int)Microsoft.VisualStudio.VSConstants.VSStd2KCmdID.RETURN); OleMenuCommand cmd = new OleMenuCommand(new EventHandler(OnReturn), id); cmd.BeforeQueryStatus += new EventHandler(UnsupportedOnCompletion); commandService.AddCommand(cmd); // Command handler for UP and DOWN arrows. These commands are needed to implement // the history in the console, but at the moment the implementation is empty. id = new CommandID(typeof(Microsoft.VisualStudio.VSConstants.VSStd2KCmdID).GUID, (int)Microsoft.VisualStudio.VSConstants.VSStd2KCmdID.UP); cmd = new OleMenuCommand(new EventHandler(OnHistory), id); cmd.BeforeQueryStatus += new EventHandler(SupportCommandOnInputPosition); commandService.AddCommand(cmd); id = new CommandID(typeof(Microsoft.VisualStudio.VSConstants.VSStd2KCmdID).GUID, (int)Microsoft.VisualStudio.VSConstants.VSStd2KCmdID.DOWN); cmd = new OleMenuCommand(new EventHandler(OnHistory), id); cmd.BeforeQueryStatus += new EventHandler(SupportCommandOnInputPosition); commandService.AddCommand(cmd); // Command handler for the LEFT arrow. This command handler is needed in order to // avoid that the user uses the left arrow to move to the previous line or over the // command prompt. id = new CommandID(typeof(Microsoft.VisualStudio.VSConstants.VSStd2KCmdID).GUID, (int)Microsoft.VisualStudio.VSConstants.VSStd2KCmdID.LEFT); cmd = new OleMenuCommand(new EventHandler(OnNoAction), id); cmd.BeforeQueryStatus += new EventHandler(OnBeforeMoveLeft); commandService.AddCommand(cmd); // Handle also the HOME command. id = new CommandID(typeof(Microsoft.VisualStudio.VSConstants.VSStd2KCmdID).GUID, (int)Microsoft.VisualStudio.VSConstants.VSStd2KCmdID.BOL); cmd = new OleMenuCommand(new EventHandler(OnHome), id); commandService.AddCommand(cmd); id = new CommandID(typeof(Microsoft.VisualStudio.VSConstants.VSStd2KCmdID).GUID, (int)Microsoft.VisualStudio.VSConstants.VSStd2KCmdID.BOL_EXT); cmd = new OleMenuCommand(new EventHandler(OnShiftHome), id); cmd.BeforeQueryStatus += new EventHandler(SupportCommandOnInputPosition); commandService.AddCommand(cmd); // Adding support for "Clear Pane" command. id = new CommandID(typeof(Microsoft.VisualStudio.VSConstants.VSStd97CmdID).GUID, (int)Microsoft.VisualStudio.VSConstants.VSStd97CmdID.ClearPane); cmd = new OleMenuCommand(new EventHandler(OnClearPane), id); commandService.AddCommand(cmd); // Add a command handler for the context menu. id = new CommandID(typeof(Microsoft.VisualStudio.VSConstants.VSStd2KCmdID).GUID, (int)Microsoft.VisualStudio.VSConstants.VSStd2KCmdID.SHOWCONTEXTMENU); cmd = new OleMenuCommand(new EventHandler(ShowContextMenu), id); commandService.AddCommand(cmd); // Now we set the key binding for this frame to the same value as the text editor // so that there will be the same mapping for the commands. Guid commandUiGuid = VSConstants.GUID_TextEditorFactory; ((IVsWindowFrame)Frame).SetGuidProperty((int)__VSFPROPID.VSFPROPID_InheritKeyBindings, ref commandUiGuid); }
protected override void CommandBeforeQueryStatus(EnvDTE80.DTE2 applicationObject, OleMenuCommand menuCommand) { CommonHandlers.ActionBeforeQueryStatusSolutionExplorerWebResourceTextRecursive(applicationObject, menuCommand); }
private static void OnBeforeQueryStatus(OleMenuCommand menuItem, DTE2 dte) { var language = dte.ActiveDocument?.Language; menuItem.Visible = menuItem.Enabled = language != null && _map.ContainsKey(language); }
protected override void CommandBeforeQueryStatus(EnvDTE80.DTE2 applicationObject, ConnectionData connectionData, OleMenuCommand menuCommand) { CommonHandlers.ActionBeforeQueryStatusSolutionExplorerCSharpAny(applicationObject, menuCommand); }
private void GulpBeforeQueryStatus(object sender, EventArgs e) { // gets the full path of the clicked file var path = SolutionHelpers.GetSourceFilePath(); var myCommand = sender as OleMenuCommand; myCommand.Visible = this.IsGulpFile(); if (!this.IsNewFile()) { return; } OleMenuCommandService mcs = GetService(typeof(IMenuCommandService)) as OleMenuCommandService; // delete the old command list if (commands == null) { commands = new List <OleMenuCommand>(); } foreach (var cmd in commands) { mcs.RemoveCommand(cmd); } if (myCommand.Visible) { this.lastFile = path; var list = GulpParser.ReadAllTasks(path); myCommand.Text = "Gulp"; myCommand.Enabled = true; if (list.Count == 0) { myCommand.Enabled = false; myCommand.Text = "Gulpfile.js not found"; } if (list.Contains("default")) { list.Remove("default"); } string n = exclusionRegex; Regex a = null; if (!string.IsNullOrEmpty(n)) { try { a = new Regex(n); } catch (Exception) { // invalid regex -> ignore } } // creates the list of commands int j = 1; foreach (var ele in list) { if (a != null) { if (a.Match(ele).Success) { continue; } } CommandID menuCommandID = new CommandID(GuidList.guidGruntLauncherCmdSet, (int)PkgCmdIDList.cmdidGulpLauncher + j); j++; OleMenuCommand command = new OleMenuCommand(this.GulpCallback, menuCommandID); command.Text = "Gulp: " + ele; command.BeforeQueryStatus += (x, y) => { (x as OleMenuCommand).Visible = true; }; commands.Add(command); mcs.AddCommand(command); } } }
protected override void CommandBeforeQueryStatus(EnvDTE80.DTE2 applicationObject, OleMenuCommand menuCommand) { CommonHandlers.ActionBeforeQueryStatusConnectionIsNotReadOnly(applicationObject, menuCommand); CommonHandlers.ActionBeforeQueryStatusOpenedDocumentsWebResource(applicationObject, menuCommand); }
protected override void CommandBeforeQueryStatus(EnvDTE80.DTE2 applicationObject, string solutionUniqueName, OleMenuCommand menuCommand) { CommonHandlers.ActionBeforeQueryStatusActiveDocumentJavaScriptHasLinkedEntityName(applicationObject, menuCommand); }
protected override void CommandBeforeQueryStatus(EnvDTE80.DTE2 applicationObject, OleMenuCommand menuCommand) { CommonHandlers.ActionBeforeQueryStatusActiveDocumentXml(applicationObject, menuCommand); CommonHandlers.ActionBeforeQueryStatusClipboardIsText(applicationObject, menuCommand); }
protected override void CommandBeforeQueryStatus(EnvDTE80.DTE2 applicationObject, OleMenuCommand menuCommand) { _sourceSelectedFiles.CommandBeforeQueryStatus(applicationObject, menuCommand, SelectedFileType.Report); }
protected override void CommandBeforeQueryStatus(EnvDTE80.DTE2 applicationObject, OleMenuCommand menuCommand) { CommonHandlers.ActionBeforeQueryStatusSolutionExplorerCSharpSingle(applicationObject, menuCommand); CommonHandlers.ActionBeforeQueryStatusSolutionExplorerSingleItemContainsProject(applicationObject, menuCommand); }
protected override void CommandBeforeQueryStatus(EnvDTE80.DTE2 applicationObject, ConnectionData connectionData, OleMenuCommand menuCommand) { CommonHandlers.ActionBeforeQueryStatusActiveDocumentIsXmlWithRootWithAttribute( applicationObject , menuCommand , Intellisense.Model.IntellisenseContext.IntellisenseContextAttributeSavedQueryId , out var attribute , AbstractDynamicCommandXsdSchemas.RootFetch , AbstractDynamicCommandXsdSchemas.RootGrid , AbstractDynamicCommandXsdSchemas.RootColumnSet ); if (attribute == null || !Guid.TryParse(attribute.Value, out _) ) { menuCommand.Enabled = menuCommand.Visible = false; } }
//--- protected override void OnExecute(OleMenuCommand command) => ExecuteCommand() .ShowProblem() .ShowInformation();
protected override void CommandBeforeQueryStatus(EnvDTE80.DTE2 applicationObject, OleMenuCommand menuCommand) { CommonHandlers.ActionBeforeQueryStatusActiveDocumentIsXmlWithRoot(applicationObject, menuCommand, out _, AbstractDynamicCommandXsdSchemas.RootFetch); CommonHandlers.CorrectCommandNameForConnectionName(applicationObject, menuCommand, Properties.CommandNames.CodeXmlFetchXmlExecuteRequestCommand); }
protected override void CommandBeforeQueryStatus(EnvDTE80.DTE2 applicationObject, ConnectionData connectionData, OleMenuCommand menuCommand) { if (connectionData.IsReadOnly) { menuCommand.Enabled = menuCommand.Visible = false; } else { menuCommand.Enabled = menuCommand.Visible = true; CommonHandlers.ActionBeforeQueryStatusListForPublishWebResourceTextAny(applicationObject, menuCommand); } }
protected override void CommandBeforeQueryStatus(EnvDTE80.DTE2 applicationObject, OleMenuCommand menuCommand) { CommonHandlers.CorrectCommandNameForConnectionName(applicationObject, menuCommand, Properties.CommandNames.CommonEntityRelationshipManyToManyExplorerCommand); }