From fc3324c8fa6c0aaa37c89d8d0bf098092d705932 Mon Sep 17 00:00:00 2001 From: sr55 Date: Sat, 9 Apr 2016 14:46:54 +0100 Subject: WinGui: Use Mixdowns from LibHBand sanitise the choices. The GUI no longer shows invalid mixdowns. --- .../Converters/Audio/AudioMixdownConverter.cs | 61 ++++++++++++++++++++++ 1 file changed, 61 insertions(+) create mode 100644 win/CS/HandBrakeWPF/Converters/Audio/AudioMixdownConverter.cs (limited to 'win/CS/HandBrakeWPF/Converters/Audio/AudioMixdownConverter.cs') diff --git a/win/CS/HandBrakeWPF/Converters/Audio/AudioMixdownConverter.cs b/win/CS/HandBrakeWPF/Converters/Audio/AudioMixdownConverter.cs new file mode 100644 index 000000000..e1a371743 --- /dev/null +++ b/win/CS/HandBrakeWPF/Converters/Audio/AudioMixdownConverter.cs @@ -0,0 +1,61 @@ +// -------------------------------------------------------------------------------------------------------------------- +// +// This file is part of the HandBrake source code - It may be used under the terms of the GNU General Public License. +// +// +// Defines the AudioMixdownConverter type. +// +// -------------------------------------------------------------------------------------------------------------------- + +namespace HandBrakeWPF.Converters.Audio +{ + using System.Globalization; + using System.Windows.Data; + using System; + + using HandBrake.ApplicationServices.Interop; + using HandBrake.ApplicationServices.Interop.Model.Encoding; + + /// + /// The audio mixdown converter. + /// Handles conversion between HBMixdown and it's shortname. + /// + public class AudioMixdownConverter : IValueConverter + { + /// + /// Converts a value. + /// + /// + /// A converted value. If the method returns null, the valid null value is used. + /// + /// The value produced by the binding source.The type of the binding target property.The converter parameter to use.The culture to use in the converter. + public object Convert(object value, Type targetType, object parameter, CultureInfo culture) + { + string mixdown = value as string; + if (!string.IsNullOrEmpty(mixdown)) + { + return HandBrakeEncoderHelpers.GetMixdown(mixdown); + } + + return HandBrakeEncoderHelpers.GetMixdown("dpl2"); // Default + } + + /// + /// Converts a value. + /// + /// + /// A converted value. If the method returns null, the valid null value is used. + /// + /// The value that is produced by the binding target.The type to convert to.The converter parameter to use.The culture to use in the converter. + public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) + { + HBMixdown mixdown = value as HBMixdown; + if (mixdown != null) + { + return mixdown.ShortName; + } + + return "none"; + } + } +} -- cgit v1.2.3