// -------------------------------------------------------------------------------------------------------------------- // // This file is part of the HandBrake source code - It may be used under the terms of the GNU General Public License. // // // Defines the ResourceConverterBase type. // // -------------------------------------------------------------------------------------------------------------------- namespace HandBrakeWPF.Converters { using System; using System.ComponentModel; using System.Globalization; using System.Linq; using HandBrakeWPF.Utilities; public class ResourceConverterBase { /// /// 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.GetEnumDisplayValuesSubset((BindingList)value).ToList()); } if (value != null && value.GetType() == typeof(T)) { return EnumHelper.GetDisplay((T)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; } } }