]> granicus.if.org Git - handbrake/commitdiff
WinGui: Store the Extra Args when switching video encoders. This prevents invalid...
authorsr55 <sr55.hb@outlook.com>
Sat, 31 Dec 2016 13:04:46 +0000 (13:04 +0000)
committersr55 <sr55.hb@outlook.com>
Sat, 31 Dec 2016 13:05:08 +0000 (13:05 +0000)
win/CS/HandBrakeWPF/ViewModels/VideoViewModel.cs

index 9b9daf5c608ae7bae5f961c9809e2437405546ae..39aab77e0e586ccf752c05fac21e964631b89a0a 100644 (file)
@@ -65,7 +65,8 @@ namespace HandBrakeWPF.ViewModels
         private bool displayTuneControls;\r
         private bool displayLevelControl;\r
         private bool displayProfileControl;\r
-\r
+        private Dictionary<string, string> encoderOptions = new Dictionary<string, string>();\r
+        \r
         #endregion\r
 \r
         #region Constructors and Destructors\r
@@ -497,9 +498,15 @@ namespace HandBrakeWPF.ViewModels
             }\r
             set\r
             {\r
-                this.Task.VideoEncoder = value;\r
-                this.NotifyOfPropertyChange(() => this.SelectedVideoEncoder);\r
-                HandleEncoderChange(this.Task.VideoEncoder);\r
+                if (!object.Equals(value, this.Task.VideoEncoder))\r
+                {\r
+                    // Cache the current extra args. We can set them back later if the user switches back\r
+                    this.encoderOptions[EnumHelper<VideoEncoder>.GetShortName(this.Task.VideoEncoder)] = this.ExtraArguments;\r
+\r
+                    this.Task.VideoEncoder = value;\r
+                    this.NotifyOfPropertyChange(() => this.SelectedVideoEncoder);\r
+                    HandleEncoderChange(this.Task.VideoEncoder);\r
+                }\r
             }\r
         }\r
 \r
@@ -1315,6 +1322,11 @@ namespace HandBrakeWPF.ViewModels
                 this.NotifyOfPropertyChange(() => SelectedFramerate);\r
                 this.UseAdvancedTab = false;\r
             }\r
+\r
+            // Cleanup Extra Arguments\r
+            // Load the cached arguments. Saves the user from resetting when switching encoders.\r
+            string result;\r
+            this.ExtraArguments = this.encoderOptions.TryGetValue(EnumHelper<VideoEncoder>.GetShortName(selectedEncoder), out result) ? result : string.Empty;\r
         }\r
     }\r
 }
\ No newline at end of file