summaryrefslogtreecommitdiffstats
path: root/win/CS/HandBrakeWPF/ViewModels/AudioDefaultsViewModel.cs
diff options
context:
space:
mode:
authorsr55 <[email protected]>2016-02-07 21:32:16 +0000
committersr55 <[email protected]>2016-02-07 21:32:16 +0000
commit4827c1fefdef10053318477c2eed6386b374a779 (patch)
tree6dd65cdd450e894cff6b30ff1647ef8d639e1a25 /win/CS/HandBrakeWPF/ViewModels/AudioDefaultsViewModel.cs
parent8ce01f3f60df3e2065e44bdf2629f81b7b10b2b6 (diff)
WinGui: Fixes to the refactored Audio Defaults View. Settings were not getting applied correctly.
Diffstat (limited to 'win/CS/HandBrakeWPF/ViewModels/AudioDefaultsViewModel.cs')
-rw-r--r--win/CS/HandBrakeWPF/ViewModels/AudioDefaultsViewModel.cs240
1 files changed, 220 insertions, 20 deletions
diff --git a/win/CS/HandBrakeWPF/ViewModels/AudioDefaultsViewModel.cs b/win/CS/HandBrakeWPF/ViewModels/AudioDefaultsViewModel.cs
index f61aa4010..fc1760f8b 100644
--- a/win/CS/HandBrakeWPF/ViewModels/AudioDefaultsViewModel.cs
+++ b/win/CS/HandBrakeWPF/ViewModels/AudioDefaultsViewModel.cs
@@ -16,6 +16,8 @@ namespace HandBrakeWPF.ViewModels
using HandBrake.ApplicationServices.Utilities;
using HandBrakeWPF.Model.Audio;
+ using HandBrakeWPF.Services.Encode.Model;
+ using HandBrakeWPF.Services.Encode.Model.Models;
using HandBrakeWPF.Services.Presets.Model;
using HandBrakeWPF.Utilities;
using HandBrakeWPF.ViewModels.Interfaces;
@@ -27,19 +29,28 @@ namespace HandBrakeWPF.ViewModels
{
private BindingList<string> availableLanguages;
private AudioBehaviours audioBehaviours;
+ private EncodeTask task;
+
+ private AudioEncoder audioEncoderFallback;
#region Constructors and Destructors
/// <summary>
/// Initializes a new instance of the <see cref="AudioDefaultsViewModel"/> class.
/// </summary>
- public AudioDefaultsViewModel()
+ /// <param name="task">
+ /// The task.
+ /// </param>
+ public AudioDefaultsViewModel(EncodeTask task)
{
+ this.Task = task;
this.AudioBehaviours = new AudioBehaviours();
this.SelectedAvailableToMove = new BindingList<string>();
this.SelectedLangaugesToMove = new BindingList<string>();
this.AvailableLanguages = new BindingList<string>();
- this.SetupLanguages((Preset)null);
+ this.AudioEncoders = EnumHelper<AudioEncoder>.GetEnumList();
+
+ this.Setup((Preset)null, task);
}
#endregion
@@ -47,6 +58,31 @@ namespace HandBrakeWPF.ViewModels
#region Properties
/// <summary>
+ /// Gets or sets the task.
+ /// </summary>
+ public EncodeTask Task
+ {
+ get
+ {
+ return this.task;
+ }
+ set
+ {
+ if (Equals(value, this.task))
+ {
+ return;
+ }
+ this.task = value;
+ this.NotifyOfPropertyChange(() => this.Task);
+ }
+ }
+
+ /// <summary>
+ /// Gets or sets AudioEncoders.
+ /// </summary>
+ public IEnumerable<AudioEncoder> AudioEncoders { get; set; }
+
+ /// <summary>
/// Gets the audio behaviours.
/// </summary>
public AudioBehaviours AudioBehaviours
@@ -116,6 +152,162 @@ namespace HandBrakeWPF.ViewModels
/// </summary>
public BindingList<string> SelectedLangaugesToMove { get; private set; }
+ /// <summary>
+ /// Gets or sets a value indicating whether audio allow m p 3 pass.
+ /// </summary>
+ public bool AudioAllowMP3Pass
+ {
+ get
+ {
+ return this.Task.AllowedPassthruOptions.AudioAllowMP3Pass;
+ }
+
+ set
+ {
+ this.task.AllowedPassthruOptions.AudioAllowMP3Pass = value;
+ this.NotifyOfPropertyChange(() => this.AudioAllowMP3Pass);
+ }
+ }
+
+ /// <summary>
+ /// Gets or sets a value indicating whether audio allow aac pass.
+ /// </summary>
+ public bool AudioAllowAACPass
+ {
+ get
+ {
+ return this.Task.AllowedPassthruOptions.AudioAllowAACPass;
+ }
+
+ set
+ {
+ this.task.AllowedPassthruOptions.AudioAllowAACPass = value;
+ this.NotifyOfPropertyChange(() => this.AudioAllowAACPass);
+ }
+ }
+
+ /// <summary>
+ /// Gets or sets a value indicating whether audio allow ac3 pass.
+ /// </summary>
+ public bool AudioAllowAC3Pass
+ {
+ get
+ {
+ return this.Task.AllowedPassthruOptions.AudioAllowAC3Pass;
+ }
+
+ set
+ {
+ this.task.AllowedPassthruOptions.AudioAllowAC3Pass = value;
+ this.NotifyOfPropertyChange(() => this.AudioAllowAC3Pass);
+ }
+ }
+
+ /// <summary>
+ /// Gets or sets a value indicating whether audio allow eac3 pass.
+ /// </summary>
+ public bool AudioAllowEAC3Pass
+ {
+ get
+ {
+ return this.Task.AllowedPassthruOptions.AudioAllowEAC3Pass;
+ }
+
+ set
+ {
+ this.task.AllowedPassthruOptions.AudioAllowEAC3Pass = value;
+ this.NotifyOfPropertyChange(() => this.AudioAllowEAC3Pass);
+ }
+ }
+
+ /// <summary>
+ /// Gets or sets a value indicating whether audio allow dts pass.
+ /// </summary>
+ public bool AudioAllowDTSPass
+ {
+ get
+ {
+ return this.Task.AllowedPassthruOptions.AudioAllowDTSPass;
+ }
+
+ set
+ {
+ this.task.AllowedPassthruOptions.AudioAllowDTSPass = value;
+ this.NotifyOfPropertyChange(() => this.AudioAllowDTSPass);
+ }
+ }
+
+ /// <summary>
+ /// Gets or sets a value indicating whether audio allow dtshd pass.
+ /// </summary>
+ public bool AudioAllowDTSHDPass
+ {
+ get
+ {
+ return this.Task.AllowedPassthruOptions.AudioAllowDTSHDPass;
+ }
+
+ set
+ {
+ this.task.AllowedPassthruOptions.AudioAllowDTSHDPass = value;
+ this.NotifyOfPropertyChange(() => this.AudioAllowDTSHDPass);
+ }
+ }
+
+ /// <summary>
+ /// Gets or sets a value indicating whether audio allow true hd pass.
+ /// </summary>
+ public bool AudioAllowTrueHDPass
+ {
+ get
+ {
+ return this.Task.AllowedPassthruOptions.AudioAllowTrueHDPass;
+ }
+
+ set
+ {
+ this.task.AllowedPassthruOptions.AudioAllowTrueHDPass = value;
+ this.NotifyOfPropertyChange(() => this.AudioAllowTrueHDPass);
+ }
+ }
+
+ /// <summary>
+ /// Gets or sets a value indicating whether audio allow flac pass.
+ /// </summary>
+ public bool AudioAllowFlacPass
+ {
+ get
+ {
+ return this.Task.AllowedPassthruOptions.AudioAllowFlacPass;
+ }
+
+ set
+ {
+ this.task.AllowedPassthruOptions.AudioAllowFlacPass = value;
+ this.NotifyOfPropertyChange(() => this.AudioAllowFlacPass);
+ }
+ }
+
+ /// <summary>
+ /// Gets or sets the audio encoder fallback.
+ /// </summary>
+ public AudioEncoder AudioEncoderFallback
+ {
+ get
+ {
+ return this.audioEncoderFallback;
+ }
+ set
+ {
+ if (value == this.audioEncoderFallback)
+ {
+ return;
+ }
+ this.audioEncoderFallback = value;
+ this.NotifyOfPropertyChange(() => this.AudioEncoderFallback);
+ }
+ }
+
#endregion
#region Public Methods
@@ -180,38 +372,34 @@ namespace HandBrakeWPF.ViewModels
/// <param name="preset">
/// The preset.
/// </param>
- public void SetupLanguages(Preset preset)
- {
- if (preset != null)
- {
- this.SetupLanguages(preset.AudioTrackBehaviours.Clone());
- }
- }
-
- /// <summary>
- /// The setup languages.
- /// </summary>
- /// <param name="behaviours">
- /// The behaviours.
+ /// <param name="task">
+ /// The task.
/// </param>
- public void SetupLanguages(AudioBehaviours behaviours)
+ public void Setup(Preset preset, EncodeTask task)
{
- // Step 1, Set the behaviour mode
+ // Reset
this.AudioBehaviours.SelectedBehaviour = AudioBehaviourModes.None;
this.AudioBehaviours.SelectedLangauges.Clear();
- // Step 2, Get all the languages
+ // Setup for this Encode Task.
+ this.Task = task;
+
IDictionary<string, string> langList = LanguageUtilities.MapLanguages();
langList = (from entry in langList orderby entry.Key ascending select entry).ToDictionary(pair => pair.Key, pair => pair.Value);
- // Step 3, Setup Available Languages
this.AvailableLanguages.Clear();
foreach (string item in langList.Keys)
{
this.AvailableLanguages.Add(item);
}
- // Step 4, Set the Selected Languages
+ // Handle the Preset, if it's not null.
+ if (preset == null)
+ {
+ return;
+ }
+
+ AudioBehaviours behaviours = preset.AudioTrackBehaviours.Clone();
if (behaviours != null)
{
this.AudioBehaviours.SelectedBehaviour = behaviours.SelectedBehaviour;
@@ -223,6 +411,18 @@ namespace HandBrakeWPF.ViewModels
this.AudioBehaviours.SelectedLangauges.Add(selectedItem);
}
}
+
+ this.task.AllowedPassthruOptions = new AllowedPassthru(preset.Task.AllowedPassthruOptions);
+
+ this.NotifyOfPropertyChange(() => this.AudioAllowMP3Pass);
+ this.NotifyOfPropertyChange(() => this.AudioAllowAACPass);
+ this.NotifyOfPropertyChange(() => this.AudioAllowAC3Pass);
+ this.NotifyOfPropertyChange(() => this.AudioAllowEAC3Pass);
+ this.NotifyOfPropertyChange(() => this.AudioAllowDTSPass);
+ this.NotifyOfPropertyChange(() => this.AudioAllowDTSHDPass);
+ this.NotifyOfPropertyChange(() => this.AudioAllowTrueHDPass);
+ this.NotifyOfPropertyChange(() => this.AudioAllowFlacPass);
+ this.NotifyOfPropertyChange(() => this.AudioEncoderFallback);
}
#endregion