Beispiel #1
0
        private async void btnRefresh_Click(object sender, EventArgs e)
        {
            using var progressDlg = new ProgressForm(10000);
            try
            {
                Enabled                    = false;
                Cursor.Current             = Cursors.WaitCursor;
                progressDlg.Text           = Resources.Localization_RefreshAvailableVersion_Title;
                progressDlg.UserCancelText = Resources.Localization_Stop_Text;
                progressDlg.Show(this);
                await _currentRepository.RefreshUpdatesAsync(progressDlg.CancelToken);

                progressDlg.CurrentTaskProgress = 1.0f;
            }
            catch
            {
                if (!progressDlg.IsCanceledByUser)
                {
                    MessageBox.Show(Resources.Localization_Download_ErrorText,
                                    Resources.Localization_Download_ErrorTitle, MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
            finally
            {
                Cursor.Current = Cursors.Default;
                Enabled        = true;
                progressDlg.Hide();
                UpdateAvailableVersions();
            }
        }
Beispiel #2
0
        private async void btnAppUpdate_Click(object sender, EventArgs e)
        {
            if (Program.Updater.GetScheduledUpdateInfo() != null)
            {
                if (Program.InstallScheduledUpdate())
                {
                    Close();
                }
                UpdateInstallButton();
                return;
            }
            using var progressDlg = new ProgressForm();
            try
            {
                Enabled          = false;
                Cursor.Current   = Cursors.WaitCursor;
                progressDlg.Text = Resources.Localization_ApplicationUpdate_Title;
                var checkForUpdateDialogAdapter = new CheckForUpdateDialogAdapter(progressDlg);
                progressDlg.Show(this);
                var availableUpdate = await Program.Updater.CheckForUpdateVersionAsync(progressDlg.CancelToken);

                progressDlg.CurrentTaskProgress = 1.0f;
                if (availableUpdate == null)
                {
                    progressDlg.Hide();
                    MessageBox.Show(this, Resources.Localization_NoUpdatesFound_Text, Resources.Localization_CheckForUpdate_Title,
                                    MessageBoxButtons.OK, MessageBoxIcon.Information);
                    return;
                }
                var dialogResult = MessageBox.Show(string.Format(Resources.Localization_UpdateAvailableDownloadAsk_Text, availableUpdate.GetVersion()),
                                                   Resources.Localization_CheckForUpdate_Title, MessageBoxButtons.YesNo, MessageBoxIcon.Question);
                if (dialogResult == DialogResult.Yes)
                {
                    var downloadDialogAdapter = new DownloadProgressDialogAdapter(progressDlg);
                    var filePath = await Program.Updater.DownloadVersionAsync(availableUpdate, progressDlg.CancelToken, downloadDialogAdapter);

                    Program.Updater.ScheduleInstallUpdate(availableUpdate, filePath);
                }
            }
            catch
            {
                if (!progressDlg.IsCanceledByUser)
                {
                    progressDlg.Hide();
                    MessageBox.Show(this, Resources.Localization_Download_ErrorText,
                                    Resources.Localization_Download_ErrorTitle, MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
            finally
            {
                Cursor.Current = Cursors.Default;
                Enabled        = true;
                progressDlg.Hide();
                UpdateInstallButton();
            }
        }
Beispiel #3
0
        private void btnUninstall_Click(object sender, EventArgs e)
        {
            if (_currentInstallation.InstalledVersion != null)
            {
                var dialogResult = MessageBox.Show(Resources.Localization_Uninstall_QuestionText,
                                                   Resources.Localization_Uninstall_QuestionTitle, MessageBoxButtons.YesNo, MessageBoxIcon.Question);
                if (dialogResult == DialogResult.No)
                {
                    return;
                }
                using var progressDlg = new ProgressForm();
                try
                {
                    progressDlg.Text = Resources.Localization_UninstallLocalization_Text;
                    var uninstallDialogAdapter = new UninstallProgressDialogAdapter(progressDlg);
                    progressDlg.Show(this);
                    switch (_currentRepository.Installer.Uninstall(_currentGame.RootFolder.FullName))
                    {
                    case UninstallStatus.Success:
                        _gameSettings.RemoveCurrentLanguage();
                        _gameSettings.Load();
                        progressDlg.CurrentTaskProgress = 1.0f;
                        Program.RepositoryManager.RemoveInstalledRepository(_currentGame.Mode, _currentRepository);
                        break;

                    case UninstallStatus.Partial:
                        _gameSettings.RemoveCurrentLanguage();
                        _gameSettings.Load();
                        progressDlg.CurrentTaskProgress = 1.0f;
                        Program.RepositoryManager.RemoveInstalledRepository(_currentGame.Mode, _currentRepository);
                        MessageBox.Show(Resources.Localization_Uninstall_WarningText,
                                        Resources.Localization_Uninstall_WarningTitle, MessageBoxButtons.OK, MessageBoxIcon.Warning);
                        break;

                    case UninstallStatus.Failed:
                    default:
                        MessageBox.Show(Resources.Localization_Uninstall_ErrorText,
                                        Resources.Localization_Uninstall_ErrorTitle, MessageBoxButtons.OK, MessageBoxIcon.Error);
                        break;
                    }
                }
                catch
                {
                    MessageBox.Show(Resources.Localization_Uninstall_ErrorText,
                                    Resources.Localization_Uninstall_ErrorTitle, MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
                finally
                {
                    progressDlg.Hide();
                    UpdateControls();
                    cbRepository.Refresh();
                }
            }
        }
Beispiel #4
0
        private async void btnInstall_Click(object sender, EventArgs e)
        {
            if (cbVersions.SelectedItem is UpdateInfo selectedUpdateInfo)
            {
                using var progressDlg = new ProgressForm();
                try
                {
                    Enabled          = false;
                    Cursor.Current   = Cursors.WaitCursor;
                    progressDlg.Text = string.Format(Resources.Localization_InstallVersion_Title, selectedUpdateInfo.GetVersion());
                    var downloadDialogAdapter = new DownloadProgressDialogAdapter(progressDlg);
                    progressDlg.Show(this);
                    var filePath = await _currentRepository.DownloadAsync(selectedUpdateInfo, null,
                                                                          progressDlg.CancelToken, downloadDialogAdapter);

                    var installDialogAdapter = new InstallProgressDialogAdapter(progressDlg);
                    var result = _currentRepository.Installer.Install(filePath, _currentGame.RootFolder.FullName);
                    switch (result)
                    {
                    case InstallStatus.Success:
                        _gameSettings.Load();
                        progressDlg.CurrentTaskProgress = 1.0f;
                        Program.RepositoryManager.SetInstalledRepository(_currentGame.Mode, _currentRepository);
                        break;

                    case InstallStatus.PackageError:
                        MessageBox.Show(Resources.Localization_Package_ErrorText,
                                        Resources.Localization_Package_ErrorTitle, MessageBoxButtons.OK, MessageBoxIcon.Error);
                        break;

                    case InstallStatus.VerifyError:
                        MessageBox.Show(Resources.Localization_Verify_ErrorText,
                                        Resources.Localization_Verify_ErrorTitle, MessageBoxButtons.OK, MessageBoxIcon.Error);
                        break;

                    case InstallStatus.FileError:
                        MessageBox.Show(Resources.Localization_File_ErrorText,
                                        Resources.Localization_File_ErrorTitle, MessageBoxButtons.OK, MessageBoxIcon.Error);
                        break;

                    case InstallStatus.UnknownError:
                    default:
                        MessageBox.Show(Resources.Localization_Install_ErrorText,
                                        Resources.Localization_Install_ErrorTitle, MessageBoxButtons.OK, MessageBoxIcon.Error);
                        break;
                    }
                }
                catch
                {
                    if (!progressDlg.IsCanceledByUser)
                    {
                        MessageBox.Show(Resources.Localization_Download_ErrorText,
                                        Resources.Localization_Download_ErrorTitle, MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }
                }
                finally
                {
                    Cursor.Current = Cursors.Default;
                    Enabled        = true;
                    progressDlg.Hide();
                    UpdateControls();
                }
            }
        }