From 12c2588e4d281f4cc16683d211a6cb8a76b4b1d5 Mon Sep 17 00:00:00 2001 From: sr55 Date: Sat, 26 May 2012 19:46:10 +0000 Subject: WinGui: Add a warning when closing the app while an encode is running. A fix for the Browse button not updating the Output format dropdown correctly. git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@4703 b64f7644-9d1e-0410-96f1-a4d463321fa5 --- win/CS/HandBrakeWPF/ViewModels/MainViewModel.cs | 45 ++++++++++++++++++++++--- 1 file changed, 41 insertions(+), 4 deletions(-) (limited to 'win/CS/HandBrakeWPF/ViewModels') diff --git a/win/CS/HandBrakeWPF/ViewModels/MainViewModel.cs b/win/CS/HandBrakeWPF/ViewModels/MainViewModel.cs index 71bf4c022..d8331354a 100644 --- a/win/CS/HandBrakeWPF/ViewModels/MainViewModel.cs +++ b/win/CS/HandBrakeWPF/ViewModels/MainViewModel.cs @@ -764,6 +764,29 @@ namespace HandBrakeWPF.ViewModels this.queueProcessor.EncodeService.EncodeStarted -= this.EncodeStarted; this.queueProcessor.EncodeService.EncodeStatusChanged -= this.EncodeStatusChanged; } + + /// + /// Handle the Window Closing Event and warn the user if an encode is in-progress + /// + /// + /// The CancelEventArgs. + /// + public void HandleWindowClosing(CancelEventArgs e) + { + if (this.encodeService.IsEncoding) + { + MessageBoxResult result = this.errorService.ShowMessageBox("HandBrake is currently encoding. Closing now will abort your encode.\nAre you sure you wish to exit?", "Warning", MessageBoxButton.YesNo, MessageBoxImage.Warning); + if (result == MessageBoxResult.No) + { + e.Cancel = true; + } + else + { + this.encodeService.Stop(); + } + } + } + #endregion #region Menu and Taskbar @@ -1072,9 +1095,24 @@ namespace HandBrakeWPF.ViewModels }; dialog.ShowDialog(); - this.CurrentTask.Destination = dialog.FileName; - this.NotifyOfPropertyChange("CurrentTask"); - this.SetExtension(Path.GetExtension(dialog.FileName)); + if (!string.IsNullOrEmpty(dialog.FileName)) + { + switch (Path.GetExtension(dialog.FileName)) + { + case ".mkv": + this.SelectedOutputFormat = OutputFormat.Mkv; + break; + case ".mp4": + this.SelectedOutputFormat = OutputFormat.Mp4; + break; + case ".m4v": + this.SelectedOutputFormat = OutputFormat.M4V; + break; + } + + this.CurrentTask.Destination = dialog.FileName; + this.NotifyOfPropertyChange(() => this.CurrentTask); + } } /// @@ -1269,7 +1307,6 @@ namespace HandBrakeWPF.ViewModels this.CurrentTask.LargeFile = false; this.CurrentTask.OptimizeMP4 = false; this.CurrentTask.IPod5GSupport = false; - this.selectedOutputFormat = OutputFormat.Mkv; } // Update The browse file extension display -- cgit v1.2.3