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(); } } }