Beispiel #1
0
        private static void OnExecuteImagingToolsCommand(object sender, EventArgs e)
        {
            try
            {
                if (imagingToolsView == null || imagingToolsView.IsDisposed)
                {
                    imagingToolsViewModel?.Dispose();
                    imagingToolsViewModel = ViewModelFactory.CreateDefault();
                    imagingToolsView      = ViewFactory.CreateView(imagingToolsViewModel);
                }

                imagingToolsView.Show();
            }
            catch (Exception ex)
            {
                imagingToolsView?.Dispose();
                imagingToolsViewModel?.Dispose();
                imagingToolsView = null;
                ShellDialogs.Error(serviceProvider, Res.ErrorMessageUnexpectedError(ex.Message));
            }
        }
Beispiel #2
0
        private void InstallIfNeeded(IVsShell shellService)
        {
            if (shellService == null)
            {
                ShellDialogs.Error(this, Resources.ErrorMessage_ShellServiceUnavailable);
                return;
            }

            ThreadHelper.ThrowIfNotOnUIThread();
            shellService.GetProperty((int)__VSSPROPID2.VSSPROPID_VisualStudioDir, out object documentsDirObj);
            string           documentsDir     = documentsDirObj.ToString();
            string           targetPath       = Path.Combine(documentsDir, "Visualizers");
            InstallationInfo installedVersion = InstallationManager.GetInstallationInfo(targetPath);
            InstallationInfo availableVersion = InstallationManager.AvailableVersion;

            if (installedVersion.Installed && (installedVersion.Version == null || installedVersion.Version >= availableVersion.Version))
            {
                return;
            }

            InstallationManager.Install(targetPath, out string error, out string warning);
            if (error != null)
            {
                ShellDialogs.Error(this, Res.ErrorMessageFailedToInstall(targetPath, error));
            }
            else if (warning != null)
            {
                ShellDialogs.Warning(this, Res.WarningMessageInstallationFinishedWithWarning(targetPath, warning));
            }
            else if (installedVersion.Installed && installedVersion.Version != null)
            {
                ShellDialogs.Info(this, Res.InfoMessageUpgradeFinished(installedVersion.Version, availableVersion.Version, targetPath));
            }
            else
            {
                ShellDialogs.Info(this, Res.InfoMessageInstallationFinished(availableVersion.Version, targetPath));
            }
        }
Beispiel #3
0
        private static void OnExecuteImagingToolsCommand(object sender, EventArgs e)
        {
            try
            {
                if (manageInstallationsView == null || manageInstallationsView.IsDisposed)
                {
                    manageInstallationsViewModel?.Dispose();
#pragma warning disable VSTHRD010 // Invoke single-threaded types on Main thread - invoked in UI thread. And ThreadHelper.ThrowIfNotOnUIThread() just emits another warning.
                    shellService.GetProperty((int)__VSSPROPID2.VSSPROPID_VisualStudioDir, out object documentsDirObj);
#pragma warning restore VSTHRD010 // Invoke single-threaded types on Main thread
                    manageInstallationsViewModel = ViewModelFactory.CreateManageInstallations(documentsDirObj?.ToString());
                    manageInstallationsView      = ViewFactory.CreateView(manageInstallationsViewModel);
                }

                manageInstallationsView.Show();
            }
            catch (Exception ex)
            {
                manageInstallationsView?.Dispose();
                manageInstallationsViewModel?.Dispose();
                manageInstallationsView = null;
                ShellDialogs.Error(serviceProvider, Res.ErrorMessageUnexpectedError(ex.Message));
            }
        }