private void CloseToolWindow() { Application.Current.Dispatcher.Invoke(() => { try { SolutionOptionWindow.Close(this); } catch { } }); }
protected override async Task InitializeAsync(CancellationToken cancellationToken, IProgress <ServiceProgressData> progress) { await JoinableTaskFactory.SwitchToMainThreadAsync(cancellationToken); DTE = (DTE2)GetGlobalService(typeof(DTE)); DTE.Events.WindowEvents.WindowCreated += (_) => UpdateWindow(); DTE.Events.WindowEvents.WindowActivated += (_, __) => UpdateWindow(); DTE.Events.WindowEvents.WindowClosing += (_) => UpdateWindow(); DTE.Events.DocumentEvents.DocumentOpened += (_) => UpdateWindow(); DTE.Events.DocumentEvents.DocumentClosing += (_) => UpdateWindow(); SolutionEvents.OnAfterRenameSolution += (_, __) => OnSolutionUpdated(); SolutionEvents.OnAfterOpenSolution += (_, __) => OnSolutionOpend(); SolutionEvents.OnAfterCloseSolution += (_, __) => OnSolutionClosed(); SolutionEvents.OnBeforeCloseSolution += (_, __) => CloseToolWindow(); bool isSolutionLoaded = await IsSolutionLoadedAsync(); if (isSolutionLoaded) { OnSolutionOpend(); } await SolutionOptionWindowCommand.InitializeAsync(this); UserOption = new UserOptions(); UserOption.LoadSetting(); Settings = new SettingStore((Options)GetDialogPage(typeof(Options)), UserOption); if (isSolutionLoaded) { Settings.SolutionFilePath.Value = DTE.Solution.FileName; } SolutionOptionWindow.ConnectExisits(this); }