/// <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 Execute(object sender, EventArgs e) { try { ThreadHelper.ThrowIfNotOnUIThread(); var dte = (EnvDTE.DTE)ThreadHelper.JoinableTaskFactory.Run(() => ServiceProvider.GetServiceAsync(typeof(EnvDTE.DTE))); var solution = dte.Solution; IVsUIShell uiShell = (IVsUIShell)ThreadHelper.JoinableTaskFactory.Run(() => ServiceProvider.GetServiceAsync(typeof(IVsUIShell))); MultiTemplateView dialog = new MultiTemplateView(solution?.FullName); uiShell.GetDialogOwnerHwnd(out var hwnd); dialog.WindowStartupLocation = System.Windows.WindowStartupLocation.CenterOwner; uiShell.EnableModeless(0); try { WindowHelper.ShowModal(dialog, hwnd); } finally { // This will take place after the window is closed. uiShell.EnableModeless(1); } } catch (Exception exception) { Trace.WriteLine(exception); _package.ShowError(exception, "Error in Execute"); throw; } }
protected override void OnStartup(StartupEventArgs e) { base.OnStartup(e); string testSolutionName = null; if (e.Args.Length == 1) { testSolutionName = e.Args[0]; if (!testSolutionName.FileExists()) { testSolutionName = null; } } MultiTemplateView projectSelectView = new MultiTemplateView(testSolutionName); projectSelectView.ShowInTaskbar = true; projectSelectView.ShowDialog(); }