summaryrefslogtreecommitdiffstats
path: root/win/CS/HandBrakeWPF/ViewModels
diff options
context:
space:
mode:
Diffstat (limited to 'win/CS/HandBrakeWPF/ViewModels')
-rw-r--r--win/CS/HandBrakeWPF/ViewModels/AddPresetViewModel.cs12
-rw-r--r--win/CS/HandBrakeWPF/ViewModels/AudioViewModel.cs310
-rw-r--r--win/CS/HandBrakeWPF/ViewModels/Interfaces/IAddPresetViewModel.cs10
-rw-r--r--win/CS/HandBrakeWPF/ViewModels/Interfaces/IAudioViewModel.cs7
-rw-r--r--win/CS/HandBrakeWPF/ViewModels/Interfaces/ISubtitlesViewModel.cs6
-rw-r--r--win/CS/HandBrakeWPF/ViewModels/MainViewModel.cs2
-rw-r--r--win/CS/HandBrakeWPF/ViewModels/OptionsViewModel.cs426
-rw-r--r--win/CS/HandBrakeWPF/ViewModels/QueueSelectionViewModel.cs12
-rw-r--r--win/CS/HandBrakeWPF/ViewModels/SubtitlesViewModel.cs348
9 files changed, 600 insertions, 533 deletions
diff --git a/win/CS/HandBrakeWPF/ViewModels/AddPresetViewModel.cs b/win/CS/HandBrakeWPF/ViewModels/AddPresetViewModel.cs
index 4235a67dc..bedfb838c 100644
--- a/win/CS/HandBrakeWPF/ViewModels/AddPresetViewModel.cs
+++ b/win/CS/HandBrakeWPF/ViewModels/AddPresetViewModel.cs
@@ -13,6 +13,8 @@ namespace HandBrakeWPF.ViewModels
using System.Windows;
using HandBrake.ApplicationServices.Model;
+ using HandBrake.ApplicationServices.Model.Audio;
+ using HandBrake.ApplicationServices.Model.Subtitle;
using HandBrake.ApplicationServices.Parsing;
using HandBrake.ApplicationServices.Services;
using HandBrake.ApplicationServices.Services.Interfaces;
@@ -132,9 +134,17 @@ namespace HandBrakeWPF.ViewModels
/// <param name="title">
/// The title.
/// </param>
- public void Setup(EncodeTask task, Title title)
+ /// <param name="audioBehaviours">
+ /// The audio Behaviours.
+ /// </param>
+ /// <param name="subtitleBehaviours">
+ /// The subtitle Behaviours.
+ /// </param>
+ public void Setup(EncodeTask task, Title title, AudioBehaviours audioBehaviours, SubtitleBehaviours subtitleBehaviours)
{
this.Preset.Task = new EncodeTask(task);
+ this.Preset.AudioTrackBehaviours = audioBehaviours.Clone();
+ this.Preset.SubtitleTrackBehaviours = subtitleBehaviours.Clone();
this.selectedTitle = title;
switch (task.Anamorphic)
diff --git a/win/CS/HandBrakeWPF/ViewModels/AudioViewModel.cs b/win/CS/HandBrakeWPF/ViewModels/AudioViewModel.cs
index ed619b010..0e25b3f58 100644
--- a/win/CS/HandBrakeWPF/ViewModels/AudioViewModel.cs
+++ b/win/CS/HandBrakeWPF/ViewModels/AudioViewModel.cs
@@ -9,21 +9,21 @@
namespace HandBrakeWPF.ViewModels
{
+ using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
- using System.Collections.Specialized;
+ using System.ComponentModel;
using System.Linq;
using Caliburn.Micro;
using HandBrake.ApplicationServices.Model;
+ using HandBrake.ApplicationServices.Model.Audio;
using HandBrake.ApplicationServices.Model.Encoding;
using HandBrake.ApplicationServices.Parsing;
using HandBrake.ApplicationServices.Utilities;
using HandBrake.Interop.Model.Encoding;
- using HandBrakeWPF.Commands;
- using HandBrakeWPF.Model;
using HandBrakeWPF.Services.Interfaces;
using HandBrakeWPF.ViewModels.Interfaces;
@@ -42,6 +42,21 @@ namespace HandBrakeWPF.ViewModels
/// </summary>
private Preset currentPreset;
+ /// <summary>
+ /// The show audio defaults panel.
+ /// </summary>
+ private bool showAudioDefaultsPanel;
+
+ /// <summary>
+ /// The available languages.
+ /// </summary>
+ private BindingList<string> availableLanguages;
+
+ /// <summary>
+ /// The audio behaviours.
+ /// </summary>
+ private AudioBehaviours audioBehaviours;
+
#region Constructors and Destructors
/// <summary>
@@ -60,6 +75,12 @@ namespace HandBrakeWPF.ViewModels
this.AudioEncoders = EnumHelper<AudioEncoder>.GetEnumList();
this.AudioMixdowns = EnumHelper<Mixdown>.GetEnumList();
this.SourceTracks = new List<Audio>();
+
+ this.AudioBehaviours = new AudioBehaviours();
+ this.SelectedAvailableToMove = new BindingList<string>();
+ this.SelectedLangaugesToMove = new BindingList<string>();
+ this.AvailableLanguages = new BindingList<string>();
+ this.SetupLanguages(null);
}
#endregion
@@ -67,6 +88,37 @@ namespace HandBrakeWPF.ViewModels
#region Properties
/// <summary>
+ /// Gets or sets the audio behaviours.
+ /// </summary>
+ public AudioBehaviours AudioBehaviours
+ {
+ get
+ {
+ return this.audioBehaviours;
+ }
+ set
+ {
+ if (Equals(value, this.audioBehaviours))
+ {
+ return;
+ }
+ this.audioBehaviours = value;
+ this.NotifyOfPropertyChange(() => this.AudioBehaviours);
+ }
+ }
+
+ /// <summary>
+ /// Gets the audio behaviour modes.
+ /// </summary>
+ public BindingList<AudioBehaviourModes> AudioBehaviourModeList
+ {
+ get
+ {
+ return new BindingList<AudioBehaviourModes>(EnumHelper<AudioBehaviourModes>.GetEnumList().ToList());
+ }
+ }
+
+ /// <summary>
/// Gets or sets AudioBitrates.
/// </summary>
public IEnumerable<int> AudioBitrates { get; set; }
@@ -108,16 +160,76 @@ namespace HandBrakeWPF.ViewModels
public EncodeTask Task { get; set; }
/// <summary>
- /// Gets a value indicating whether ShowPassthruOptions.
+ /// Gets or sets a value indicating whether show audio defaults panel.
+ /// </summary>
+ public bool ShowAudioDefaultsPanel
+ {
+ get
+ {
+ return this.showAudioDefaultsPanel;
+ }
+ set
+ {
+ if (value.Equals(this.showAudioDefaultsPanel))
+ {
+ return;
+ }
+ this.showAudioDefaultsPanel = value;
+ this.NotifyOfPropertyChange(() => this.ShowAudioDefaultsPanel);
+ this.NotifyOfPropertyChange(() => this.PanelTitle);
+ this.NotifyOfPropertyChange(() => this.SwitchDisplayTitle);
+ }
+ }
+
+ /// <summary>
+ /// Gets the panel title.
+ /// </summary>
+ public string PanelTitle
+ {
+ get
+ {
+ return this.ShowAudioDefaultsPanel ? "Audio Defaults" : "Audio Tracks";
+ }
+ }
+
+ /// <summary>
+ /// Gets the switch display title.
+ /// </summary>
+ public string SwitchDisplayTitle
+ {
+ get
+ {
+ return this.ShowAudioDefaultsPanel ? "Switch to Tracks" : "Switch to Defaults";
+ }
+ }
+
+ /// <summary>
+ /// Gets or sets AvailableLanguages.
/// </summary>
- public bool ShowPassthruOptions
+ public BindingList<string> AvailableLanguages
{
get
{
- return this.UserSettingService.GetUserSetting<bool>(UserSettingConstants.ShowAdvancedAudioPassthruOpts);
+ return this.availableLanguages;
+ }
+
+ set
+ {
+ this.availableLanguages = value;
+ this.NotifyOfPropertyChange("AvailableLanguages");
}
}
+ /// <summary>
+ /// Gets or sets SelectedLangauges.
+ /// </summary>
+ public BindingList<string> SelectedAvailableToMove { get; set; }
+
+ /// <summary>
+ /// Gets or sets SelectedLangauges.
+ /// </summary>
+ public BindingList<string> SelectedLangaugesToMove { get; set; }
+
#endregion
#region Public Methods
@@ -179,8 +291,65 @@ namespace HandBrakeWPF.ViewModels
/// </summary>
public void SetDefaultBehaviour()
{
- OpenOptionsScreenCommand command = new OpenOptionsScreenCommand();
- command.Execute(OptionsTab.AudioAndSubtitles);
+ this.ShowAudioDefaultsPanel = true;
+ }
+
+ /// <summary>
+ /// The show audio defaults.
+ /// </summary>
+ public void ShowAudioDefaults()
+ {
+ this.ShowAudioDefaultsPanel = !this.ShowAudioDefaultsPanel;
+ }
+
+ /// <summary>
+ /// Audio List Move Left
+ /// </summary>
+ public void LanguageMoveRight()
+ {
+ if (this.SelectedAvailableToMove.Count > 0)
+ {
+ List<string> copiedList = SelectedAvailableToMove.ToList();
+ foreach (string item in copiedList)
+ {
+ this.AvailableLanguages.Remove(item);
+ this.AudioBehaviours.SelectedLangauges.Add(item);
+ }
+
+ this.AvailableLanguages = new BindingList<string>(this.AvailableLanguages.OrderBy(o => o).ToList());
+ }
+ }
+
+ /// <summary>
+ /// Audio List Move Right
+ /// </summary>
+ public void LanguageMoveLeft()
+ {
+ if (this.SelectedLangaugesToMove.Count > 0)
+ {
+ List<string> copiedList = SelectedLangaugesToMove.ToList();
+ foreach (string item in copiedList)
+ {
+ this.AudioBehaviours.SelectedLangauges.Remove(item);
+ this.AvailableLanguages.Add(item);
+ }
+ }
+
+ this.AvailableLanguages = new BindingList<string>(this.AvailableLanguages.OrderBy(o => o).ToList());
+ }
+
+ /// <summary>
+ /// Audio List Clear all selected languages
+ /// </summary>
+ public void LanguageClearAll()
+ {
+ foreach (string item in this.AudioBehaviours.SelectedLangauges)
+ {
+ this.AvailableLanguages.Add(item);
+ }
+ this.AvailableLanguages = new BindingList<string>(this.AvailableLanguages.OrderBy(o => o).ToList());
+
+ this.AudioBehaviours.SelectedLangauges.Clear();
}
#endregion
@@ -203,16 +372,18 @@ namespace HandBrakeWPF.ViewModels
this.Task = task;
this.currentPreset = preset;
+ // Audio Behaviours
+ this.SetupLanguages(preset);
+
if (preset != null && preset.Task != null)
{
- int mode = this.UserSettingService.GetUserSetting<int>(UserSettingConstants.DubModeAudio);
- if (mode >= 1)
+ if (this.AudioBehaviours.SelectedBehaviour != AudioBehaviourModes.None)
{
this.AutomaticTrackSelection();
}
else
{
- this.AddTracksFromPreset(preset);
+ this.AddTracksFromPreset(preset);
}
this.AutomaticTrackSelection();
@@ -303,12 +474,6 @@ namespace HandBrakeWPF.ViewModels
// For all the source audio tracks
foreach (Audio sourceTrack in this.SourceTracks)
{
- // Step 1: If "Add only One per language" is turned on, check to see if this language is already added.
- if (this.CanSkipSourceTrack(sourceTrack))
- {
- continue;
- }
-
// Step 2: Check if the track list already contrains this track
bool found = this.Task.AudioTracks.Any(audioTrack => Equals(audioTrack.ScannedTrack, sourceTrack));
if (!found)
@@ -327,12 +492,6 @@ namespace HandBrakeWPF.ViewModels
// Add them if they are not already added.
foreach (Audio sourceTrack in this.GetSelectedLanguagesTracks())
{
- // Step 1: If "Add only One per language" is turned on, check to see if this language is already added.
- if (this.CanSkipSourceTrack(sourceTrack))
- {
- continue;
- }
-
// Step 2: Check if the track list already contrains this track
bool found = this.Task.AudioTracks.Any(audioTrack => Equals(audioTrack.ScannedTrack, sourceTrack));
if (!found)
@@ -362,6 +521,35 @@ namespace HandBrakeWPF.ViewModels
}
/// <summary>
+ /// The add first for selected languages.
+ /// </summary>
+ private void AddFirstForSelectedLanguages()
+ {
+ foreach (Audio sourceTrack in this.GetSelectedLanguagesTracks())
+ {
+ // Step 2: Check if the track list already contrains this track
+ bool found = this.Task.AudioTracks.Any(audioTrack => Equals(audioTrack.ScannedTrack, sourceTrack));
+ if (!found)
+ {
+ // Check if we are already using this language
+ bool foundLanguage = false;
+ foreach (var item in this.Task.AudioTracks.Where(item => item.ScannedTrack != null && sourceTrack.LanguageCode.Contains(item.ScannedTrack.LanguageCode)))
+ {
+ foundLanguage = true;
+ }
+
+ if (foundLanguage)
+ {
+ continue;
+ }
+
+ // If it doesn't, add it.
+ this.Add(sourceTrack);
+ }
+ }
+ }
+
+ /// <summary>
/// Attempt to automatically select the correct audio tracks based on the users settings.
/// </summary>
private void AutomaticTrackSelection()
@@ -381,8 +569,7 @@ namespace HandBrakeWPF.ViewModels
}
// Handle the default selection behaviour.
- int mode = this.UserSettingService.GetUserSetting<int>(UserSettingConstants.DubModeAudio);
- if (mode == 1 || mode == 2)
+ 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.
@@ -390,12 +577,12 @@ namespace HandBrakeWPF.ViewModels
this.AddTracksFromPreset(this.currentPreset);
}
- switch (mode)
+ switch (this.AudioBehaviours.SelectedBehaviour)
{
- case 1: // Adding all remaining audio tracks
- this.AddAllRemaining();
+ case AudioBehaviourModes.FirstMatch: // Adding all remaining audio tracks
+ this.AddFirstForSelectedLanguages();
break;
- case 2: // Add Langauges tracks for the additional languages selected, in-order.
+ case AudioBehaviourModes.AllMatching: // Add Langauges tracks for the additional languages selected, in-order.
this.AddAllRemainingForSelectedLanguages();
break;
}
@@ -409,12 +596,18 @@ namespace HandBrakeWPF.ViewModels
/// </returns>
private Audio GetPreferredAudioTrack()
{
- // Get the preferred Language
- IEnumerable<Audio> preferredAudioTracks =
- this.SourceTracks.Where(
- item =>
- item.Language.Contains(
- this.UserSettingService.GetUserSetting<string>(UserSettingConstants.NativeLanguage)));
+ // The first track in the selected languages list is considered the preferred language.
+ // So, try match tracks on this.
+ IEnumerable<Audio> preferredAudioTracks = new List<Audio>();
+ if (this.AudioBehaviours.SelectedLangauges.Count > 0)
+ {
+ string langName = this.AudioBehaviours.SelectedLangauges.FirstOrDefault(w => !w.Equals(Constants.Any));
+ if (!string.IsNullOrEmpty(langName))
+ {
+ preferredAudioTracks = this.SourceTracks.Where(item => item.Language.Contains(langName));
+ }
+ }
+
return preferredAudioTracks.FirstOrDefault() ?? this.SourceTracks.FirstOrDefault();
}
@@ -428,9 +621,10 @@ namespace HandBrakeWPF.ViewModels
{
List<Audio> trackList = new List<Audio>();
- List<string> isoCodes =
- LanguageUtilities.GetLanguageCodes(
- this.UserSettingService.GetUserSetting<StringCollection>(UserSettingConstants.SelectedLanguages));
+ List<string> isoCodes = this.AudioBehaviours.SelectedLangauges.Contains(Constants.Any)
+ ? LanguageUtilities.GetIsoCodes()
+ : LanguageUtilities.GetLanguageCodes(
+ this.AudioBehaviours.SelectedLangauges.ToArray());
foreach (string code in isoCodes)
{
@@ -441,25 +635,39 @@ namespace HandBrakeWPF.ViewModels
}
/// <summary>
- /// Checks to see if we can skip over the given source audio track.
- /// True when the user has set "Add only one per language" feature AND the language is contained in the track list.
+ /// The setup languages.
/// </summary>
- /// <param name="sourceTrack">
- /// The source track.
+ /// <param name="preset">
+ /// The preset.
/// </param>
- /// <returns>
- /// True when the user has set "Add only one per language" feature AND the language is contained in the track list
- /// </returns>
- private bool CanSkipSourceTrack(Audio sourceTrack)
+ private void SetupLanguages(Preset preset)
{
- bool addOnlyOnePerLanguage = this.UserSettingService.GetUserSetting<bool>(UserSettingConstants.AddOnlyOneAudioPerLanguage);
- bool sourceTrackLanguageFound = this.Task.AudioTracks.Any(audioTrack => audioTrack.ScannedTrack != null && sourceTrack.Language == audioTrack.ScannedTrack.Language);
- if (addOnlyOnePerLanguage && sourceTrackLanguageFound)
+ // Step 1, Set the behaviour mode
+ this.AudioBehaviours.SelectedBehaviour = AudioBehaviourModes.None;
+ this.AudioBehaviours.SelectedLangauges.Clear();
+
+ // Step 2, Get all the languages
+ 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)
{
- return true; // This track can be skipped.
+ this.AvailableLanguages.Add(item);
}
- return false;
+ // Step 4, Set the Selected Languages
+ if (preset != null && preset.AudioTrackBehaviours != null)
+ {
+ this.AudioBehaviours.SelectedBehaviour = preset.AudioTrackBehaviours.SelectedBehaviour;
+
+ foreach (string selectedItem in preset.AudioTrackBehaviours.SelectedLangauges)
+ {
+ this.AvailableLanguages.Remove(selectedItem);
+ this.AudioBehaviours.SelectedLangauges.Add(selectedItem);
+ }
+ }
}
#endregion
diff --git a/win/CS/HandBrakeWPF/ViewModels/Interfaces/IAddPresetViewModel.cs b/win/CS/HandBrakeWPF/ViewModels/Interfaces/IAddPresetViewModel.cs
index ac0ec160f..3ea543b1f 100644
--- a/win/CS/HandBrakeWPF/ViewModels/Interfaces/IAddPresetViewModel.cs
+++ b/win/CS/HandBrakeWPF/ViewModels/Interfaces/IAddPresetViewModel.cs
@@ -10,6 +10,8 @@
namespace HandBrakeWPF.ViewModels.Interfaces
{
using HandBrake.ApplicationServices.Model;
+ using HandBrake.ApplicationServices.Model.Audio;
+ using HandBrake.ApplicationServices.Model.Subtitle;
using HandBrake.ApplicationServices.Parsing;
/// <summary>
@@ -26,6 +28,12 @@ namespace HandBrakeWPF.ViewModels.Interfaces
/// <param name="title">
/// The title.
/// </param>
- void Setup(EncodeTask task, Title title);
+ /// <param name="audioBehaviours">
+ /// The audio Behaviours.
+ /// </param>
+ /// <param name="subtitleBehaviours">
+ /// The subtitle Behaviours.
+ /// </param>
+ void Setup(EncodeTask task, Title title, AudioBehaviours audioBehaviours, SubtitleBehaviours subtitleBehaviours);
}
}
diff --git a/win/CS/HandBrakeWPF/ViewModels/Interfaces/IAudioViewModel.cs b/win/CS/HandBrakeWPF/ViewModels/Interfaces/IAudioViewModel.cs
index 6f3edca2a..41d7f4940 100644
--- a/win/CS/HandBrakeWPF/ViewModels/Interfaces/IAudioViewModel.cs
+++ b/win/CS/HandBrakeWPF/ViewModels/Interfaces/IAudioViewModel.cs
@@ -9,12 +9,19 @@
namespace HandBrakeWPF.ViewModels.Interfaces
{
+ using HandBrake.ApplicationServices.Model.Audio;
+
/// <summary>
/// The Audio View Model Interface
/// </summary>
public interface IAudioViewModel : ITabInterface
{
/// <summary>
+ /// Gets the audio behaviours.
+ /// </summary>
+ AudioBehaviours AudioBehaviours { get; }
+
+ /// <summary>
/// Trigger a Notify Property Changed on the Task to force various UI elements to update.
/// </summary>
void RefreshTask();
diff --git a/win/CS/HandBrakeWPF/ViewModels/Interfaces/ISubtitlesViewModel.cs b/win/CS/HandBrakeWPF/ViewModels/Interfaces/ISubtitlesViewModel.cs
index 2b10089de..27d096fb5 100644
--- a/win/CS/HandBrakeWPF/ViewModels/Interfaces/ISubtitlesViewModel.cs
+++ b/win/CS/HandBrakeWPF/ViewModels/Interfaces/ISubtitlesViewModel.cs
@@ -9,10 +9,16 @@
namespace HandBrakeWPF.ViewModels.Interfaces
{
+ using HandBrake.ApplicationServices.Model.Subtitle;
+
/// <summary>
/// The Subtiles View Model Interface
/// </summary>
public interface ISubtitlesViewModel : ITabInterface
{
+ /// <summary>
+ /// Gets the subtitle behaviours.
+ /// </summary>
+ SubtitleBehaviours SubtitleBehaviours { get; }
}
}
diff --git a/win/CS/HandBrakeWPF/ViewModels/MainViewModel.cs b/win/CS/HandBrakeWPF/ViewModels/MainViewModel.cs
index a531b549c..d5d02a0f8 100644
--- a/win/CS/HandBrakeWPF/ViewModels/MainViewModel.cs
+++ b/win/CS/HandBrakeWPF/ViewModels/MainViewModel.cs
@@ -1462,7 +1462,7 @@ namespace HandBrakeWPF.ViewModels
public void PresetAdd()
{
IAddPresetViewModel presetViewModel = IoC.Get<IAddPresetViewModel>();
- presetViewModel.Setup(this.CurrentTask, this.SelectedTitle);
+ presetViewModel.Setup(this.CurrentTask, this.SelectedTitle, this.AudioViewModel.AudioBehaviours, this.SubtitleViewModel.SubtitleBehaviours);
this.WindowManager.ShowWindow(presetViewModel);
}
diff --git a/win/CS/HandBrakeWPF/ViewModels/OptionsViewModel.cs b/win/CS/HandBrakeWPF/ViewModels/OptionsViewModel.cs
index b6b301d2b..9cf6c694b 100644
--- a/win/CS/HandBrakeWPF/ViewModels/OptionsViewModel.cs
+++ b/win/CS/HandBrakeWPF/ViewModels/OptionsViewModel.cs
@@ -10,8 +10,6 @@
namespace HandBrakeWPF.ViewModels
{
using System;
- using System.Collections.Generic;
- using System.Collections.Specialized;
using System.ComponentModel;
using System.Diagnostics;
using System.Globalization;
@@ -21,9 +19,7 @@ namespace HandBrakeWPF.ViewModels
using Caliburn.Micro;
- using HandBrake.ApplicationServices;
using HandBrake.ApplicationServices.Model;
- using HandBrake.ApplicationServices.Services.Interfaces;
using HandBrake.ApplicationServices.Utilities;
using HandBrakeWPF.Model;
@@ -55,26 +51,6 @@ namespace HandBrakeWPF.ViewModels
private readonly IUpdateService updateService;
/// <summary>
- /// The add audio mode options.
- /// </summary>
- private BindingList<string> addAudioModeOptions = new BindingList<string>();
-
- /// <summary>
- /// The add closed captions.
- /// </summary>
- private bool addClosedCaptions;
-
- /// <summary>
- /// The add only one audio track per language.
- /// </summary>
- private bool addOnlyOneAudioTrackPerLanguage;
-
- /// <summary>
- /// The add subtitle mode options.
- /// </summary>
- private BindingList<string> addSubtitleModeOptions = new BindingList<string>();
-
- /// <summary>
/// The arguments.
/// </summary>
private string arguments;
@@ -95,11 +71,6 @@ namespace HandBrakeWPF.ViewModels
private string autonameFormat;
/// <summary>
- /// The available languages.
- /// </summary>
- private BindingList<string> availableLanguages = new BindingList<string>();
-
- /// <summary>
/// The change to title case.
/// </summary>
private bool changeToTitleCase;
@@ -205,16 +176,6 @@ namespace HandBrakeWPF.ViewModels
private bool removeUnderscores;
/// <summary>
- /// The selected add audio mode.
- /// </summary>
- private int selectedAddAudioMode;
-
- /// <summary>
- /// The selected add subtitle mode.
- /// </summary>
- private int selectedAddSubtitleMode;
-
- /// <summary>
/// The selected granulairty.
/// </summary>
private string selectedGranulairty;
@@ -225,21 +186,6 @@ namespace HandBrakeWPF.ViewModels
private int selectedMp4Extension;
/// <summary>
- /// The selected preferred languages.
- /// </summary>
- private BindingList<string> preferredLanguages = new BindingList<string>();
-
- /// <summary>
- /// The selected preferred langauge.
- /// </summary>
- private string selectedPreferredLangauge;
-
- /// <summary>
- /// The selected preferred subtitle language
- /// </summary>
- private string selectedPreferredSubtitleLangauge;
-
- /// <summary>
/// The selected preview count.
/// </summary>
private int selectedPreviewCount;
@@ -285,16 +231,6 @@ namespace HandBrakeWPF.ViewModels
private BindingList<string> whenDoneOptions = new BindingList<string>();
/// <summary>
- /// Selected Langauges
- /// </summary>
- private BindingList<string> selectedLangauges = new BindingList<string>();
-
- /// <summary>
- /// The backing field for show advanced passthru options for Audio
- /// </summary>
- private bool showAdvancedPassthruOpts;
-
- /// <summary>
/// Backing field for clear queue on encode completed.
/// </summary>
private bool clearQueueOnEncodeCompleted;
@@ -375,11 +311,6 @@ namespace HandBrakeWPF.ViewModels
private bool disableQuickSyncDecoding;
/// <summary>
- /// The add foreign audio scan track.
- /// </summary>
- private bool addForeignAudioScanTrack;
-
- /// <summary>
/// The is cl scaling.
/// </summary>
private bool isClScaling;
@@ -824,242 +755,6 @@ namespace HandBrakeWPF.ViewModels
}
#endregion
- #region Audio and Subtitles
-
- /// <summary>
- /// Gets or sets preferredLanguages.
- /// </summary>
- public BindingList<string> PreferredLanguages
- {
- get
- {
- return this.preferredLanguages;
- }
-
- set
- {
- this.preferredLanguages = value;
- this.NotifyOfPropertyChange("PreferredLanguages");
- }
- }
-
- /// <summary>
- /// Gets or sets SelectedPreferreedLangauge.
- /// </summary>
- public string SelectedPreferredLangauge
- {
- get
- {
- return this.selectedPreferredLangauge;
- }
-
- set
- {
- this.selectedPreferredLangauge = value;
- this.NotifyOfPropertyChange(() => SelectedPreferredLangauge);
- }
- }
-
- /// <summary>
- /// Gets or sets SelectedPreferredSubtitleLangauge.
- /// </summary>
- public string SelectedPreferredSubtitleLangauge
- {
- get
- {
- return this.selectedPreferredSubtitleLangauge;
- }
-
- set
- {
- this.selectedPreferredSubtitleLangauge = value;
- this.NotifyOfPropertyChange(() => SelectedPreferredSubtitleLangauge);
- }
- }
-
- /// <summary>
- /// Gets or sets AvailableLanguages.
- /// </summary>
- public BindingList<string> AvailableLanguages
- {
- get
- {
- return this.availableLanguages;
- }
-
- set
- {
- this.availableLanguages = value;
- this.NotifyOfPropertyChange("AvailableLanguages");
- }
- }
-
- /// <summary>
- /// Gets or sets SelectedLangauges.
- /// </summary>
- public BindingList<string> SelectedLangauges
- {
- get
- {
- return this.selectedLangauges;
- }
- set
- {
- this.selectedLangauges = value;
- this.NotifyOfPropertyChange("SelectedLangauges");
- }
- }
-
- /// <summary>
- /// Gets or sets SelectedLangauges.
- /// </summary>
- public BindingList<string> SelectedAvailableToMove { get; set; }
-
- /// <summary>
- /// Gets or sets SelectedLangauges.
- /// </summary>
- public BindingList<string> SelectedLangaugesToMove { get; set; }
-
- /// <summary>
- /// Gets or sets AddAudioModeOptions.
- /// </summary>
- public BindingList<string> AddAudioModeOptions
- {
- get
- {
- return this.addAudioModeOptions;
- }
-
- set
- {
- this.addAudioModeOptions = value;
- this.NotifyOfPropertyChange("AddAudioModeOptions");
- }
- }
-
- /// <summary>
- /// Gets or sets a value indicating whether AddClosedCaptions.
- /// </summary>
- public bool AddClosedCaptions
- {
- get
- {
- return this.addClosedCaptions;
- }
-
- set
- {
- this.addClosedCaptions = value;
- this.NotifyOfPropertyChange("AddClosedCaptions");
- }
- }
-
- /// <summary>
- /// Gets or sets a value indicating whether AddOnlyOneAudioTrackPerLanguage.
- /// </summary>
- public bool AddOnlyOneAudioTrackPerLanguage
- {
- get
- {
- return this.addOnlyOneAudioTrackPerLanguage;
- }
-
- set
- {
- this.addOnlyOneAudioTrackPerLanguage = value;
- this.NotifyOfPropertyChange("AddOnlyOneAudioTrackPerLanguage");
- }
- }
-
- /// <summary>
- /// Gets or sets AddSubtitleModeOptions.
- /// </summary>
- public BindingList<string> AddSubtitleModeOptions
- {
- get
- {
- return this.addSubtitleModeOptions;
- }
-
- set
- {
- this.addSubtitleModeOptions = value;
- this.NotifyOfPropertyChange("AddSubtitleModeOptions");
- }
- }
-
- /// <summary>
- /// Gets or sets SelectedAddAudioMode.
- /// </summary>
- public int SelectedAddAudioMode
- {
- get
- {
- return this.selectedAddAudioMode;
- }
-
- set
- {
- this.selectedAddAudioMode = value;
- this.NotifyOfPropertyChange("SelectedAddAudioMode");
- }
- }
-
- /// <summary>
- /// Gets or sets SelectedAddSubtitleMode.
- /// </summary>
- public int SelectedAddSubtitleMode
- {
- get
- {
- return this.selectedAddSubtitleMode;
- }
-
- set
- {
- this.selectedAddSubtitleMode = value;
- this.NotifyOfPropertyChange("SelectedAddSubtitleMode");
- }
- }
-
- /// <summary>
- /// Gets or sets a value indicating whether ShowAdvancedPassthruOpts.
- /// </summary>
- public bool ShowAdvancedPassthruOpts
- {
- get
- {
- return this.showAdvancedPassthruOpts;
- }
- set
- {
- this.showAdvancedPassthruOpts = value;
- this.NotifyOfPropertyChange(() => this.ShowAdvancedPassthruOpts);
- }
- }
-
- /// <summary>
- /// Gets or sets a value indicating whether add foreign audio scan track.
- /// </summary>
- public bool AddForeignAudioScanTrack
- {
- get
- {
- return this.addForeignAudioScanTrack;
- }
- set
- {
- if (value.Equals(this.addForeignAudioScanTrack))
- {
- return;
- }
- this.addForeignAudioScanTrack = value;
- this.NotifyOfPropertyChange(() => this.AddForeignAudioScanTrack);
- }
- }
-
- #endregion
-
#region System and Logging
/// <summary>
@@ -1655,56 +1350,6 @@ namespace HandBrakeWPF.ViewModels
}
/// <summary>
- /// Audio List Move Left
- /// </summary>
- public void LanguageMoveRight()
- {
- if (this.SelectedAvailableToMove.Count > 0)
- {
- List<string> copiedList = SelectedAvailableToMove.ToList();
- foreach (string item in copiedList)
- {
- this.AvailableLanguages.Remove(item);
- this.SelectedLangauges.Add(item);
- }
-
- this.AvailableLanguages = new BindingList<string>(this.AvailableLanguages.OrderBy(o => o).ToList());
- }
- }
-
- /// <summary>
- /// Audio List Move Right
- /// </summary>
- public void LanguageMoveLeft()
- {
- if (this.SelectedLangaugesToMove.Count > 0)
- {
- List<string> copiedList = SelectedLangaugesToMove.ToList();
- foreach (string item in copiedList)
- {
- this.SelectedLangauges.Remove(item);
- this.AvailableLanguages.Add(item);
- }
- }
-
- this.AvailableLanguages = new BindingList<string>(this.AvailableLanguages.OrderBy(o => o).ToList());
- }
-
- /// <summary>
- /// Audio List Clear all selected languages
- /// </summary>
- public void LanguageClearAll()
- {
- foreach (string item in this.SelectedLangauges)
- {
- this.AvailableLanguages.Add(item);
- }
- this.AvailableLanguages = new BindingList<string>(this.AvailableLanguages.OrderBy(o => o).ToList());
-
- this.SelectedLangauges.Clear();
- }
-
- /// <summary>
/// Browse - Log Path
/// </summary>
public void BrowseLogPath()
@@ -1852,64 +1497,6 @@ namespace HandBrakeWPF.ViewModels
this.VLCPath = this.userSettingService.GetUserSetting<string>(UserSettingConstants.VLCPath) ?? string.Empty;
// #############################
- // Audio and Subtitles Tab
- // #############################
-
- this.SelectedAvailableToMove = new BindingList<string>();
- this.SelectedLangaugesToMove = new BindingList<string>();
-
- IDictionary<string, string> langList = LanguageUtilities.MapLanguages();
- langList = (from entry in langList orderby entry.Key ascending select entry).ToDictionary(pair => pair.Key, pair => pair.Value);
-
- this.selectedLangauges.Clear();
- foreach (string selectedItem in this.userSettingService.GetUserSetting<StringCollection>(UserSettingConstants.SelectedLanguages))
- {
- // removing wrong keys when a new Language list comes out.
- if (langList.ContainsKey(selectedItem))
- {
- this.selectedLangauges.Add(selectedItem);
- }
- }
-
- this.preferredLanguages.Clear();
- this.availableLanguages.Clear();
- foreach (string item in langList.Keys)
- {
- this.preferredLanguages.Add(item);
-
- // In the available languages should be no "Any" and no selected language.
- if ((item != Constants.Any) && (!this.userSettingService.GetUserSetting<StringCollection>(UserSettingConstants.SelectedLanguages).Contains(item)))
- {
- this.availableLanguages.Add(item);
- }
- }
-
- this.SelectedPreferredLangauge = this.userSettingService.GetUserSetting<string>(UserSettingConstants.NativeLanguage) ?? string.Empty;
- this.SelectedPreferredSubtitleLangauge = this.userSettingService.GetUserSetting<string>(UserSettingConstants.NativeLanguageForSubtitles) ?? string.Empty;
-
- this.AddAudioModeOptions.Clear();
- this.AddAudioModeOptions.Add("None");
- this.AddAudioModeOptions.Add("Add All Remaining Tracks");
- this.AddAudioModeOptions.Add("Add All for Selected Languages");
-
- this.AddSubtitleModeOptions.Clear();
- this.AddSubtitleModeOptions.Add("None");
- this.AddSubtitleModeOptions.Add("Add All (Where possible)");
- this.AddSubtitleModeOptions.Add("Add First");
- this.AddSubtitleModeOptions.Add("Add all for Selected Languages");
- this.AddSubtitleModeOptions.Add("Add only for Prefered Language (First)");
- this.AddSubtitleModeOptions.Add("Add all for Prefered Language");
-
- this.SelectedAddAudioMode = this.userSettingService.GetUserSetting<int>(UserSettingConstants.DubModeAudio);
- this.SelectedAddSubtitleMode = this.userSettingService.GetUserSetting<int>(UserSettingConstants.DubModeSubtitle);
-
- this.AddOnlyOneAudioTrackPerLanguage = this.userSettingService.GetUserSetting<bool>(UserSettingConstants.AddOnlyOneAudioPerLanguage);
-
- this.AddClosedCaptions = this.userSettingService.GetUserSetting<bool>(UserSettingConstants.UseClosedCaption);
- this.ShowAdvancedPassthruOpts = this.userSettingService.GetUserSetting<bool>(UserSettingConstants.ShowAdvancedAudioPassthruOpts);
- this.AddForeignAudioScanTrack = this.userSettingService.GetUserSetting<bool>(UserSettingConstants.AddForeignAudioScanTrack);
-
- // #############################
// Video
// #############################
this.DisableQuickSyncDecoding = this.userSettingService.GetUserSetting<bool>(UserSettingConstants.DisableQuickSyncDecoding);
@@ -2020,19 +1607,6 @@ namespace HandBrakeWPF.ViewModels
/* Previews */
this.userSettingService.SetUserSetting(UserSettingConstants.VLCPath, this.VLCPath);
-
- /* Audio and Subtitles */
- this.userSettingService.SetUserSetting(UserSettingConstants.NativeLanguage, this.SelectedPreferredLangauge);
- this.userSettingService.SetUserSetting(UserSettingConstants.NativeLanguageForSubtitles, this.SelectedPreferredSubtitleLangauge);
- StringCollection collection = new StringCollection();
- collection.AddRange(this.SelectedLangauges.ToArray());
- this.userSettingService.SetUserSetting(UserSettingConstants.SelectedLanguages, collection);
- this.userSettingService.SetUserSetting(UserSettingConstants.AddOnlyOneAudioPerLanguage, this.AddOnlyOneAudioTrackPerLanguage);
- this.userSettingService.SetUserSetting(UserSettingConstants.UseClosedCaption, this.AddClosedCaptions);
- this.userSettingService.SetUserSetting(UserSettingConstants.DubModeAudio, this.SelectedAddAudioMode);
- this.userSettingService.SetUserSetting(UserSettingConstants.DubModeSubtitle, this.SelectedAddSubtitleMode);
- this.userSettingService.SetUserSetting(UserSettingConstants.ShowAdvancedAudioPassthruOpts, this.ShowAdvancedPassthruOpts);
- this.userSettingService.SetUserSetting(UserSettingConstants.AddForeignAudioScanTrack, this.AddForeignAudioScanTrack);
/* Video */
this.userSettingService.SetUserSetting(UserSettingConstants.DisableQuickSyncDecoding, this.DisableQuickSyncDecoding);
diff --git a/win/CS/HandBrakeWPF/ViewModels/QueueSelectionViewModel.cs b/win/CS/HandBrakeWPF/ViewModels/QueueSelectionViewModel.cs
index 3cbe56feb..0da603e05 100644
--- a/win/CS/HandBrakeWPF/ViewModels/QueueSelectionViewModel.cs
+++ b/win/CS/HandBrakeWPF/ViewModels/QueueSelectionViewModel.cs
@@ -122,12 +122,12 @@ namespace HandBrakeWPF.ViewModels
get
{
// TODO decide what is the minimal requirement to hide the warning message.
- if (this.UserSettingService.GetUserSetting<string>(UserSettingConstants.NativeLanguage) != Constants.Any ||
- this.UserSettingService.GetUserSetting<string>(UserSettingConstants.NativeLanguageForSubtitles) !=
- Constants.Any)
- {
- return true;
- }
+ //if (this.UserSettingService.GetUserSetting<string>(UserSettingConstants.NativeLanguage) != Constants.Any ||
+ // this.UserSettingService.GetUserSetting<string>(UserSettingConstants.NativeLanguageForSubtitles) !=
+ // Constants.Any)
+ //{
+ // return true;
+ //}
return false;
}
diff --git a/win/CS/HandBrakeWPF/ViewModels/SubtitlesViewModel.cs b/win/CS/HandBrakeWPF/ViewModels/SubtitlesViewModel.cs
index 467535bc3..859763d3f 100644
--- a/win/CS/HandBrakeWPF/ViewModels/SubtitlesViewModel.cs
+++ b/win/CS/HandBrakeWPF/ViewModels/SubtitlesViewModel.cs
@@ -10,17 +10,16 @@
namespace HandBrakeWPF.ViewModels
{
using System.Collections.Generic;
- using System.Collections.Specialized;
+ using System.ComponentModel;
using System.IO;
using System.Linq;
using HandBrake.ApplicationServices.Model;
using HandBrake.ApplicationServices.Model.Encoding;
+ using HandBrake.ApplicationServices.Model.Subtitle;
using HandBrake.ApplicationServices.Parsing;
using HandBrake.ApplicationServices.Utilities;
- using HandBrakeWPF.Commands;
- using HandBrakeWPF.Model;
using HandBrakeWPF.ViewModels.Interfaces;
using Ookii.Dialogs.Wpf;
@@ -42,6 +41,21 @@ namespace HandBrakeWPF.ViewModels
/// </summary>
private IList<Subtitle> sourceTracks;
+ /// <summary>
+ /// The show defaults panel.
+ /// </summary>
+ private bool showDefaultsPanel;
+
+ /// <summary>
+ /// The audio behaviours.
+ /// </summary>
+ private SubtitleBehaviours subtitleBehaviours;
+
+ /// <summary>
+ /// The available languages.
+ /// </summary>
+ private BindingList<string> availableLanguages;
+
#endregion
#region Constructors and Destructors
@@ -58,6 +72,12 @@ namespace HandBrakeWPF.ViewModels
this.ForeignAudioSearchTrack = new Subtitle { SubtitleType = SubtitleType.ForeignAudioSearch, Language = "Foreign Audio Search (Bitmap)" };
this.SourceTracks = new List<Subtitle> { this.ForeignAudioSearchTrack };
+
+ this.SubtitleBehaviours = new SubtitleBehaviours();
+ this.SelectedAvailableToMove = new BindingList<string>();
+ this.SelectedLangaugesToMove = new BindingList<string>();
+ this.availableLanguages = new BindingList<string>();
+ this.SetupLanguages(null);
}
#endregion
@@ -96,6 +116,109 @@ namespace HandBrakeWPF.ViewModels
/// </summary>
public EncodeTask Task { get; set; }
+ /// <summary>
+ /// Gets or sets a value indicating whether show defaults panel.
+ /// </summary>
+ public bool ShowDefaultsPanel
+ {
+ get
+ {
+ return this.showDefaultsPanel;
+ }
+ set
+ {
+ if (value.Equals(this.showDefaultsPanel))
+ {
+ return;
+ }
+ this.showDefaultsPanel = value;
+ this.NotifyOfPropertyChange(() => this.ShowDefaultsPanel);
+ this.NotifyOfPropertyChange(() => this.PanelTitle);
+ this.NotifyOfPropertyChange(() => this.SwitchDisplayTitle);
+ }
+ }
+
+ /// <summary>
+ /// Gets the panel title.
+ /// </summary>
+ public string PanelTitle
+ {
+ get
+ {
+ return this.ShowDefaultsPanel ? "Subtitle Defaults" : "Subtitle Tracks";
+ }
+ }
+
+ /// <summary>
+ /// Gets the switch display title.
+ /// </summary>
+ public string SwitchDisplayTitle
+ {
+ get
+ {
+ return this.ShowDefaultsPanel ? "Switch to Tracks" : "Switch to Defaults";
+ }
+ }
+
+
+ /// <summary>
+ /// Gets or sets the subtitle behaviours.
+ /// </summary>
+ public SubtitleBehaviours SubtitleBehaviours
+ {
+ get
+ {
+ return this.subtitleBehaviours;
+ }
+ set
+ {
+ if (Equals(value, this.subtitleBehaviours))
+ {
+ return;
+ }
+ this.subtitleBehaviours = value;
+ this.NotifyOfPropertyChange(() => this.SubtitleBehaviours);
+ }
+ }
+
+ /// <summary>
+ /// Gets the sbutitle behaviour modes.
+ /// </summary>
+ public BindingList<SubtitleBehaviourModes> SubtitleBehaviourModeList
+ {
+ get
+ {
+ return new BindingList<SubtitleBehaviourModes>(EnumHelper<SubtitleBehaviourModes>.GetEnumList().ToList());
+ }
+ }
+
+ /// <summary>
+ /// Gets or sets AvailableLanguages.
+ /// </summary>
+ public BindingList<string> AvailableLanguages
+ {
+ get
+ {
+ return this.availableLanguages;
+ }
+
+ set
+ {
+ this.availableLanguages = value;
+ this.NotifyOfPropertyChange("AvailableLanguages");
+ }
+ }
+
+ /// <summary>
+ /// Gets or sets SelectedLangauges.
+ /// </summary>
+ public BindingList<string> SelectedAvailableToMove { get; set; }
+
+ /// <summary>
+ /// Gets or sets SelectedLangauges.
+ /// </summary>
+ public BindingList<string> SelectedLangaugesToMove { get; set; }
+
#endregion
#region Public Methods
@@ -135,12 +258,12 @@ namespace HandBrakeWPF.ViewModels
/// </summary>
public void AddAllRemainingForSelectedLanguages()
{
- // Get a list of subtitle tracks that match the users lanaguages
- StringCollection userSelectedLanguages = this.UserSettingService.GetUserSetting<StringCollection>(UserSettingConstants.SelectedLanguages);
- userSelectedLanguages.Add(this.UserSettingService.GetUserSetting<string>(UserSettingConstants.NativeLanguageForSubtitles));
-
// Translate to Iso Codes
- List<string> iso6392Codes = LanguageUtilities.GetLanguageCodes(userSelectedLanguages);
+ List<string> iso6392Codes = this.SubtitleBehaviours.SelectedLangauges.Contains(Constants.Any)
+ ? LanguageUtilities.GetIsoCodes()
+ : LanguageUtilities.GetLanguageCodes(
+ this.SubtitleBehaviours.SelectedLangauges.ToArray());
+
List<Subtitle> availableTracks =
this.SourceTracks.Where(subtitle => iso6392Codes.Contains(subtitle.LanguageCodeClean)).ToList();
@@ -152,6 +275,41 @@ namespace HandBrakeWPF.ViewModels
}
/// <summary>
+ /// The add first for selected languages.
+ /// </summary>
+ private void AddFirstForSelectedLanguages()
+ {
+ foreach (Subtitle sourceTrack in this.GetSelectedLanguagesTracks())
+ {
+ // Step 2: Check if the track list already contrains this track
+ bool found = this.Task.SubtitleTracks.Any(track => Equals(track.SourceTrack, sourceTrack));
+ if (!found)
+ {
+ // Check if we are already using this language
+ bool foundLanguage = false;
+ Subtitle track = sourceTrack;
+
+
+ foreach (var item in this.Task.SubtitleTracks)
+ {
+ if (item.SourceTrack != null && item.SourceTrack.LanguageCode != null && track.LanguageCode.Contains(item.SourceTrack.LanguageCode))
+ {
+ foundLanguage = true;
+ }
+ }
+
+ if (foundLanguage)
+ {
+ continue;
+ }
+
+ // If it doesn't, add it.
+ this.Add(sourceTrack);
+ }
+ }
+ }
+
+ /// <summary>
/// Import an SRT File.
/// </summary>
public void Import()
@@ -246,34 +404,24 @@ namespace HandBrakeWPF.ViewModels
this.Task.SubtitleTracks.Clear();
// Add Foreign Audio Scan
- if (this.UserSettingService.GetUserSetting<bool>(UserSettingConstants.AddForeignAudioScanTrack))
+ if (this.SubtitleBehaviours.AddForeignAudioScanTrack)
{
this.Add(ForeignAudioSearchTrack);
}
- // New DUB Settings
- int mode = this.UserSettingService.GetUserSetting<int>(UserSettingConstants.DubModeSubtitle);
- switch (mode)
+ // Add Track Behaviours
+ switch (this.SubtitleBehaviours.SelectedBehaviour)
{
- case 1: // Adding all remaining subtitle tracks
- this.AddAllRemaining();
- break;
- case 2: // Adding only the first or preferred first subtitle track.
- this.Add();
+ case SubtitleBehaviourModes.FirstMatch: // Adding all remaining tracks
+ this.AddFirstForSelectedLanguages();
break;
- case 3: // Selected Languages Only
+ case SubtitleBehaviourModes.AllMatching: // Add Langauges tracks for the additional languages selected, in-order.
this.AddAllRemainingForSelectedLanguages();
break;
- case 4: // Prefered Only
- this.AddForPreferredLanaguages(true);
- break;
- case 5: // Prefered Only All
- this.AddForPreferredLanaguages(false);
- break;
}
// Add all closed captions if enabled.
- if (this.UserSettingService.GetUserSetting<bool>(UserSettingConstants.UseClosedCaption))
+ if (this.SubtitleBehaviours.AddClosedCaptions)
{
this.AddAllClosedCaptions();
}
@@ -284,8 +432,65 @@ namespace HandBrakeWPF.ViewModels
/// </summary>
public void SetDefaultBehaviour()
{
- OpenOptionsScreenCommand command = new OpenOptionsScreenCommand();
- command.Execute(OptionsTab.AudioAndSubtitles);
+ this.ShowDefaultsPanel = true;
+ }
+
+ /// <summary>
+ /// The show audio defaults.
+ /// </summary>
+ public void ShowSubtitleDefaultsPanel()
+ {
+ this.ShowDefaultsPanel = !this.ShowDefaultsPanel;
+ }
+
+ /// <summary>
+ /// Audio List Move Left
+ /// </summary>
+ public void LanguageMoveRight()
+ {
+ if (this.SelectedAvailableToMove.Count > 0)
+ {
+ List<string> copiedList = SelectedAvailableToMove.ToList();
+ foreach (string item in copiedList)
+ {
+ this.AvailableLanguages.Remove(item);
+ this.SubtitleBehaviours.SelectedLangauges.Add(item);
+ }
+
+ this.AvailableLanguages = new BindingList<string>(this.AvailableLanguages.OrderBy(o => o).ToList());
+ }
+ }
+
+ /// <summary>
+ /// Audio List Move Right
+ /// </summary>
+ public void LanguageMoveLeft()
+ {
+ if (this.SelectedLangaugesToMove.Count > 0)
+ {
+ List<string> copiedList = SelectedLangaugesToMove.ToList();
+ foreach (string item in copiedList)
+ {
+ this.SubtitleBehaviours.SelectedLangauges.Remove(item);
+ this.AvailableLanguages.Add(item);
+ }
+ }
+
+ this.AvailableLanguages = new BindingList<string>(this.AvailableLanguages.OrderBy(o => o).ToList());
+ }
+
+ /// <summary>
+ /// Language List Clear all selected languages
+ /// </summary>
+ public void LanguageClearAll()
+ {
+ foreach (string item in this.SubtitleBehaviours.SelectedLangauges)
+ {
+ this.AvailableLanguages.Add(item);
+ }
+ this.AvailableLanguages = new BindingList<string>(this.AvailableLanguages.OrderBy(o => o).ToList());
+
+ this.SubtitleBehaviours.SelectedLangauges.Clear();
}
#endregion
@@ -308,6 +513,9 @@ namespace HandBrakeWPF.ViewModels
// Note, We don't support Subtitles in presets yet.
this.Task = task;
this.NotifyOfPropertyChange(() => this.Task);
+
+ this.SetupLanguages(preset);
+ this.AutomaticSubtitleSelection();
}
/// <summary>
@@ -369,12 +577,9 @@ namespace HandBrakeWPF.ViewModels
/// </param>
private void Add(Subtitle subtitle)
{
- string preferred =
- this.UserSettingService.GetUserSetting<string>(UserSettingConstants.NativeLanguageForSubtitles);
-
Subtitle source = subtitle
?? ((this.SourceTracks != null)
- ? (this.SourceTracks.FirstOrDefault(l => l.Language == preferred)
+ ? (this.SourceTracks.FirstOrDefault(l => l.Language == this.GetPreferredSubtitleTrackLanguage())
?? this.SourceTracks.FirstOrDefault(
s => s.SubtitleType != SubtitleType.ForeignAudioSearch))
: null);
@@ -405,27 +610,37 @@ namespace HandBrakeWPF.ViewModels
}
/// <summary>
- /// Add all tracks for the preferred languages settings.
+ /// Gets a list of source tracks for the users selected languages.
/// </summary>
- /// <param name="firstOnly">
- /// The first only.
- /// </param>
- private void AddForPreferredLanaguages(bool firstOnly)
+ /// <returns>
+ /// A list of source subtitle tracks.
+ /// </returns>
+ private IEnumerable<Subtitle> GetSelectedLanguagesTracks()
{
- string preferred =
- this.UserSettingService.GetUserSetting<string>(UserSettingConstants.NativeLanguageForSubtitles);
+ List<Subtitle> trackList = new List<Subtitle>();
- foreach (Subtitle subtitle in this.SourceTitlesSubset(null))
+ List<string> isoCodes = this.SubtitleBehaviours.SelectedLangauges.Contains(Constants.Any)
+ ? LanguageUtilities.GetIsoCodes()
+ : LanguageUtilities.GetLanguageCodes(
+ this.SubtitleBehaviours.SelectedLangauges.ToArray());
+
+ foreach (string code in isoCodes)
{
- if (subtitle.Language == preferred)
- {
- this.Add(subtitle);
- if (firstOnly)
- {
- break;
- }
- }
+ trackList.AddRange(this.SourceTracks.Where(source => source.LanguageCode == code));
}
+
+ return trackList;
+ }
+
+ /// <summary>
+ /// The get preferred subtitle track, or the first if none available.
+ /// </summary>
+ /// <returns>
+ /// The users preferred language, or the first if none available.
+ /// </returns>
+ private string GetPreferredSubtitleTrackLanguage()
+ {
+ return this.SubtitleBehaviours.SelectedLangauges.FirstOrDefault(w => w != Constants.Any);
}
/// <summary>
@@ -444,6 +659,45 @@ namespace HandBrakeWPF.ViewModels
: this.SourceTracks.Where(subtitle => !this.Task.SubtitleTracks.Any(track => Equals(track.SourceTrack, subtitle))).ToList();
}
+ /// <summary>
+ /// The setup languages.
+ /// </summary>
+ /// <param name="preset">
+ /// The preset.
+ /// </param>
+ private void SetupLanguages(Preset preset)
+ {
+ // Step 1, Set the behaviour mode
+ this.SubtitleBehaviours.SelectedBehaviour = SubtitleBehaviourModes.None;
+ this.SubtitleBehaviours.AddClosedCaptions = false;
+ this.SubtitleBehaviours.AddForeignAudioScanTrack = false;
+ this.SubtitleBehaviours.SelectedLangauges.Clear();
+
+ // Step 2, Get all the languages
+ 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
+ if (preset != null && preset.SubtitleTrackBehaviours != null)
+ {
+ this.SubtitleBehaviours.SelectedBehaviour = preset.SubtitleTrackBehaviours.SelectedBehaviour;
+ this.SubtitleBehaviours.AddClosedCaptions = preset.SubtitleTrackBehaviours.AddClosedCaptions;
+ this.SubtitleBehaviours.AddForeignAudioScanTrack = preset.SubtitleTrackBehaviours.AddForeignAudioScanTrack;
+
+ foreach (string selectedItem in preset.SubtitleTrackBehaviours.SelectedLangauges)
+ {
+ this.AvailableLanguages.Remove(selectedItem);
+ this.SubtitleBehaviours.SelectedLangauges.Add(selectedItem);
+ }
+ }
+ }
#endregion
}
} \ No newline at end of file