// -------------------------------------------------------------------------------------------------------------------- // // This file is part of the HandBrake source code - It may be used under the terms of the GNU General Public License. // // // The audio rate type converter. // // -------------------------------------------------------------------------------------------------------------------- namespace HandBrakeWPF.Converters.Audio { using System; using System.Collections.Generic; using System.Globalization; using System.Windows.Data; using HandBrake.ApplicationServices.Utilities; using HandBrakeWPF.Utilities; using AudioEncoderRateType = HandBrakeWPF.Services.Encode.Model.Models.AudioEncoderRateType; /// /// The audio rate type converter. /// public class AudioRateTypeConverter : IValueConverter { /// /// The convert. /// /// /// The value. /// /// /// The target type. /// /// /// The parameter. /// /// /// The culture. /// /// /// The . /// public object Convert(object value, Type targetType, object parameter, CultureInfo culture) { var types = value as IEnumerable; if (types != null) { List rateTypes = new List(); foreach (var item in types) { rateTypes.Add(EnumHelper.GetDisplay(item)); } return rateTypes; } if (targetType == typeof(AudioEncoderRateType) || value.GetType() == typeof(AudioEncoderRateType)) { return EnumHelper.GetDisplay((AudioEncoderRateType)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) { if (value == null) { return null; } return EnumHelper.GetValue(value.ToString()); } } }