Esempio n. 1
0
        private void pluginInstallWizzard_BeforeSwitchPages(object sender, Wizard.BeforeSwitchPagesEventArgs e)
        {
            // get wizard page already displayed
            WizardPage oldPage = this.pluginInstallWizzard.Pages[e.OldIndex];

            // check if we're going forward from options page
            if (oldPage == this.installedStudioVersionsPage && e.NewIndex > e.OldIndex)
            {
                var selectedStudioVersionsGeneric = chkStudioVersions.CheckedObjects;
                if (selectedStudioVersionsGeneric.Count == 0)
                {
                    MessageBox.Show(this,
                                    Resources
                                    .InstallerForm_pluginInstallWizzard_BeforeSwitchPages_Please_select_at_least_one_Studio_version_,
                                    Resources.InstallerForm_pluginInstallWizzard_BeforeSwitchPages_Please_select_Studio_version, MessageBoxButtons.OK);
                    e.Cancel = true;
                    return;
                }


                _installService.StudioVersions = selectedStudioVersionsGeneric.OfType <StudioVersion>().ToList();
                if (!_installService.IsPluginInstalled())
                {
                    return;
                }
                var dialogResult = MessageBox.Show(this,
                                                   string.Format("Plugin {0} is already installed. Are you sure you want to continue?",
                                                                 _pluginPackageInfo.PluginName),
                                                   Resources.InstallerForm_pluginInstallWizzard_BeforeSwitchPages_Please_select_Studio_version,
                                                   MessageBoxButtons.YesNo);

                if (dialogResult == DialogResult.No)
                {
                    e.Cancel = true;
                    return;
                }

                var processes = _installService.GetStudioProcesses();
                if (processes.Count > 0)
                {
                    using (var processesForm = new Processes(processes))
                    {
                        processesForm.ShowDialog();
                    }
                    e.Cancel = true;
                    return;
                }
                _installService.RemoveInstalledPlugin();
            }
        }