/// <summary> /// Initializes the singleton instance of the command. /// </summary> /// <param name="package">Owner package, not null.</param> public static async Task InitializeAsync(FormatOnSavePackage package) { // Switch to the main thread - the call to AddCommand in EnableDisableFormatOnSaveCommand's constructor requires // the UI thread. await ThreadHelper.JoinableTaskFactory.SwitchToMainThreadAsync(package.DisposalToken); var commandService = await package.GetServiceAsync(typeof(IMenuCommandService)) as OleMenuCommandService; Instance = new EnableDisableFormatOnSaveCommand(package, commandService); }
public SolutionExplorerContextMenu(FormatOnSavePackage package) { _package = package; var mcs = _package.MenuCommandService; var menuCommandId = new CommandID(GuidList.GuidFormatOnSaveCmdSetFile, (int)PkgCmdIdList.CmdIdFormatOnSaveFile); var menuItem = new MenuCommand(FormatOnSaveInFileEventHandler, menuCommandId) { Visible = true, Enabled = true }; mcs.AddCommand(menuItem); menuCommandId = new CommandID(GuidList.GuidFormatOnSaveCmdSetFolder, (int)PkgCmdIdList.CmdIdFormatOnSaveFolder); menuItem = new MenuCommand(FormatOnSaveInFolderEventHandler, menuCommandId) { Visible = true, Enabled = true }; mcs.AddCommand(menuItem); menuCommandId = new CommandID(GuidList.GuidFormatOnSaveCmdSetProject, (int)PkgCmdIdList.CmdIdFormatOnSaveProject); menuItem = new MenuCommand(FormatOnSaveInProjectEventHandler, menuCommandId) { Visible = true, Enabled = true }; mcs.AddCommand(menuItem); menuCommandId = new CommandID(GuidList.GuidFormatOnSaveCmdSetMultipleItems, (int)PkgCmdIdList.CmdIdFormatOnSaveMultipleItems); menuItem = new MenuCommand(FormatOnSaveInProjectEventHandler, menuCommandId) { Visible = true, Enabled = true }; mcs.AddCommand(menuItem); menuCommandId = new CommandID(GuidList.GuidFormatOnSaveCmdSetSolution, (int)PkgCmdIdList.CmdIdFormatOnSaveSolution); menuItem = new MenuCommand(FormatOnSaveInSolutionEventHandler, menuCommandId) { Visible = true, Enabled = true }; mcs.AddCommand(menuItem); menuCommandId = new CommandID(GuidList.GuidFormatOnSaveCmdSetSolutionFolder, (int)PkgCmdIdList.CmdIdFormatOnSaveSolutionFolder); menuItem = new MenuCommand(FormatOnSaveInSolutionFolderEventHandler, menuCommandId) { Visible = true, Enabled = true }; mcs.AddCommand(menuItem); }
/// <summary> /// Initializes a new instance of the <see cref="EnableDisableFormatOnSaveCommand" /> class. /// Adds our command handlers for menu (commands must exist in the command table file) /// </summary> /// <param name="package">Owner package, not null.</param> /// <param name="commandService">Command service to add command to, not null.</param> EnableDisableFormatOnSaveCommand(FormatOnSavePackage package, OleMenuCommandService commandService) { this.package = package ?? throw new ArgumentNullException(nameof(package)); commandService = commandService ?? throw new ArgumentNullException(nameof(commandService)); var menuCommandID = new CommandID(CommandSet, CommandId); var menuItem = new MenuCommand(Execute, menuCommandID) { Checked = package.OptionsPage.Enabled }; commandService.AddCommand(menuItem); }
public VsRunningDocTableEventsHandler(FormatOnSavePackage package) { _package = package; }