/// <summary> /// This function is the callback used to execute the command when the menu item is clicked. /// See the constructor to see how the menu item is associated with this function using /// OleMenuCommandService service and MenuCommand class. /// </summary> /// <param name="sender">Event sender.</param> /// <param name="e">Event args.</param> private void OnDeployCommand(object sender, EventArgs e) { var selectedProject = SolutionHelper.CurrentSolution.SelectedProject; Debug.WriteLine($"Deploying project: {selectedProject.FullPath}"); PublishDialogWindow.PromptUser(selectedProject); }
/// <summary> /// Initializes the singleton instance of the command. /// </summary> /// <param name="package">Owner package, not null.</param> /// <param name="token"></param> public static async Task InitializeAsync(IGoogleCloudExtensionPackage package, CancellationToken token) { if (package == null) { throw new ArgumentNullException(nameof(package)); } if (await package.GetServiceAsync(typeof(IMenuCommandService)) is OleMenuCommandService commandService) { await package.JoinableTaskFactory.SwitchToMainThreadAsync(token); var menuCommandID = new CommandID(CommandSet, CommandId); var menuItem = new OleMenuCommand(OnDeployCommand, menuCommandID); menuItem.BeforeQueryStatus += OnBeforeQueryStatus; commandService.AddCommand(menuItem); } // <summary> // This function is the callback used to execute the command when the menu item is clicked. // See the constructor to see how the menu item is associated with this function using // OleMenuCommandService service and MenuCommand class. // </summary> // <param name="sender">Event sender.</param> // <param name="e">Event args.</param> async void OnDeployCommand(object sender, EventArgs e) { await GoogleCloudExtensionPackage.Instance.JoinableTaskFactory.SwitchToMainThreadAsync(); IParsedDteProject project = SolutionHelper.CurrentSolution.StartupProject.ParsedProject; PublishDialogWindow.PromptUser(project); } void OnBeforeQueryStatus(object sender, EventArgs e) { #pragma warning disable VSTHRD109 // Switch instead of assert in async methods ThreadHelper.ThrowIfNotOnUIThread(); #pragma warning restore VSTHRD109 // Switch instead of assert in async methods if (!(sender is OleMenuCommand menuCommand)) { return; } menuCommand.Visible = true; IParsedDteProject startupProject = SolutionHelper.CurrentSolution.StartupProject?.ParsedProject; if (startupProject == null) { menuCommand.Enabled = false; menuCommand.Text = Resources.PublishDialogGenericMenuHeader; } else { menuCommand.Enabled = PublishDialogWindow.CanPublish(startupProject) && !ShellUtils.Default.IsBusy(); menuCommand.Text = string.Format(Resources.PublishDialogProjectMenuHeader, startupProject.Name); } } }
/// <summary> /// This function is the callback used to execute the command when the menu item is clicked. /// See the constructor to see how the menu item is associated with this function using /// OleMenuCommandService service and MenuCommand class. /// </summary> /// <param name="sender">Event sender.</param> /// <param name="e">Event args.</param> private static void OnDeployCommand(object sender, EventArgs e) { ThreadHelper.ThrowIfNotOnUIThread(); ErrorHandlerUtils.HandleExceptions(() => { IParsedDteProject selectedProject = SolutionHelper.CurrentSolution.SelectedProject.ParsedProject; Debug.WriteLine($"Deploying project: {selectedProject.FullPath}"); PublishDialogWindow.PromptUser(selectedProject); }); }
public PublishDialogWindowViewModel(ISolutionProject project, IPublishDialogStep initialStep, PublishDialogWindow owner) { _owner = owner; _project = project; PrevCommand = new ProtectedCommand(OnPrevCommand); NextCommand = new ProtectedCommand(OnNextCommand); PublishCommand = new ProtectedCommand(OnPublishCommand); PushStep(initialStep); }
public PublishDialogWindowViewModel(ISolutionProject project, IPublishDialogStep initialStep, PublishDialogWindow owner) { _owner = owner; _project = project; PrevCommand = new ProtectedCommand(OnPrevCommand); NextCommand = new ProtectedCommand(OnNextCommand); PublishCommand = new ProtectedCommand(OnPublishCommand); PushStep(initialStep); }
private static void OnBeforeQueryStatus(object sender, EventArgs e) { ThreadHelper.ThrowIfNotOnUIThread(); if (!(sender is OleMenuCommand menuCommand)) { return; } IParsedDteProject selectedProject = SolutionHelper.CurrentSolution.SelectedProject?.ParsedProject; if (selectedProject == null || !PublishDialogWindow.CanPublish(selectedProject)) { menuCommand.Visible = false; } else { menuCommand.Visible = true; menuCommand.Enabled = !ShellUtils.Default.IsBusy(); } }
private void OnBeforeQueryStatus(object sender, EventArgs e) { var menuCommand = sender as OleMenuCommand; if (menuCommand == null) { return; } var selectedProject = SolutionHelper.CurrentSolution.SelectedProject; if (selectedProject == null || !PublishDialogWindow.CanPublish(selectedProject)) { menuCommand.Visible = false; } else { menuCommand.Visible = true; menuCommand.Enabled = !ShellUtils.IsBusy(); } }
private void OnBeforeQueryStatus(object sender, EventArgs e) { var menuCommand = sender as OleMenuCommand; if (menuCommand == null) { return; } menuCommand.Visible = true; var startupProject = SolutionHelper.CurrentSolution.StartupProject; if (startupProject == null) { menuCommand.Enabled = false; menuCommand.Text = Resources.PublishDialogGenericMenuHeader; } else { menuCommand.Enabled = PublishDialogWindow.CanPublish(startupProject) && !ShellUtils.IsBusy(); menuCommand.Text = String.Format(Resources.PublishDialogProjectMenuHeader, startupProject.Name); } }
/// <summary> /// Starts the publish wizard for the given <paramref name="project"/>. /// </summary> /// <param name="project">The project to publish.</param> public static void PromptUser(IParsedDteProject project) { var dialog = new PublishDialogWindow(project); dialog.ShowModal(); }
/// <summary> /// Starts the publish wizard for the given <paramref name="project"/>. /// </summary> /// <param name="project">The project to publish.</param> public static void PromptUser(ISolutionProject project) { var dialog = new PublishDialogWindow(project); dialog.ShowModal(); }
/// <summary> /// Starts the publish wizard for the given <paramref name="project"/>. /// </summary> /// <param name="project">The project to publish.</param> public static void PromptUser(ISolutionProject project) { var dialog = new PublishDialogWindow(project); dialog.ShowModal(); }