private void OnPathChanged() { ProgressBarData.Progress = 0; string path = tbGameDir.Text; ImportStatus result = _importService.CanImport(path); ShowBannerWithResult(result); btnImport.IsEnabled = result == ImportStatus.CAN_IMPORT; }
private async void btnImport_Click(object sender, RoutedEventArgs e) { string dir = tbGameDir.Text; ImportStatus result = _importService.CanImport(dir); if (result == ImportStatus.ALREADY_EXISTS) { MessageWindow updateWindow = new MessageWindow("Update", "This version is already imported. Are you sure you want to overwrite it?\nUse this feature only if you want to save a newer build of the same version.", MessageWindowButtons.YesNo); updateWindow.ShowDialog(); if (updateWindow.Result != MessageWindowResult.Yes) { return; } } btnImport.IsEnabled = false; tbGameDir.IsEnabled = false; btnBrowse.IsEnabled = false; chbImportMods.IsEnabled = false; _isImportInProgress = true; btnImportText.Text = "Importing..."; Taskbar.ProgressState = TaskbarItemProgressState.Normal; Taskbar.ProgressValue = 0; Progress <int> progress = new Progress <int>(percent => { ProgressBarData.Progress = percent; Taskbar.ProgressValue = percent / 100.0; }); bool importMods = chbImportMods.IsChecked.GetValueOrDefault(false); await Task.Run(() => _importService.Import(dir, importMods, progress)); tbGameDir.IsEnabled = true; btnBrowse.IsEnabled = true; chbImportMods.IsEnabled = true; btnImportText.Text = "Import"; new MessageWindow("Finished", "Import successfully finished!\nYou can now play replays from this version through the Replays tab.\nAfter you make sure everything works, you can delete the original game directory.", MessageWindowButtons.OK).ShowDialog(); _isImportInProgress = false; OnPathChanged(); Taskbar.ProgressState = TaskbarItemProgressState.None; }