// -------------------------------------------------------------------------------------------------------------------- // // 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"; } } }