public MainWindow() { InitializeComponent(); LoadRemover.Init(); cropContainer.Visibility = Visibility.Collapsed; trimContainer.Visibility = Visibility.Collapsed; }
private void startButton_Click(object sender, RoutedEventArgs e) { string file = browseFile.Text; if (!VerifyFileExists(file)) { return; } float progressSteps = Enum.GetValues(typeof(LoadRemover.ProgressPhase)).Length; bool partialRun = partialRunCheckbox.IsChecked.Value; LoadRemover.CropSettings?cropSettings = null; if (cropCheckbox.IsChecked == true) { cropSettings = new LoadRemover.CropSettings(CropLeft.Value.Value, CropTop.Value.Value, CropRight.Value.Value, CropBot.Value.Value); } LoadRemover.TrimSettings?trimSettings = null; if (trimCheckbox.IsChecked == true) { trimSettings = new LoadRemover.TrimSettings((float)TrimStart.Value.GetValueOrDefault(TimeSpan.Zero).TotalSeconds, (float)TrimEnd.Value.GetValueOrDefault(TimeSpan.Zero).TotalSeconds); } bool resize = resizeVideoCheckbox.IsChecked == true; var task = Task.Run(() => { LoadType loadTypes = LoadType.None; Dispatcher.Invoke(() => { if (checkBoxLoadTypeDeath.IsChecked.GetValueOrDefault(false)) { loadTypes |= LoadType.Death; } if (checkBoxLoadTypeEndSign.IsChecked.GetValueOrDefault(false)) { loadTypes |= LoadType.EndSign; } if (checkBoxLoadTypeOverworld.IsChecked.GetValueOrDefault(false)) { loadTypes |= LoadType.Overworld; } if (checkBoxLoadTypeBackSign.IsChecked.GetValueOrDefault(false)) { loadTypes |= LoadType.BackSign; } if (checkBoxLoadTypeBoss.IsChecked.GetValueOrDefault(false)) { loadTypes |= LoadType.Boss; } if (checkBoxLoadTypeStart.IsChecked.GetValueOrDefault(false)) { loadTypes |= LoadType.Start; } }); try { LoadRemover.Start(file, partialRun, cropSettings, trimSettings, loadTypes, resize, (phase, progress) => UpdateProgress(phase, ((int)phase / progressSteps) + (progress / progressSteps)) ); } catch (Exception e) { Dispatcher.Invoke(() => { Debug.WriteLine(e.ToString()); MessageBox.Show($"An error occurred: {e.Message}{Environment.NewLine}{e.StackTrace}"); UpdateProgress(LoadRemover.ProgressPhase.Phase_10_Finished, 1.0f); }); } UpdateProgress(LoadRemover.ProgressPhase.Phase_10_Finished, 1.0f); }); }