// -------------------------------------------------------------------------------------------------------------------- // // This file is part of the HandBrake source code - It may be used under the terms of the GNU General Public License. // // // Audio Behaviour Converter // // -------------------------------------------------------------------------------------------------------------------- namespace HandBrakeWPF.Converters.Audio { using System; using System.ComponentModel; using System.Globalization; using System.Linq; using System.Windows.Data; using HandBrake.Interop.Utilities; using HandBrakeWPF.Model.Audio; using HandBrakeWPF.Utilities; /// /// Audio Behaviour Converter /// public class AudioBehaviourConverter : IValueConverter { /// /// The convert. /// /// /// The value. /// /// /// The target type. /// /// /// The parameter. /// /// /// The culture. /// /// /// The . /// public object Convert(object value, Type targetType, object parameter, CultureInfo culture) { if (value != null && value.GetType() == typeof(BindingList)) { return new BindingList( EnumHelper.GetEnumDisplayValues(typeof(AudioBehaviourModes)).ToList()); } if (value != null && value.GetType() == typeof(AudioBehaviourModes)) { return EnumHelper.GetDisplay((AudioBehaviourModes)value); } return null; } /// /// The convert back. /// /// /// The value. /// /// /// The target type. /// /// /// The parameter. /// /// /// The culture. /// /// /// The . /// public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) { string name = value as string; if (!string.IsNullOrEmpty(name)) { return EnumHelper.GetValue(name); } return null; } } }