From ee6c524b2aae6165667ca8d1e9062667e85529e4 Mon Sep 17 00:00:00 2001 From: sr55 Date: Sat, 31 Dec 2016 13:04:46 +0000 Subject: [PATCH] WinGui: Store the Extra Args when switching video encoders. This prevents invalid arguments getting passed to the encoder and as a bonus, remembers the users setting if they switch back --- .../HandBrakeWPF/ViewModels/VideoViewModel.cs | 20 +++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/win/CS/HandBrakeWPF/ViewModels/VideoViewModel.cs b/win/CS/HandBrakeWPF/ViewModels/VideoViewModel.cs index 9b9daf5c6..39aab77e0 100644 --- a/win/CS/HandBrakeWPF/ViewModels/VideoViewModel.cs +++ b/win/CS/HandBrakeWPF/ViewModels/VideoViewModel.cs @@ -65,7 +65,8 @@ namespace HandBrakeWPF.ViewModels private bool displayTuneControls; private bool displayLevelControl; private bool displayProfileControl; - + private Dictionary encoderOptions = new Dictionary(); + #endregion #region Constructors and Destructors @@ -497,9 +498,15 @@ namespace HandBrakeWPF.ViewModels } set { - this.Task.VideoEncoder = value; - this.NotifyOfPropertyChange(() => this.SelectedVideoEncoder); - HandleEncoderChange(this.Task.VideoEncoder); + if (!object.Equals(value, this.Task.VideoEncoder)) + { + // Cache the current extra args. We can set them back later if the user switches back + this.encoderOptions[EnumHelper.GetShortName(this.Task.VideoEncoder)] = this.ExtraArguments; + + this.Task.VideoEncoder = value; + this.NotifyOfPropertyChange(() => this.SelectedVideoEncoder); + HandleEncoderChange(this.Task.VideoEncoder); + } } } @@ -1315,6 +1322,11 @@ namespace HandBrakeWPF.ViewModels this.NotifyOfPropertyChange(() => SelectedFramerate); this.UseAdvancedTab = false; } + + // Cleanup Extra Arguments + // Load the cached arguments. Saves the user from resetting when switching encoders. + string result; + this.ExtraArguments = this.encoderOptions.TryGetValue(EnumHelper.GetShortName(selectedEncoder), out result) ? result : string.Empty; } } } \ No newline at end of file -- 2.40.0