diff options
author | sr55 <[email protected]> | 2013-03-02 19:48:27 +0000 |
---|---|---|
committer | sr55 <[email protected]> | 2013-03-02 19:48:27 +0000 |
commit | 8708bacf7689dfe01af965a2ce7364f9ea5cfdfe (patch) | |
tree | 46384653e1127be721d61be92221646be72a1b3f /win/CS/HandBrakeWPF | |
parent | 76d7ab1861dbc85eb3e8ad35d365a35b4b681a96 (diff) |
WinGui: Port advanced tab caching code to trunk
git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@5285 b64f7644-9d1e-0410-96f1-a4d463321fa5
Diffstat (limited to 'win/CS/HandBrakeWPF')
-rw-r--r-- | win/CS/HandBrakeWPF/ViewModels/EncoderOptionsViewModel.cs | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/win/CS/HandBrakeWPF/ViewModels/EncoderOptionsViewModel.cs b/win/CS/HandBrakeWPF/ViewModels/EncoderOptionsViewModel.cs index e578d9688..f1da43828 100644 --- a/win/CS/HandBrakeWPF/ViewModels/EncoderOptionsViewModel.cs +++ b/win/CS/HandBrakeWPF/ViewModels/EncoderOptionsViewModel.cs @@ -9,6 +9,8 @@ namespace HandBrakeWPF.ViewModels
{
+ using System.Collections.Generic;
+
using HandBrake.ApplicationServices.Model;
using HandBrake.ApplicationServices.Parsing;
using HandBrake.Interop.Model.Encoding;
@@ -21,6 +23,11 @@ namespace HandBrakeWPF.ViewModels public class EncoderOptionsViewModel : ViewModelBase, IEncoderOptionsViewModel, ITabInterface
{
/// <summary>
+ /// The cached options.
+ /// </summary>
+ private readonly Dictionary<VideoEncoder, string> cachedOptions = new Dictionary<VideoEncoder, string>();
+
+ /// <summary>
/// Initializes a new instance of the <see cref="EncoderOptionsViewModel"/> class.
/// </summary>
public EncoderOptionsViewModel()
@@ -34,6 +41,16 @@ namespace HandBrakeWPF.ViewModels public EncodeTask Task { get; set; }
/// <summary>
+ /// Gets or sets the preset.
+ /// </summary>
+ public Preset Preset { get; set; }
+
+ /// <summary>
+ /// Gets or sets the current video encoder.
+ /// </summary>
+ public VideoEncoder CurrentVideoEncoder { get; set; }
+
+ /// <summary>
/// Gets or sets the options string.
/// </summary>
public string AdvancedOptionsString
@@ -64,6 +81,7 @@ namespace HandBrakeWPF.ViewModels public void SetSource(Title selectedTitle, Preset currentPreset, EncodeTask task)
{
this.Task = task;
+ this.Preset = currentPreset;
this.NotifyOfPropertyChange(() => this.AdvancedOptionsString);
}
@@ -79,6 +97,7 @@ namespace HandBrakeWPF.ViewModels public void SetPreset(Preset preset, EncodeTask task)
{
this.Task = task;
+ this.Preset = preset;
this.AdvancedOptionsString = preset.Task.AdvancedEncoderOptions;
}
@@ -102,6 +121,28 @@ namespace HandBrakeWPF.ViewModels /// </param>
public void SetEncoder(VideoEncoder encoder)
{
+ // Cache the existing string so it can be reused if the user changes the encoder back.
+ if (!string.IsNullOrEmpty(this.AdvancedOptionsString))
+ {
+ this.cachedOptions[CurrentVideoEncoder] = this.AdvancedOptionsString;
+ }
+
+ this.CurrentVideoEncoder = encoder;
+
+ // Set the option from the cached version if we have one.
+ string advacnedOptionsString;
+ if (cachedOptions.TryGetValue(encoder, out advacnedOptionsString)
+ && !string.IsNullOrEmpty(advacnedOptionsString))
+ {
+ this.AdvancedOptionsString = advacnedOptionsString;
+ }
+ else
+ {
+ this.AdvancedOptionsString = this.Preset != null && this.Preset.Task != null
+ && !string.IsNullOrEmpty(this.Preset.Task.AdvancedEncoderOptions)
+ ? this.Preset.Task.AdvancedEncoderOptions
+ : string.Empty;
+ }
}
/// <summary>
|