diff options
author | sr55 <[email protected]> | 2014-02-16 18:39:29 +0000 |
---|---|---|
committer | sr55 <[email protected]> | 2014-02-16 18:39:29 +0000 |
commit | d4327b0f304b99a7650b12622b48e6145794ab65 (patch) | |
tree | f0c0912f10a487d077ad36277f67f84889f176e2 /win | |
parent | 4c18d60bcd318aae2c39b3d898e96ce0470c7277 (diff) |
WinGui: Initial work to refactor the Audio and Subtitle behavioural based automatic track selections. This is not quite complete yet but close enough for gathering feedback.
- Simplified UI design that's now available on the "Subtitle" and "Audio" tabs rather than the Options screen.
The settings are no longer part of the app preferences. They are now per-preset. Build in presets default to None.
- Selected Languages can now be set independently for Audio and Video.
- Preferred Language is now part of the Selected Languages list.
- Warning: Import/Export of presets still to be implemented. Design may yet change.
git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@6036 b64f7644-9d1e-0410-96f1-a4d463321fa5
Diffstat (limited to 'win')
28 files changed, 1402 insertions, 759 deletions
diff --git a/win/CS/HandBrake.ApplicationServices/HandBrake.ApplicationServices.csproj b/win/CS/HandBrake.ApplicationServices/HandBrake.ApplicationServices.csproj index 6110c187d..6ba1e302d 100644 --- a/win/CS/HandBrake.ApplicationServices/HandBrake.ApplicationServices.csproj +++ b/win/CS/HandBrake.ApplicationServices/HandBrake.ApplicationServices.csproj @@ -97,7 +97,11 @@ <Compile Include="Isolation\BackgroundServiceConnector.cs" />
<Compile Include="Isolation\IsolatedEncodeService.cs" />
<Compile Include="LibHb\AudioVideoHelpers.cs" />
+ <Compile Include="Model\Audio\AudioBehaviourModes.cs" />
+ <Compile Include="Model\Audio\AudioBehaviours.cs" />
<Compile Include="Model\HBConfiguration.cs" />
+ <Compile Include="Model\Subtitle\SubtitleBehaviourModes.cs" />
+ <Compile Include="Model\Subtitle\SubtitleBehaviours.cs" />
<Compile Include="Model\VideoScaler.cs" />
<Compile Include="Services\Interfaces\IEncodeServiceWrapper.cs" />
<Compile Include="Services\Interfaces\IHbServiceCallback.cs" />
diff --git a/win/CS/HandBrake.ApplicationServices/Model/Audio/AudioBehaviourModes.cs b/win/CS/HandBrake.ApplicationServices/Model/Audio/AudioBehaviourModes.cs new file mode 100644 index 000000000..0172b8b1b --- /dev/null +++ b/win/CS/HandBrake.ApplicationServices/Model/Audio/AudioBehaviourModes.cs @@ -0,0 +1,28 @@ +// --------------------------------------------------------------------------------------------------------------------
+// <copyright file="AudioBehaviourModes.cs" company="HandBrake Project (http://handbrake.fr)">
+// This file is part of the HandBrake source code - It may be used under the terms of the GNU General Public License.
+// </copyright>
+// <summary>
+// The audio behaviours.
+// </summary>
+// --------------------------------------------------------------------------------------------------------------------
+
+namespace HandBrake.ApplicationServices.Model.Audio
+{
+ using System.ComponentModel.DataAnnotations;
+
+ /// <summary>
+ /// The audio behaviours.
+ /// </summary>
+ public enum AudioBehaviourModes
+ {
+ [Display(Name = "None")]
+ None = 0,
+
+ [Display(Name = "First Matching Selected Language")]
+ FirstMatch,
+
+ [Display(Name = "All Matching Selected Languages")]
+ AllMatching,
+ }
+}
diff --git a/win/CS/HandBrake.ApplicationServices/Model/Audio/AudioBehaviours.cs b/win/CS/HandBrake.ApplicationServices/Model/Audio/AudioBehaviours.cs new file mode 100644 index 000000000..119c8d26d --- /dev/null +++ b/win/CS/HandBrake.ApplicationServices/Model/Audio/AudioBehaviours.cs @@ -0,0 +1,103 @@ +// --------------------------------------------------------------------------------------------------------------------
+// <copyright file="AudioBehaviours.cs" company="HandBrake Project (http://handbrake.fr)">
+// This file is part of the HandBrake source code - It may be used under the terms of the GNU General Public License.
+// </copyright>
+// <summary>
+// Audio Behaviours
+// </summary>
+// --------------------------------------------------------------------------------------------------------------------
+
+namespace HandBrake.ApplicationServices.Model.Audio
+{
+ using System.ComponentModel;
+
+ using Caliburn.Micro;
+
+ /// <summary>
+ /// Audio Behaviours
+ /// </summary>
+ public class AudioBehaviours : PropertyChangedBase
+ {
+ /// <summary>
+ /// The selected behaviour.
+ /// </summary>
+ private AudioBehaviourModes selectedBehaviour;
+
+ /// <summary>
+ /// The selected langauges.
+ /// </summary>
+ private BindingList<string> selectedLangauges;
+
+ /// <summary>
+ /// Initializes a new instance of the <see cref="AudioBehaviours"/> class.
+ /// </summary>
+ public AudioBehaviours()
+ {
+ this.SelectedBehaviour = AudioBehaviourModes.None;
+ this.SelectedLangauges = new BindingList<string>();
+ }
+
+ /// <summary>
+ /// Gets or sets the selected behaviour.
+ /// </summary>
+ public AudioBehaviourModes SelectedBehaviour
+ {
+ get
+ {
+ return this.selectedBehaviour;
+ }
+
+ set
+ {
+ if (value == this.selectedBehaviour)
+ {
+ return;
+ }
+ this.selectedBehaviour = value;
+ this.NotifyOfPropertyChange(() => this.SelectedBehaviour);
+ }
+ }
+
+ /// <summary>
+ /// Gets or sets the selected langauges.
+ /// </summary>
+ public BindingList<string> SelectedLangauges
+ {
+ get
+ {
+ return this.selectedLangauges;
+ }
+ set
+ {
+ if (Equals(value, this.selectedLangauges))
+ {
+ return;
+ }
+ this.selectedLangauges = value;
+ this.NotifyOfPropertyChange(() => this.SelectedLangauges);
+ }
+ }
+
+ /// <summary>
+ /// Clone this object
+ /// </summary>
+ /// <returns>
+ /// The <see cref="object"/>.
+ /// </returns>
+ public AudioBehaviours Clone()
+ {
+ AudioBehaviours cloned = new AudioBehaviours
+ {
+ SelectedBehaviour = this.selectedBehaviour,
+ SelectedLangauges = new BindingList<string>()
+ };
+
+ foreach (var item in this.SelectedLangauges)
+ {
+ cloned.SelectedLangauges.Add(item);
+ }
+
+ return cloned;
+ }
+ }
+}
diff --git a/win/CS/HandBrake.ApplicationServices/Model/Preset.cs b/win/CS/HandBrake.ApplicationServices/Model/Preset.cs index 7003ca2c7..57faf2968 100644 --- a/win/CS/HandBrake.ApplicationServices/Model/Preset.cs +++ b/win/CS/HandBrake.ApplicationServices/Model/Preset.cs @@ -11,6 +11,9 @@ namespace HandBrake.ApplicationServices.Model {
using Caliburn.Micro;
+ using HandBrake.ApplicationServices.Model.Audio;
+ using HandBrake.ApplicationServices.Model.Subtitle;
+
/// <summary>
/// A Preset for encoding with.
/// </summary>
@@ -25,6 +28,7 @@ namespace HandBrake.ApplicationServices.Model #endregion
+
#region Properties
/// <summary>
@@ -89,6 +93,16 @@ namespace HandBrake.ApplicationServices.Model /// </summary>
public string Version { get; set; }
+ /// <summary>
+ /// Gets or sets the audio track behaviours.
+ /// </summary>
+ public AudioBehaviours AudioTrackBehaviours { get; set; }
+
+ /// <summary>
+ /// Gets or sets the subtitle track behaviours.
+ /// </summary>
+ public SubtitleBehaviours SubtitleTrackBehaviours { get; set; }
+
#endregion
#region Public Methods
diff --git a/win/CS/HandBrake.ApplicationServices/Model/Subtitle/SubtitleBehaviourModes.cs b/win/CS/HandBrake.ApplicationServices/Model/Subtitle/SubtitleBehaviourModes.cs new file mode 100644 index 000000000..4094c402e --- /dev/null +++ b/win/CS/HandBrake.ApplicationServices/Model/Subtitle/SubtitleBehaviourModes.cs @@ -0,0 +1,28 @@ +// --------------------------------------------------------------------------------------------------------------------
+// <copyright file="SubtitleBehaviourModes.cs" company="HandBrake Project (http://handbrake.fr)">
+// This file is part of the HandBrake source code - It may be used under the terms of the GNU General Public License.
+// </copyright>
+// <summary>
+// The subtitle behaviours modes.
+// </summary>
+// --------------------------------------------------------------------------------------------------------------------
+
+namespace HandBrake.ApplicationServices.Model.Subtitle
+{
+ using System.ComponentModel.DataAnnotations;
+
+ /// <summary>
+ /// The subtitle behaviours modes.
+ /// </summary>
+ public enum SubtitleBehaviourModes
+ {
+ [Display(Name = "None")]
+ None = 0,
+
+ [Display(Name = "First Matching Selected Language")]
+ FirstMatch,
+
+ [Display(Name = "All Matching Selected Languages")]
+ AllMatching,
+ }
+}
diff --git a/win/CS/HandBrake.ApplicationServices/Model/Subtitle/SubtitleBehaviours.cs b/win/CS/HandBrake.ApplicationServices/Model/Subtitle/SubtitleBehaviours.cs new file mode 100644 index 000000000..28f5176d1 --- /dev/null +++ b/win/CS/HandBrake.ApplicationServices/Model/Subtitle/SubtitleBehaviours.cs @@ -0,0 +1,154 @@ +// --------------------------------------------------------------------------------------------------------------------
+// <copyright file="SubtitleBehaviours.cs" company="HandBrake Project (http://handbrake.fr)">
+// This file is part of the HandBrake source code - It may be used under the terms of the GNU General Public License.
+// </copyright>
+// <summary>
+// A class to track the behaviours of audio track selection
+// </summary>
+// --------------------------------------------------------------------------------------------------------------------
+
+namespace HandBrake.ApplicationServices.Model.Subtitle
+{
+ using System.ComponentModel;
+
+ using Caliburn.Micro;
+
+ /// <summary>
+ /// A class to track the behaviours of audio track selection
+ /// </summary>
+ public class SubtitleBehaviours : PropertyChangedBase
+ {
+ /// <summary>
+ /// The selected behaviour.
+ /// </summary>
+ private SubtitleBehaviourModes selectedBehaviour;
+
+ /// <summary>
+ /// The selected langauges.
+ /// </summary>
+ private BindingList<string> selectedLangauges;
+
+ /// <summary>
+ /// The add foreign audio scan track.
+ /// </summary>
+ private bool addForeignAudioScanTrack;
+
+ /// <summary>
+ /// The add closed captions.
+ /// </summary>
+ private bool addClosedCaptions;
+
+ /// <summary>
+ /// Initializes a new instance of the <see cref="SubtitleBehaviours"/> class.
+ /// </summary>
+ public SubtitleBehaviours()
+ {
+ this.SelectedBehaviour = SubtitleBehaviourModes.None;
+ this.SelectedLangauges = new BindingList<string>();
+ }
+
+ /// <summary>
+ /// Gets or sets the selected behaviour.
+ /// </summary>
+ public SubtitleBehaviourModes SelectedBehaviour
+ {
+ get
+ {
+ return this.selectedBehaviour;
+ }
+ set
+ {
+ if (value == this.selectedBehaviour)
+ {
+ return;
+ }
+ this.selectedBehaviour = value;
+ this.NotifyOfPropertyChange(() => this.SelectedBehaviour);
+ }
+ }
+
+ /// <summary>
+ /// Gets or sets the selected langages.
+ /// </summary>
+ public BindingList<string> SelectedLangauges
+ {
+ get
+ {
+ return this.selectedLangauges;
+ }
+ set
+ {
+ if (Equals(value, this.selectedLangauges))
+ {
+ return;
+ }
+ this.selectedLangauges = value;
+ this.NotifyOfPropertyChange(() => this.SelectedLangauges);
+ }
+ }
+
+ /// <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);
+ }
+ }
+
+ /// <summary>
+ /// Gets or sets a value indicating whether add closed captions.
+ /// </summary>
+ public bool AddClosedCaptions
+ {
+ get
+ {
+ return this.addClosedCaptions;
+ }
+ set
+ {
+ if (value.Equals(this.addClosedCaptions))
+ {
+ return;
+ }
+ this.addClosedCaptions = value;
+ this.NotifyOfPropertyChange(() => this.AddClosedCaptions);
+ }
+ }
+
+ /// <summary>
+ /// Clone this object
+ /// </summary>
+ /// <returns>
+ /// The <see cref="object"/>.
+ /// </returns>
+ public SubtitleBehaviours Clone()
+ {
+ SubtitleBehaviours cloned = new SubtitleBehaviours
+ {
+ SelectedBehaviour = this.selectedBehaviour,
+ SelectedLangauges = new BindingList<string>(),
+ AddClosedCaptions = this.addClosedCaptions,
+ AddForeignAudioScanTrack = this.addForeignAudioScanTrack,
+ };
+
+ foreach (var item in this.SelectedLangauges)
+ {
+ cloned.SelectedLangauges.Add(item);
+ }
+
+ return cloned;
+ }
+ }
+}
diff --git a/win/CS/HandBrake.ApplicationServices/Utilities/Converters.cs b/win/CS/HandBrake.ApplicationServices/Utilities/Converters.cs index 1c6b785bb..9651c6e71 100644 --- a/win/CS/HandBrake.ApplicationServices/Utilities/Converters.cs +++ b/win/CS/HandBrake.ApplicationServices/Utilities/Converters.cs @@ -129,7 +129,7 @@ namespace HandBrake.ApplicationServices.Utilities {
case Mixdown.Auto:
case Mixdown.None:
- return "auto";
+ return "none";
case Mixdown.Mono:
return "mono";
case Mixdown.LeftOnly:
diff --git a/win/CS/HandBrake.ApplicationServices/Utilities/LanguageUtilities.cs b/win/CS/HandBrake.ApplicationServices/Utilities/LanguageUtilities.cs index bbfe8f62c..94a1fb201 100644 --- a/win/CS/HandBrake.ApplicationServices/Utilities/LanguageUtilities.cs +++ b/win/CS/HandBrake.ApplicationServices/Utilities/LanguageUtilities.cs @@ -11,6 +11,7 @@ namespace HandBrake.ApplicationServices.Utilities {
using System.Collections.Generic;
using System.Collections.Specialized;
+ using System.Linq;
/// <summary>
/// Language Utilities
@@ -248,6 +249,42 @@ namespace HandBrake.ApplicationServices.Utilities }
return iso6392Codes;
- }
+ }
+
+ /// <summary>
+ /// The get language codes.
+ /// </summary>
+ /// <param name="userLanguages">
+ /// The user languages.
+ /// </param>
+ /// <returns>
+ /// The <see cref="List"/>.
+ /// </returns>
+ public static List<string> GetLanguageCodes(IList<string> userLanguages)
+ {
+ // Translate to Iso Codes
+ List<string> iso6392Codes = new List<string>();
+ foreach (var item in userLanguages)
+ {
+ string isoCode;
+ if (LanguageUtilities.MapLanguages().TryGetValue(item, out isoCode))
+ {
+ iso6392Codes.Add(isoCode);
+ }
+ }
+
+ return iso6392Codes;
+ }
+
+ /// <summary>
+ /// The get iso codes.
+ /// </summary>
+ /// <returns>
+ /// The <see cref="List"/>.
+ /// </returns>
+ public static List<string> GetIsoCodes()
+ {
+ return MapLanguages().Values.ToList();
+ }
}
}
diff --git a/win/CS/HandBrake.Interop/HandBrakeInterop/HandBrakeInstance.cs b/win/CS/HandBrake.Interop/HandBrakeInterop/HandBrakeInstance.cs index fb3cf1f51..72a75c112 100644 --- a/win/CS/HandBrake.Interop/HandBrakeInterop/HandBrakeInstance.cs +++ b/win/CS/HandBrake.Interop/HandBrakeInterop/HandBrakeInstance.cs @@ -267,8 +267,6 @@ namespace HandBrake.Interop HBFunctions.hb_scan_stop(this.hbHandle);
}
-
-
/// <summary>
/// Gets an image for the given job and preview
/// </summary>
diff --git a/win/CS/HandBrakeWPF/Converters/Audio/AudioBehaviourConverter.cs b/win/CS/HandBrakeWPF/Converters/Audio/AudioBehaviourConverter.cs new file mode 100644 index 000000000..a53c4e7e9 --- /dev/null +++ b/win/CS/HandBrakeWPF/Converters/Audio/AudioBehaviourConverter.cs @@ -0,0 +1,90 @@ +// --------------------------------------------------------------------------------------------------------------------
+// <copyright file="AudioBehaviourConverter.cs" company="HandBrake Project (http://handbrake.fr)">
+// This file is part of the HandBrake source code - It may be used under the terms of the GNU General Public License.
+// </copyright>
+// <summary>
+// Audio Behaviour Converter
+// </summary>
+// --------------------------------------------------------------------------------------------------------------------
+
+namespace HandBrakeWPF.Converters.Audio
+{
+ using System;
+ using System.ComponentModel;
+ using System.Globalization;
+ using System.Linq;
+ using System.Windows.Data;
+
+ using HandBrake.ApplicationServices.Model.Audio;
+ using HandBrake.ApplicationServices.Utilities;
+
+ /// <summary>
+ /// Audio Behaviour Converter
+ /// </summary>
+ public class AudioBehaviourConverter : IValueConverter
+ {
+ /// <summary>
+ /// The convert.
+ /// </summary>
+ /// <param name="value">
+ /// The value.
+ /// </param>
+ /// <param name="targetType">
+ /// The target type.
+ /// </param>
+ /// <param name="parameter">
+ /// The parameter.
+ /// </param>
+ /// <param name="culture">
+ /// The culture.
+ /// </param>
+ /// <returns>
+ /// The <see cref="object"/>.
+ /// </returns>
+ public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
+ {
+ if (value != null && value.GetType() == typeof(BindingList<AudioBehaviourModes>))
+ {
+ return
+ new BindingList<string>(
+ EnumHelper<AudioBehaviourModes>.GetEnumDisplayValues(typeof(AudioBehaviourModes)).ToList());
+ }
+
+ if (value != null && value.GetType() == typeof(AudioBehaviourModes))
+ {
+ return EnumHelper<AudioBehaviourModes>.GetDisplay((AudioBehaviourModes)value);
+ }
+
+ return null;
+ }
+
+ /// <summary>
+ /// The convert back.
+ /// </summary>
+ /// <param name="value">
+ /// The value.
+ /// </param>
+ /// <param name="targetType">
+ /// The target type.
+ /// </param>
+ /// <param name="parameter">
+ /// The parameter.
+ /// </param>
+ /// <param name="culture">
+ /// The culture.
+ /// </param>
+ /// <returns>
+ /// The <see cref="object"/>.
+ /// </returns>
+ public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
+ {
+ string name = value as string;
+ if (!string.IsNullOrEmpty(name))
+ {
+ return EnumHelper<AudioBehaviourModes>.GetValue(name);
+ }
+
+ return null;
+ }
+ }
+}
diff --git a/win/CS/HandBrakeWPF/Converters/EnumComboConverter.cs b/win/CS/HandBrakeWPF/Converters/EnumComboConverter.cs index dd26399db..9214745e8 100644 --- a/win/CS/HandBrakeWPF/Converters/EnumComboConverter.cs +++ b/win/CS/HandBrakeWPF/Converters/EnumComboConverter.cs @@ -19,8 +19,6 @@ namespace HandBrakeWPF.Converters using HandBrake.Interop.Model.Encoding;
using HandBrake.Interop.Model.Encoding.x264;
- using HandBrakeWPF.Model;
-
/// <summary>
/// Enum Combo Converter
/// </summary>
diff --git a/win/CS/HandBrakeWPF/Converters/Options/OptionsTabConverter.cs b/win/CS/HandBrakeWPF/Converters/Options/OptionsTabConverter.cs index bd1e4c8d0..54897e19c 100644 --- a/win/CS/HandBrakeWPF/Converters/Options/OptionsTabConverter.cs +++ b/win/CS/HandBrakeWPF/Converters/Options/OptionsTabConverter.cs @@ -40,9 +40,7 @@ namespace HandBrakeWPF.Converters.Options case OptionsTab.OutputFiles:
if ((OptionsTab)parameter == OptionsTab.OutputFiles) return Visibility.Visible;
break;
- case OptionsTab.AudioAndSubtitles:
- if ((OptionsTab)parameter == OptionsTab.AudioAndSubtitles) return Visibility.Visible;
- break;
+
case OptionsTab.Advanced:
if ((OptionsTab)parameter == OptionsTab.Advanced) return Visibility.Visible;
break;
diff --git a/win/CS/HandBrakeWPF/Converters/Subtitles/SubtitleBehaviourConverter.cs b/win/CS/HandBrakeWPF/Converters/Subtitles/SubtitleBehaviourConverter.cs new file mode 100644 index 000000000..251565d80 --- /dev/null +++ b/win/CS/HandBrakeWPF/Converters/Subtitles/SubtitleBehaviourConverter.cs @@ -0,0 +1,90 @@ +// --------------------------------------------------------------------------------------------------------------------
+// <copyright file="SubtitleBehaviourConverter.cs" company="HandBrake Project (http://handbrake.fr)">
+// This file is part of the HandBrake source code - It may be used under the terms of the GNU General Public License.
+// </copyright>
+// <summary>
+// Subtitle Behaviour Converter
+// </summary>
+// --------------------------------------------------------------------------------------------------------------------
+
+namespace HandBrakeWPF.Converters.Subtitles
+{
+ using System;
+ using System.ComponentModel;
+ using System.Globalization;
+ using System.Linq;
+ using System.Windows.Data;
+
+ using HandBrake.ApplicationServices.Model.Subtitle;
+ using HandBrake.ApplicationServices.Utilities;
+
+ /// <summary>
+ /// Subtitle Behaviour Converter
+ /// </summary>
+ public class SubtitleBehaviourConverter : IValueConverter
+ {
+ /// <summary>
+ /// The convert.
+ /// </summary>
+ /// <param name="value">
+ /// The value.
+ /// </param>
+ /// <param name="targetType">
+ /// The target type.
+ /// </param>
+ /// <param name="parameter">
+ /// The parameter.
+ /// </param>
+ /// <param name="culture">
+ /// The culture.
+ /// </param>
+ /// <returns>
+ /// The <see cref="object"/>.
+ /// </returns>
+ public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
+ {
+ if (value != null && value.GetType() == typeof(BindingList<SubtitleBehaviourModes>))
+ {
+ return
+ new BindingList<string>(
+ EnumHelper<SubtitleBehaviourModes>.GetEnumDisplayValues(typeof(SubtitleBehaviourModes)).ToList());
+ }
+
+ if (value != null && value.GetType() == typeof(SubtitleBehaviourModes))
+ {
+ return EnumHelper<SubtitleBehaviourModes>.GetDisplay((SubtitleBehaviourModes)value);
+ }
+
+ return null;
+ }
+
+ /// <summary>
+ /// The convert back.
+ /// </summary>
+ /// <param name="value">
+ /// The value.
+ /// </param>
+ /// <param name="targetType">
+ /// The target type.
+ /// </param>
+ /// <param name="parameter">
+ /// The parameter.
+ /// </param>
+ /// <param name="culture">
+ /// The culture.
+ /// </param>
+ /// <returns>
+ /// The <see cref="object"/>.
+ /// </returns>
+ public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
+ {
+ string name = value as string;
+ if (!string.IsNullOrEmpty(name))
+ {
+ return EnumHelper<SubtitleBehaviourModes>.GetValue(name);
+ }
+
+ return null;
+ }
+ }
+}
diff --git a/win/CS/HandBrakeWPF/HandBrakeWPF.csproj b/win/CS/HandBrakeWPF/HandBrakeWPF.csproj index b7c27048f..8e92b7115 100644 --- a/win/CS/HandBrakeWPF/HandBrakeWPF.csproj +++ b/win/CS/HandBrakeWPF/HandBrakeWPF.csproj @@ -130,6 +130,8 @@ <Compile Include="Commands\AdvancedEncoderOptionsCommand.cs" />
<Compile Include="Constants.cs" />
<Compile Include="Controls\SplitButton\SplitMenuButton.cs" />
+ <Compile Include="Converters\Audio\AudioBehaviourConverter.cs" />
+ <Compile Include="Converters\Subtitles\SubtitleBehaviourConverter.cs" />
<Compile Include="Converters\Video\ScalingConverter.cs" />
<Compile Include="Model\ScanMode.cs" />
<Compile Include="Factories\HBConfigurationFactory.cs" />
diff --git a/win/CS/HandBrakeWPF/Model/OptionsTab.cs b/win/CS/HandBrakeWPF/Model/OptionsTab.cs index e895b6159..b22807e46 100644 --- a/win/CS/HandBrakeWPF/Model/OptionsTab.cs +++ b/win/CS/HandBrakeWPF/Model/OptionsTab.cs @@ -22,9 +22,6 @@ namespace HandBrakeWPF.Model [Display(Name = "Output Files")]
OutputFiles,
- [Display(Name = "Audio and Subtitles")]
- AudioAndSubtitles,
-
[Display(Name = "Video")]
Video,
diff --git a/win/CS/HandBrakeWPF/UserSettingConstants.cs b/win/CS/HandBrakeWPF/UserSettingConstants.cs index 129f031b5..80bebe4b3 100644 --- a/win/CS/HandBrakeWPF/UserSettingConstants.cs +++ b/win/CS/HandBrakeWPF/UserSettingConstants.cs @@ -22,11 +22,6 @@ namespace HandBrakeWPF public const string HandBrakeBuild = "HandBrakeBuild";
/// <summary>
- /// Add Only One Per Langage
- /// </summary>
- public const string AddOnlyOneAudioPerLanguage = "addOnlyOneAudioPerLanguage";
-
- /// <summary>
/// Auto name format
/// </summary>
public const string AutoNameFormat = "autoNameFormat";
@@ -67,21 +62,6 @@ namespace HandBrakeWPF public const string DefaultPlayer = "defaultPlayer";
/// <summary>
- /// Dub mode
- /// </summary>
- public const string DubMode = "DubMode";
-
- /// <summary>
- /// Dub Mode Audio
- /// </summary>
- public const string DubModeAudio = "DubModeAudio";
-
- /// <summary>
- /// Dub Mode Subs
- /// </summary>
- public const string DubModeSubtitle = "DubModeSubtitle";
-
- /// <summary>
/// Last Update Check
/// </summary>
public const string LastUpdateCheckDate = "lastUpdateCheckDate";
@@ -97,31 +77,11 @@ namespace HandBrakeWPF public const string MinTitleLength = "MinTitleLength";
/// <summary>
- /// Native Language Audio
- /// </summary>
- public const string NativeLanguage = "NativeLanguage";
-
- /// <summary>
- /// Native Language Subs
- /// </summary>
- public const string NativeLanguageForSubtitles = "NativeLanguageSubtitles";
-
- /// <summary>
/// Preset Notification
/// </summary>
public const string PresetNotification = "presetNotification";
/// <summary>
- /// Selected Languages
- /// </summary>
- public const string SelectedLanguages = "SelectedLanguages";
-
- /// <summary>
- /// AUudio Passthru
- /// </summary>
- public const string ShowAdvancedAudioPassthruOpts = "ShowAdvancedAudioPassthruOpts";
-
- /// <summary>
/// Skip Version
/// </summary>
public const string Skipversion = "skipversion";
@@ -132,11 +92,6 @@ namespace HandBrakeWPF public const string UpdateStatus = "updateStatus";
/// <summary>
- /// Closed Captions
- /// </summary>
- public const string UseClosedCaption = "useClosedCaption";
-
- /// <summary>
/// Use m4v
/// </summary>
public const string UseM4v = "useM4v";
@@ -242,11 +197,6 @@ namespace HandBrakeWPF public const string ResetWhenDoneAction = "ResetWhenDoneAction";
/// <summary>
- /// The add foreign audio scan track.
- /// </summary>
- public const string AddForeignAudioScanTrack = "AddForeignAudioScanTrack";
-
- /// <summary>
/// The disable lib dvd nav.
/// </summary>
public const string DisableLibDvdNav = "DisableLibDvdNav";
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 diff --git a/win/CS/HandBrakeWPF/Views/AudioView.xaml b/win/CS/HandBrakeWPF/Views/AudioView.xaml index 0b9dd5a8d..a2d303cca 100644 --- a/win/CS/HandBrakeWPF/Views/AudioView.xaml +++ b/win/CS/HandBrakeWPF/Views/AudioView.xaml @@ -12,6 +12,7 @@ xmlns:dropButton="clr-namespace:HandBrakeWPF.Controls.DropButton"
xmlns:splitButton="clr-namespace:HandBrakeWPF.Controls.SplitButton"
xmlns:controls="clr-namespace:HandBrakeWPF.Controls"
+ xmlns:helpers="clr-namespace:HandBrakeWPF.Helpers"
d:DesignHeight="170"
d:DesignWidth="616"
mc:Ignorable="d"
@@ -23,8 +24,9 @@ <Conveters:BooleanToHiddenVisibilityConverter x:Key="boolToHiddenVisConverter" />
<Audio:AudioBitrateConverter x:Key="audioBitrateConverter" />
<Audio:AudioEncoderConverter x:Key="audioEncoderConverter" />
+ <Audio:AudioBehaviourConverter x:Key="audioBehaviourConverter" />
</UserControl.Resources>
-
+
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
@@ -32,18 +34,38 @@ <RowDefinition Height="*" />
</Grid.RowDefinitions>
+ <Grid.ColumnDefinitions>
+ <ColumnDefinition Width="*" />
+ <ColumnDefinition Width="Auto" />
+ </Grid.ColumnDefinitions>
+
+
+ <!-- Row 0 -->
<TextBlock Grid.Row="0"
Margin="10,5,0,0"
FontWeight="Bold"
- Text="Audio Tracks" />
+ VerticalAlignment="Top"
+ Text="{Binding PanelTitle}" />
- <Grid Grid.Row="1" Margin="10,5,10,0">
+ <Grid Grid.Row="0" Grid.Column="1" Margin="0,5,10,0">
+ <Border cal:Message.Attach="[Event MouseDown] = [Action ShowAudioDefaults]">
+ <StackPanel Orientation="Horizontal">
+ <Image Source="../Views/Images/Advanced.png" Width="20" />
+ <TextBlock Text="{Binding SwitchDisplayTitle}" VerticalAlignment="Center" Margin="5,0,0,0" />
+ </StackPanel>
+ </Border>
+ </Grid>
+
+ <!-- Row 1 -->
+
+ <Grid Grid.Row="1" Margin="10,5,10,0" Grid.Column="0"
+ Visibility="{Binding ShowAudioDefaultsPanel, Converter={StaticResource boolToVisConverter}, ConverterParameter=true}">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="*" />
<ColumnDefinition Width="Auto" />
</Grid.ColumnDefinitions>
-
+
<StackPanel Orientation="Horizontal" Grid.Row="0">
<splitButton:SplitMenuButton Content="Add Track" cal:Message.Attach="[Event Click] = [Action Add]" FontWeight="Bold" Margin="0,0,10,0">
<splitButton:SplitMenuButton.ItemSource>
@@ -52,7 +74,7 @@ <MenuItem Header="Add All Remaining Selected Languages" cal:Message.Attach="[Event Click] = [Action AddAllRemainingForSelectedLanguages]" />
</splitButton:SplitMenuButton.ItemSource>
</splitButton:SplitMenuButton>
-
+
<Button MinWidth="65"
Margin="0,0,10,0"
cal:Message.Attach="[Event Click] = [Action Clear]"
@@ -60,51 +82,12 @@ </StackPanel>
-
- <StackPanel Grid.Column="2"
- Orientation="Horizontal"
- Visibility="{Binding ShowPassthruOptions,
- Converter={StaticResource boolToVisConverter}}">
- <TextBlock Margin="5,0,5,0" Text="Auto Passthru:" VerticalAlignment="Center" />
- <CheckBox Margin="0,0,5,0"
- Content="MP3" VerticalAlignment="Center"
- IsChecked="{Binding Task.AllowedPassthruOptions.AudioAllowMP3Pass}" />
- <CheckBox Margin="0,0,5,0"
- Content="AAC" VerticalAlignment="Center"
- IsChecked="{Binding Task.AllowedPassthruOptions.AudioAllowAACPass}" />
- <CheckBox Margin="0,0,5,0"
- Content="AC3" VerticalAlignment="Center"
- IsChecked="{Binding Task.AllowedPassthruOptions.AudioAllowAC3Pass}" />
- <CheckBox Margin="0,0,5,0"
- Content="DTS" VerticalAlignment="Center"
- IsChecked="{Binding Task.AllowedPassthruOptions.AudioAllowDTSPass}" />
- <CheckBox Margin="0,0,5,0"
- Content="DTSHD" VerticalAlignment="Center"
- IsChecked="{Binding Task.AllowedPassthruOptions.AudioAllowDTSHDPass}" />
- <TextBlock Margin="5,0,5,0" Text="Fallback:" />
-
- <ComboBox VerticalAlignment="Center"
- Width="100"
- Height="22"
- Margin="10,0,5,0">
- <ComboBox.SelectedItem>
- <MultiBinding Converter="{StaticResource audioEncoderConverter}">
- <Binding Path="Task.AllowedPassthruOptions.AudioEncoderFallback" />
- </MultiBinding>
- </ComboBox.SelectedItem>
- <ComboBox.ItemsSource>
- <MultiBinding Converter="{StaticResource audioEncoderConverter}" ConverterParameter="True">
- <Binding Path="DataContext.AudioEncoders" RelativeSource="{RelativeSource FindAncestor, AncestorType={x:Type UserControl}}" />
- <Binding Path="DataContext.Task" RelativeSource="{RelativeSource FindAncestor, AncestorType={x:Type UserControl}}" />
- </MultiBinding>
- </ComboBox.ItemsSource>
- </ComboBox>
-
- </StackPanel>
-
</Grid>
- <ListBox Grid.Row="2"
+ <!-- Row 2 -->
+
+ <ListBox Grid.Row="2" Grid.Column="0" Grid.ColumnSpan="2"
+ Visibility="{Binding ShowAudioDefaultsPanel, Converter={StaticResource boolToVisConverter}, ConverterParameter=true}"
Margin="10,10,10,10"
dd:DragDrop.DropHandler="{Binding}"
dd:DragDrop.IsDragSource="True"
@@ -120,7 +103,7 @@ </Style.Triggers>
</Style>
</ListBox.Style>
-
+
<ListBox.ItemContainerStyle>
<Style TargetType="ListBoxItem">
<Setter Property="HorizontalContentAlignment" Value="Stretch" />
@@ -147,7 +130,7 @@ <ListBox.ItemTemplate>
<DataTemplate>
-
+
<Grid HorizontalAlignment="Stretch">
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
@@ -191,7 +174,7 @@ <ComboBox Grid.Column="1" Height="22" Width="100" Margin="5,0,5,0" HorizontalAlignment="Stretch"
ItemsSource="{Binding DataContext.SourceTracks, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type UserControl}}}"
SelectedItem="{Binding ScannedTrack}" />
-
+
<TextBlock Grid.Column="2" VerticalAlignment="Center" FontWeight="Bold" Text="Codec" />
<ComboBox Grid.Column="3" Width="100" Height="22" Margin="5,0,5,0">
<ComboBox.SelectedItem>
@@ -213,7 +196,7 @@ SelectedItem="{Binding Bitrate}"
Visibility="{Binding CannotSetBitrate, Converter={StaticResource boolToVisConverter}, ConverterParameter=true}" />
-
+
<!-- Row 2 -->
<TextBlock Grid.Row="0" Grid.Column="6" VerticalAlignment="Center" FontWeight="Bold" Text="Mixdown"
Visibility="{Binding IsPassthru, Converter={StaticResource boolToVisConverter}, ConverterParameter=true}" />
@@ -222,7 +205,7 @@ SelectedItem="{Binding MixDown, Converter={StaticResource enumComboConverter}}"
Visibility="{Binding IsPassthru, Converter={StaticResource boolToVisConverter}, ConverterParameter=true}" />
-
+
<ToggleButton Name="advancedOptionsToggle" VerticalAlignment="Center" Grid.Column="8" Grid.Row="0" Grid.ColumnSpan="2"
Padding="3,0" Height="22" HorizontalAlignment="Left" >
@@ -240,7 +223,7 @@ </Style>
</ToggleButton.Style>
</ToggleButton>
-
+
</Grid>
<!-- Delete -->
@@ -284,7 +267,7 @@ <TextBlock Text="Track Name:" VerticalAlignment="Center" FontWeight="Bold" Margin="5,0,5,0" />
<TextBox Text="{Binding TrackName, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" Width="138" Height="22" />
- </StackPanel>
+ </StackPanel>
</Grid>
</Grid>
@@ -292,5 +275,114 @@ </ListBox.ItemTemplate>
</ListBox>
+ <StackPanel Grid.Row="2" Grid.Column="0" Grid.ColumnSpan="2" Margin="10,10,10,10"
+ Visibility="{Binding ShowAudioDefaultsPanel, Converter={StaticResource boolToVisConverter}, ConverterParameter=false}">
+
+ <Grid Margin="5,0,0,0" >
+ <Grid.RowDefinitions>
+ <RowDefinition Height="Auto" />
+ <RowDefinition Height="Auto" />
+ <RowDefinition Height="Auto" />
+ </Grid.RowDefinitions>
+
+ <Grid.ColumnDefinitions>
+ <ColumnDefinition Width="Auto" />
+ <ColumnDefinition Width="Auto" />
+ <ColumnDefinition Width="Auto" />
+ <ColumnDefinition Width="Auto" />
+ <ColumnDefinition Width="*" />
+ </Grid.ColumnDefinitions>
+
+ <!-- Audio -->
+ <TextBlock Text="Track Selection Behaviour:" Grid.Column="0" Grid.Row="0" Margin="0,0,5,0" HorizontalAlignment="Left" VerticalAlignment="Center" />
+ <ComboBox Name="autoAudioMode" Grid.Column="1" Grid.Row="0" HorizontalAlignment="Left"
+ ItemsSource="{Binding AudioBehaviourModeList, Converter={StaticResource audioBehaviourConverter}}"
+ SelectedItem="{Binding AudioBehaviours.SelectedBehaviour, Converter={StaticResource audioBehaviourConverter}}" Width="210" Margin="0,0,5,0" />
+ </Grid>
+
+ <TextBlock Text="Choose Languages:" Margin="5,15,0,5" />
+
+ <Grid Margin="20,5,0,0">
+ <Grid.ColumnDefinitions>
+ <ColumnDefinition Width="*" />
+ </Grid.ColumnDefinitions>
+
+ <StackPanel Orientation="Horizontal">
+ <Grid>
+ <Grid.ColumnDefinitions>
+ <ColumnDefinition Width="*" />
+ <ColumnDefinition Width="*" />
+ <ColumnDefinition Width="*" />
+ </Grid.ColumnDefinitions>
+
+ <StackPanel Orientation="Vertical" Grid.Column="0">
+ <TextBlock Text="Available Languages:" Margin="0,0,0,5"/>
+ <ListBox Name="availableLanguages" ItemsSource="{Binding AvailableLanguages}"
+ helpers:ListBoxHelper.SelectedItems="{Binding SelectedAvailableToMove}"
+ SelectionMode="Extended" Width="140" Height="120" />
+ </StackPanel>
+
+ <DockPanel Grid.Column="1" Margin="10,0,10,0">
+ <StackPanel Orientation="Vertical" VerticalAlignment="Center">
+ <Button Content="Move Right" VerticalAlignment="Center" Margin="0,0,0,5" cal:Message.Attach="[Event Click] = [Action LanguageMoveRight]" MaxWidth="90" />
+ <Button Content="Move Left" VerticalAlignment="Center" Margin="0,0,0,5" cal:Message.Attach="[Event Click] = [Action LanguageMoveLeft]" MaxWidth="90" />
+ <Button Content="Clear" VerticalAlignment="Center" Margin="0,0,0,5" cal:Message.Attach="[Event Click] = [Action LanguageClearAll]" Width="80"/>
+ </StackPanel>
+ </DockPanel>
+
+ <StackPanel Orientation="Vertical" Grid.Column="2">
+ <TextBlock Text="Chosen Languages:" Margin="0,0,0,5"/>
+ <ListBox Name="selectedLangauges" ItemsSource="{Binding AudioBehaviours.SelectedLangauges}"
+ helpers:ListBoxHelper.SelectedItems="{Binding SelectedLangaugesToMove}"
+ SelectionMode="Extended" Width="140" Height="120"
+ dd:DragDrop.DropHandler="{Binding}"
+ dd:DragDrop.IsDragSource="True"
+ dd:DragDrop.IsDropTarget="True"/>
+ </StackPanel>
+ </Grid>
+ </StackPanel>
+ </Grid>
+
+ <TextBlock Text="Automatic Passthru Behaviours:" FontWeight="Bold" Margin="0,20,0,5" />
+ <StackPanel Margin="10,5,0,0"
+ Orientation="Horizontal">
+ <TextBlock Margin="5,0,5,0" Text="Allow passthrough of:" VerticalAlignment="Center" />
+ <CheckBox Margin="0,0,5,0"
+ Content="MP3" VerticalAlignment="Center"
+ IsChecked="{Binding Task.AllowedPassthruOptions.AudioAllowMP3Pass}" />
+ <CheckBox Margin="0,0,5,0"
+ Content="AAC" VerticalAlignment="Center"
+ IsChecked="{Binding Task.AllowedPassthruOptions.AudioAllowAACPass}" />
+ <CheckBox Margin="0,0,5,0"
+ Content="AC3" VerticalAlignment="Center"
+ IsChecked="{Binding Task.AllowedPassthruOptions.AudioAllowAC3Pass}" />
+ <CheckBox Margin="0,0,5,0"
+ Content="DTS" VerticalAlignment="Center"
+ IsChecked="{Binding Task.AllowedPassthruOptions.AudioAllowDTSPass}" />
+ <CheckBox Margin="0,0,5,0"
+ Content="DTSHD" VerticalAlignment="Center"
+ IsChecked="{Binding Task.AllowedPassthruOptions.AudioAllowDTSHDPass}" />
+
+ <TextBlock Margin="15,0,5,0" Text="Fallback Encoder:" />
+
+ <ComboBox VerticalAlignment="Center" Width="100" Height="22" Margin="10,0,5,0">
+ <ComboBox.SelectedItem>
+ <MultiBinding Converter="{StaticResource audioEncoderConverter}">
+ <Binding Path="Task.AllowedPassthruOptions.AudioEncoderFallback" />
+ </MultiBinding>
+ </ComboBox.SelectedItem>
+ <ComboBox.ItemsSource>
+ <MultiBinding Converter="{StaticResource audioEncoderConverter}" ConverterParameter="True">
+ <Binding Path="DataContext.AudioEncoders" RelativeSource="{RelativeSource FindAncestor, AncestorType={x:Type UserControl}}" />
+ <Binding Path="DataContext.Task" RelativeSource="{RelativeSource FindAncestor, AncestorType={x:Type UserControl}}" />
+ </MultiBinding>
+ </ComboBox.ItemsSource>
+ </ComboBox>
+
+ </StackPanel>
+
+ </StackPanel>
+
+
</Grid>
</UserControl>
diff --git a/win/CS/HandBrakeWPF/Views/OptionsView.xaml b/win/CS/HandBrakeWPF/Views/OptionsView.xaml index ad1a20ca4..4f28678c9 100644 --- a/win/CS/HandBrakeWPF/Views/OptionsView.xaml +++ b/win/CS/HandBrakeWPF/Views/OptionsView.xaml @@ -202,111 +202,6 @@ </StackPanel>
</StackPanel>
- <StackPanel Name="Audio" Orientation="Vertical" Margin="10,10,0,0"
- Visibility="{Binding SelectedTab, Converter={StaticResource tabConverter}, ConverterParameter={x:Static local:OptionsTab.AudioAndSubtitles}}">
-
-
- <Border BorderThickness="0 0 0 1" BorderBrush="LightGray">
- <TextBlock Text="Audio and Subtitle Language Handling" FontSize="16" />
- </Border>
- <TextBlock Text="Control the default selection behaviour for audio and subtitle tracks" Margin="0,10,0,10" />
-
- <TextBlock Text="Select your preferred languages" Grid.Column="0" Margin="10,10,0,0" FontSize="14"/>
-
- <Grid Margin="20,10,0,0" >
- <StackPanel Orientation="Horizontal">
- <TextBlock VerticalAlignment="Center" Text="Audio: " />
- <ComboBox Name="primaryAudioLanguage" VerticalAlignment="Center" ItemsSource="{Binding PreferredLanguages}"
- SelectedItem="{Binding SelectedPreferredLangauge}" Width="120" />
- <TextBlock VerticalAlignment="Center" Text="Subtitles: " Margin="10,0,0,0" />
- <ComboBox Name="primarySubtitleLanguage" VerticalAlignment="Center" ItemsSource="{Binding PreferredLanguages}"
- SelectedItem="{Binding SelectedPreferredSubtitleLangauge}" Width="120" />
- </StackPanel>
- </Grid>
-
- <TextBlock Text="Automatic language selection behaviour" Margin="10,20,0,0" FontSize="14"/>
-
- <Grid Margin="20,10,0,0" >
- <Grid.RowDefinitions>
- <RowDefinition Height="Auto" />
- <RowDefinition Height="Auto" />
- <RowDefinition Height="Auto" />
- </Grid.RowDefinitions>
-
- <Grid.ColumnDefinitions>
- <ColumnDefinition Width="Auto" />
- <ColumnDefinition Width="Auto" />
- <ColumnDefinition Width="Auto" />
- <ColumnDefinition Width="Auto" />
- <ColumnDefinition Width="*" />
- </Grid.ColumnDefinitions>
-
- <!-- Audio -->
- <TextBlock Text="Audio:" Grid.Column="0" Grid.Row="0" Margin="0,0,5,0" HorizontalAlignment="Left" VerticalAlignment="Center" />
- <ComboBox Name="autoAudioMode" Grid.Column="1" Grid.Row="0" HorizontalAlignment="Left"
- ItemsSource="{Binding AddAudioModeOptions}" SelectedIndex="{Binding SelectedAddAudioMode}" Width="120" Margin="0,0,5,0" />
- <CheckBox Content="Add only one audio track per language" Grid.Column="1" Grid.Row="1" HorizontalAlignment="Left"
- IsChecked="{Binding AddOnlyOneAudioTrackPerLanguage}" Margin="0,5,0,0" />
-
- <!-- Subtitles -->
- <TextBlock Text="Subtitle:" Grid.Column="2" Grid.Row="0" Margin="0,0,5,0" HorizontalAlignment="Left" VerticalAlignment="Center" />
- <ComboBox Name="autoSubtitleMode" Grid.Column="3" Grid.Row="0" HorizontalAlignment="Left"
- ItemsSource="{Binding AddSubtitleModeOptions}" SelectedIndex="{Binding SelectedAddSubtitleMode}" Width="120" Margin="0,0,5,0" />
- <CheckBox Content="Add Closed Captions when available" Grid.Column="3" Grid.Row="1" Margin="0,5,0,0"
- HorizontalAlignment="Left" IsChecked="{Binding AddClosedCaptions}"/>
- <CheckBox Content="Add 'Foreign Audio Scan'" Grid.Column="3" Grid.Row="2" Margin="0,5,0,0"
- HorizontalAlignment="Left" IsChecked="{Binding AddForeignAudioScanTrack}"/>
- </Grid>
-
- <TextBlock Text="Additional languages for possible selection" Margin="10,20,0,0" FontSize="14"/>
-
- <Grid Margin="20,20,0,0">
- <Grid.ColumnDefinitions>
- <ColumnDefinition Width="*" />
- </Grid.ColumnDefinitions>
-
- <StackPanel Orientation="Horizontal">
- <Grid>
- <Grid.ColumnDefinitions>
- <ColumnDefinition Width="*" />
- <ColumnDefinition Width="*" />
- <ColumnDefinition Width="*" />
- </Grid.ColumnDefinitions>
-
- <StackPanel Orientation="Vertical" Grid.Column="0">
- <TextBlock Text="Available Languages" Margin="0,0,0,5"/>
- <ListBox Name="availableLanguages" ItemsSource="{Binding AvailableLanguages}" Helpers:ListBoxHelper.SelectedItems="{Binding SelectedAvailableToMove}"
- SelectionMode="Extended" Width="140" Height="140"></ListBox>
- </StackPanel>
-
- <DockPanel Grid.Column="1" Margin="10,0,10,0">
- <StackPanel Orientation="Vertical" VerticalAlignment="Center">
- <Button Content="Move Right" VerticalAlignment="Center" Margin="0,0,0,5" cal:Message.Attach="[Event Click] = [Action LanguageMoveRight]" MaxWidth="90" />
- <Button Content="Move Left" VerticalAlignment="Center" Margin="0,0,0,5" cal:Message.Attach="[Event Click] = [Action LanguageMoveLeft]" MaxWidth="90" />
- <Button Content="Clear" VerticalAlignment="Center" Margin="0,0,0,5" cal:Message.Attach="[Event Click] = [Action LanguageClearAll]" Width="80"/>
- </StackPanel>
- </DockPanel>
-
- <StackPanel Orientation="Vertical" Grid.Column="2">
- <TextBlock Text="Chosen Selected Languages" Margin="0,0,0,5"/>
- <ListBox Name="selectedLangauges" ItemsSource="{Binding SelectedLangauges}" Helpers:ListBoxHelper.SelectedItems="{Binding SelectedLangaugesToMove}"
- SelectionMode="Extended" Width="140" Height="140"
- dd:DragDrop.DropHandler="{Binding}"
- dd:DragDrop.IsDragSource="True"
- dd:DragDrop.IsDropTarget="True"/>
- </StackPanel>
- </Grid>
- </StackPanel>
- </Grid>
-
- <StackPanel Orientation="Vertical" Margin="0,10,0,0">
- <Label Content="Audio Tab Options" FontSize="14"/>
- <CheckBox IsChecked="{Binding ShowAdvancedPassthruOpts}" Content="Show advanced audio passthru options. (Requires Restart)"
- Margin="20,0,0,0" />
- </StackPanel>
-
- </StackPanel>
-
<StackPanel Name="Hardware" Orientation="Vertical" Margin="10,10,0,0"
Visibility="{Binding SelectedTab, Converter={StaticResource tabConverter}, ConverterParameter={x:Static local:OptionsTab.Video}}">
diff --git a/win/CS/HandBrakeWPF/Views/SubtitlesView.xaml b/win/CS/HandBrakeWPF/Views/SubtitlesView.xaml index d8e2052ca..3e1db6857 100644 --- a/win/CS/HandBrakeWPF/Views/SubtitlesView.xaml +++ b/win/CS/HandBrakeWPF/Views/SubtitlesView.xaml @@ -10,12 +10,15 @@ xmlns:controls="clr-namespace:HandBrakeWPF.Controls"
xmlns:dropButton="clr-namespace:HandBrakeWPF.Controls.DropButton"
xmlns:splitButton="clr-namespace:HandBrakeWPF.Controls.SplitButton"
+ xmlns:helpers="clr-namespace:HandBrakeWPF.Helpers"
+ xmlns:subtitles="clr-namespace:HandBrakeWPF.Converters.Subtitles"
d:DesignHeight="153"
d:DesignWidth="319"
mc:Ignorable="d"
x:Name="subTab">
<UserControl.Resources>
<Converters:BooleanToVisibilityConverter x:Key="booleanToVisConverter" />
+ <subtitles:SubtitleBehaviourConverter x:Key="subtitleBehaviourConverter" />
</UserControl.Resources>
<Grid>
@@ -25,12 +28,30 @@ <RowDefinition Height="*" />
</Grid.RowDefinitions>
- <TextBlock Grid.Row="0"
+ <Grid.ColumnDefinitions>
+ <ColumnDefinition Width="*" />
+ <ColumnDefinition Width="Auto" />
+ </Grid.ColumnDefinitions>
+
+ <!-- Row 0 -->
+ <TextBlock Grid.Row="0" Grid.Column="0"
Margin="10,5,0,0"
FontWeight="Bold"
- Text="Subtitles" />
+ VerticalAlignment="Top"
+ Text="{Binding PanelTitle}" />
+
+ <Grid Grid.Row="0" Grid.Column="1" Margin="0,5,10,0">
+ <Border cal:Message.Attach="[Event MouseDown] = [Action ShowSubtitleDefaultsPanel]">
+ <StackPanel Orientation="Horizontal">
+ <Image Source="../Views/Images/Advanced.png" Width="20" />
+ <TextBlock Text="{Binding SwitchDisplayTitle}" VerticalAlignment="Center" Margin="5,0,0,0" />
+ </StackPanel>
+ </Border>
+ </Grid>
- <StackPanel Grid.Row="1" Margin="10,5,10,0" Orientation="Horizontal">
+ <!-- Row 1 -->
+ <StackPanel Grid.Row="1" Margin="10,5,10,0" Orientation="Horizontal"
+ Visibility="{Binding ShowDefaultsPanel, Converter={StaticResource booleanToVisConverter}, ConverterParameter=true}" >
<splitButton:SplitMenuButton Content="Add Track" cal:Message.Attach="[Event Click] = [Action Add]" FontWeight="Bold" Margin="0,0,10,0">
<splitButton:SplitMenuButton.ItemSource>
<MenuItem Header="Add New Track" cal:Message.Attach="[Event Click] = [Action Add]" />
@@ -50,7 +71,10 @@ Content="Clear" />
</StackPanel>
- <ListBox Grid.Row="2"
+
+ <!-- Row 2 -->
+ <ListBox Grid.Row="2" Grid.Column="0" Grid.ColumnSpan="2"
+ Visibility="{Binding ShowDefaultsPanel, Converter={StaticResource booleanToVisConverter}, ConverterParameter=true}"
Margin="10,10,10,10"
dd:DragDrop.DropHandler="{Binding}"
dd:DragDrop.IsDragSource="True"
@@ -237,6 +261,80 @@ </ListBox.ItemTemplate>
</ListBox>
+ <StackPanel Grid.Row="2" Grid.Column="0" Grid.ColumnSpan="2" Margin="10,10,10,10"
+ Visibility="{Binding ShowDefaultsPanel, Converter={StaticResource booleanToVisConverter}, ConverterParameter=false}">
+
+ <Grid Margin="5,0,0,0" >
+ <Grid.RowDefinitions>
+ <RowDefinition Height="Auto" />
+ <RowDefinition Height="Auto" />
+ <RowDefinition Height="Auto" />
+ </Grid.RowDefinitions>
+
+ <Grid.ColumnDefinitions>
+ <ColumnDefinition Width="Auto" />
+ <ColumnDefinition Width="Auto" />
+ <ColumnDefinition Width="Auto" />
+ <ColumnDefinition Width="Auto" />
+ <ColumnDefinition Width="*" />
+ </Grid.ColumnDefinitions>
+
+ <!-- Subtitles -->
+ <TextBlock Text="Track Selection Behaviour:" Grid.Column="2" Grid.Row="0" Margin="0,0,5,0" HorizontalAlignment="Left" VerticalAlignment="Center" />
+ <ComboBox Name="autoSubtitleMode" Grid.Column="3" Grid.Row="0" HorizontalAlignment="Left"
+ ItemsSource="{Binding SubtitleBehaviourModeList, Converter={StaticResource subtitleBehaviourConverter}}"
+ SelectedItem="{Binding SubtitleBehaviours.SelectedBehaviour, Converter={StaticResource subtitleBehaviourConverter}}" Width="210" Margin="0,0,5,0" />
+ <CheckBox Content="Add Closed Captions when available" Grid.Column="3" Grid.Row="1" Margin="0,5,0,0"
+ HorizontalAlignment="Left" IsChecked="{Binding SubtitleBehaviours.AddClosedCaptions}"/>
+ <CheckBox Content="Add 'Foreign Audio Scan'" Grid.Column="3" Grid.Row="2" Margin="0,5,0,0"
+ HorizontalAlignment="Left" IsChecked="{Binding SubtitleBehaviours.AddForeignAudioScanTrack}"/>
+ </Grid>
+
+ <TextBlock Text="Choose Languages:" Margin="5,15,0,0"/>
+
+ <Grid Margin="20,5,0,0">
+ <Grid.ColumnDefinitions>
+ <ColumnDefinition Width="*" />
+ </Grid.ColumnDefinitions>
+
+ <StackPanel Orientation="Horizontal">
+ <Grid>
+ <Grid.ColumnDefinitions>
+ <ColumnDefinition Width="*" />
+ <ColumnDefinition Width="*" />
+ <ColumnDefinition Width="*" />
+ </Grid.ColumnDefinitions>
+
+ <StackPanel Orientation="Vertical" Grid.Column="0">
+ <TextBlock Text="Available Languages:" Margin="0,0,0,5"/>
+ <ListBox Name="availableLanguages" ItemsSource="{Binding AvailableLanguages}"
+ helpers:ListBoxHelper.SelectedItems="{Binding SelectedAvailableToMove}"
+ SelectionMode="Extended" Width="140" Height="120" />
+ </StackPanel>
+
+ <DockPanel Grid.Column="1" Margin="10,0,10,0">
+ <StackPanel Orientation="Vertical" VerticalAlignment="Center">
+ <Button Content="Move Right" VerticalAlignment="Center" Margin="0,0,0,5" cal:Message.Attach="[Event Click] = [Action LanguageMoveRight]" MaxWidth="90" />
+ <Button Content="Move Left" VerticalAlignment="Center" Margin="0,0,0,5" cal:Message.Attach="[Event Click] = [Action LanguageMoveLeft]" MaxWidth="90" />
+ <Button Content="Clear" VerticalAlignment="Center" Margin="0,0,0,5" cal:Message.Attach="[Event Click] = [Action LanguageClearAll]" Width="80"/>
+ </StackPanel>
+ </DockPanel>
+
+ <StackPanel Orientation="Vertical" Grid.Column="2">
+ <TextBlock Text="Chosen Languages:" Margin="0,0,0,5"/>
+ <ListBox Name="selectedLangauges" ItemsSource="{Binding SubtitleBehaviours.SelectedLangauges}"
+ helpers:ListBoxHelper.SelectedItems="{Binding SelectedLangaugesToMove}"
+ SelectionMode="Extended" Width="140" Height="120"
+ dd:DragDrop.DropHandler="{Binding}"
+ dd:DragDrop.IsDragSource="True"
+ dd:DragDrop.IsDropTarget="True"/>
+ </StackPanel>
+ </Grid>
+ </StackPanel>
+ </Grid>
+
+ </StackPanel>
+
</Grid>
</UserControl>
|