summaryrefslogtreecommitdiffstats
path: root/win/CS
diff options
context:
space:
mode:
Diffstat (limited to 'win/CS')
-rw-r--r--win/CS/HandBrake.ApplicationServices/Model/Audio/AudioBehaviours.cs12
-rw-r--r--win/CS/HandBrake.ApplicationServices/Model/Preset.cs21
-rw-r--r--win/CS/HandBrake.ApplicationServices/Model/Subtitle/SubtitleBehaviours.cs12
-rw-r--r--win/CS/HandBrakeWPF/ViewModels/AudioViewModel.cs108
-rw-r--r--win/CS/HandBrakeWPF/ViewModels/MainViewModel.cs4
5 files changed, 88 insertions, 69 deletions
diff --git a/win/CS/HandBrake.ApplicationServices/Model/Audio/AudioBehaviours.cs b/win/CS/HandBrake.ApplicationServices/Model/Audio/AudioBehaviours.cs
index 119c8d26d..4363ec56d 100644
--- a/win/CS/HandBrake.ApplicationServices/Model/Audio/AudioBehaviours.cs
+++ b/win/CS/HandBrake.ApplicationServices/Model/Audio/AudioBehaviours.cs
@@ -38,6 +38,18 @@ namespace HandBrake.ApplicationServices.Model.Audio
}
/// <summary>
+ /// Initializes a new instance of the <see cref="AudioBehaviours"/> class.
+ /// </summary>
+ /// <param name="behaviours">
+ /// The behaviours.
+ /// </param>
+ public AudioBehaviours(AudioBehaviours behaviours)
+ {
+ this.SelectedBehaviour = behaviours.SelectedBehaviour;
+ this.SelectedLangauges = new BindingList<string>(behaviours.selectedLangauges);
+ }
+
+ /// <summary>
/// Gets or sets the selected behaviour.
/// </summary>
public AudioBehaviourModes SelectedBehaviour
diff --git a/win/CS/HandBrake.ApplicationServices/Model/Preset.cs b/win/CS/HandBrake.ApplicationServices/Model/Preset.cs
index 57faf2968..e281e12b6 100644
--- a/win/CS/HandBrake.ApplicationServices/Model/Preset.cs
+++ b/win/CS/HandBrake.ApplicationServices/Model/Preset.cs
@@ -28,7 +28,6 @@ namespace HandBrake.ApplicationServices.Model
#endregion
-
#region Properties
/// <summary>
@@ -108,6 +107,26 @@ namespace HandBrake.ApplicationServices.Model
#region Public Methods
/// <summary>
+ /// Update this preset.
+ /// The given parameters should be copy-constructed.
+ /// </summary>
+ /// <param name="task">
+ /// The task.
+ /// </param>
+ /// <param name="audioBehaviours">
+ /// The audio behaviours.
+ /// </param>
+ /// <param name="subtitleBehaviours">
+ /// The subtitle behaviours.
+ /// </param>
+ public void Update(EncodeTask task, AudioBehaviours audioBehaviours, SubtitleBehaviours subtitleBehaviours)
+ {
+ this.Task = task;
+ this.AudioTrackBehaviours = audioBehaviours;
+ this.SubtitleTrackBehaviours = subtitleBehaviours;
+ }
+
+ /// <summary>
/// Override the ToString Method
/// </summary>
/// <returns>
diff --git a/win/CS/HandBrake.ApplicationServices/Model/Subtitle/SubtitleBehaviours.cs b/win/CS/HandBrake.ApplicationServices/Model/Subtitle/SubtitleBehaviours.cs
index 28f5176d1..c96357c3b 100644
--- a/win/CS/HandBrake.ApplicationServices/Model/Subtitle/SubtitleBehaviours.cs
+++ b/win/CS/HandBrake.ApplicationServices/Model/Subtitle/SubtitleBehaviours.cs
@@ -48,6 +48,18 @@ namespace HandBrake.ApplicationServices.Model.Subtitle
}
/// <summary>
+ /// Initializes a new instance of the <see cref="SubtitleBehaviours"/> class.
+ /// </summary>
+ /// <param name="behaviours">
+ /// The behaviours.
+ /// </param>
+ public SubtitleBehaviours(SubtitleBehaviours behaviours)
+ {
+ this.SelectedBehaviour = behaviours.selectedBehaviour;
+ this.SelectedLangauges = new BindingList<string>(behaviours.SelectedLangauges);
+ }
+
+ /// <summary>
/// Gets or sets the selected behaviour.
/// </summary>
public SubtitleBehaviourModes SelectedBehaviour
diff --git a/win/CS/HandBrakeWPF/ViewModels/AudioViewModel.cs b/win/CS/HandBrakeWPF/ViewModels/AudioViewModel.cs
index 0e25b3f58..73741313f 100644
--- a/win/CS/HandBrakeWPF/ViewModels/AudioViewModel.cs
+++ b/win/CS/HandBrakeWPF/ViewModels/AudioViewModel.cs
@@ -9,7 +9,6 @@
namespace HandBrakeWPF.ViewModels
{
- using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.ComponentModel;
@@ -377,19 +376,11 @@ namespace HandBrakeWPF.ViewModels
if (preset != null && preset.Task != null)
{
- if (this.AudioBehaviours.SelectedBehaviour != AudioBehaviourModes.None)
- {
- this.AutomaticTrackSelection();
- }
- else
- {
- this.AddTracksFromPreset(preset);
- }
-
- this.AutomaticTrackSelection();
+ this.SetupTracks();
this.Task.AllowedPassthruOptions = new AllowedPassthru(preset.Task.AllowedPassthruOptions);
}
+
this.NotifyOfPropertyChange(() => this.Task);
}
@@ -435,7 +426,7 @@ namespace HandBrakeWPF.ViewModels
}
else
{
- this.AutomaticTrackSelection();
+ this.SetupTracks();
}
// Force UI Updates
@@ -485,39 +476,43 @@ namespace HandBrakeWPF.ViewModels
}
/// <summary>
- /// Add all remaining for selected languages.
+ /// Attempt to automatically select the correct audio tracks based on the users settings.
/// </summary>
- public void AddAllRemainingForSelectedLanguages()
+ private void SetupTracks()
{
- // Add them if they are not already added.
- foreach (Audio sourceTrack in this.GetSelectedLanguagesTracks())
+ if (!this.SourceTracks.Any())
{
- // Step 2: Check if the track list already contrains this track
- bool found = this.Task.AudioTracks.Any(audioTrack => Equals(audioTrack.ScannedTrack, sourceTrack));
- if (!found)
- {
- // If it doesn't, add it.
- this.Add(sourceTrack);
- }
+ // Clear out the old tracks
+ this.Task.AudioTracks.Clear();
+
+ return;
}
- }
- /// <summary>
- /// Add the required tracks for the current preset
- /// </summary>
- /// <param name="preset">
- /// The preset.
- /// </param>
- private void AddTracksFromPreset(Preset preset)
- {
- // Clear out the old tracks
+ // Step 1, Cleanup Previous Tracks
this.Task.AudioTracks.Clear();
- // Add the preset audio tracks with the preferred language
- foreach (AudioTrack track in preset.Task.AudioTracks)
+ // Step 2, Sanity Check
+ if (this.SourceTracks == null || !this.SourceTracks.Any())
+ {
+ return;
+ }
+
+ // Step 3, Setup the tracks from the preset
+ foreach (AudioTrack track in this.currentPreset.Task.AudioTracks)
{
this.Task.AudioTracks.Add(new AudioTrack(track) { ScannedTrack = this.GetPreferredAudioTrack() });
}
+
+ // Step 4, Handle the default selection behaviour.
+ switch (this.AudioBehaviours.SelectedBehaviour)
+ {
+ case AudioBehaviourModes.FirstMatch: // Adding all remaining audio tracks
+ this.AddFirstForSelectedLanguages();
+ break;
+ case AudioBehaviourModes.AllMatching: // Add Langauges tracks for the additional languages selected, in-order.
+ this.AddAllRemainingForSelectedLanguages();
+ break;
+ }
}
/// <summary>
@@ -550,41 +545,20 @@ namespace HandBrakeWPF.ViewModels
}
/// <summary>
- /// Attempt to automatically select the correct audio tracks based on the users settings.
+ /// Add all remaining for selected languages.
/// </summary>
- private void AutomaticTrackSelection()
+ public void AddAllRemainingForSelectedLanguages()
{
- if (!this.SourceTracks.Any())
- {
- // Clear out the old tracks
- this.Task.AudioTracks.Clear();
-
- return;
- }
-
- // We've changed source, so lets try reset the language, description and formats as close as possible to the previous track.
- foreach (AudioTrack track in this.Task.AudioTracks)
- {
- track.ScannedTrack = this.GetPreferredAudioTrack();
- }
-
- // Handle the default selection behaviour.
- if (this.AudioBehaviours.SelectedBehaviour != AudioBehaviourModes.None)
- {
- // First, we'll clear out all current tracks and go back to what the current preset has.
- // This will alteast provide a consistent behavior when switching tracks.
- this.Task.AudioTracks.Clear();
- this.AddTracksFromPreset(this.currentPreset);
- }
-
- switch (this.AudioBehaviours.SelectedBehaviour)
+ // Add them if they are not already added.
+ foreach (Audio sourceTrack in this.GetSelectedLanguagesTracks())
{
- case AudioBehaviourModes.FirstMatch: // Adding all remaining audio tracks
- this.AddFirstForSelectedLanguages();
- break;
- case AudioBehaviourModes.AllMatching: // Add Langauges tracks for the additional languages selected, in-order.
- this.AddAllRemainingForSelectedLanguages();
- break;
+ // Step 2: Check if the track list already contrains this track
+ bool found = this.Task.AudioTracks.Any(audioTrack => Equals(audioTrack.ScannedTrack, sourceTrack));
+ if (!found)
+ {
+ // If it doesn't, add it.
+ this.Add(sourceTrack);
+ }
}
}
diff --git a/win/CS/HandBrakeWPF/ViewModels/MainViewModel.cs b/win/CS/HandBrakeWPF/ViewModels/MainViewModel.cs
index aa60adf68..d9c2640f8 100644
--- a/win/CS/HandBrakeWPF/ViewModels/MainViewModel.cs
+++ b/win/CS/HandBrakeWPF/ViewModels/MainViewModel.cs
@@ -23,7 +23,9 @@ namespace HandBrakeWPF.ViewModels
using HandBrake.ApplicationServices.Factories;
using HandBrake.ApplicationServices.Model;
+ using HandBrake.ApplicationServices.Model.Audio;
using HandBrake.ApplicationServices.Model.Encoding;
+ using HandBrake.ApplicationServices.Model.Subtitle;
using HandBrake.ApplicationServices.Parsing;
using HandBrake.ApplicationServices.Services.Interfaces;
using HandBrake.ApplicationServices.Utilities;
@@ -1495,7 +1497,7 @@ namespace HandBrakeWPF.ViewModels
if (this.errorService.ShowMessageBox(Resources.Main_PresetUpdateConfrimation, Resources.AreYouSure, MessageBoxButton.YesNo, MessageBoxImage.Question) == MessageBoxResult.Yes)
{
- this.SelectedPreset.Task = new EncodeTask(this.CurrentTask);
+ this.SelectedPreset.Update(new EncodeTask(this.CurrentTask), new AudioBehaviours(this.AudioViewModel.AudioBehaviours), new SubtitleBehaviours(this.SubtitleViewModel.SubtitleBehaviours));
this.presetService.Update(this.SelectedPreset);
this.errorService.ShowMessageBox(