// -------------------------------------------------------------------------------------------------------------------- // // This file is part of the HandBrake source code - It may be used under the terms of the GNU General Public License. // // // Defines the EnumComboConverter type. // // -------------------------------------------------------------------------------------------------------------------- namespace HandBrakeWPF.Converters { using System; using System.Collections.Generic; using System.Globalization; using System.Windows.Data; using HandBrake.ApplicationServices.Interop.Model.Encoding; using HandBrake.ApplicationServices.Model; using HandBrakeWPF.Services.Queue.Model; using HandBrakeWPF.Utilities; using OutputFormat = HandBrakeWPF.Services.Encode.Model.Models.OutputFormat; using PresetPictureSettingsMode = HandBrakeWPF.Model.Picture.PresetPictureSettingsMode; /// /// Enum Combo Converter /// public sealed class EnumComboConverter : IValueConverter { /// /// Convert an Enum to it's display value (attribute) /// /// /// The value. /// /// /// The target type. /// /// /// The parameter. (A boolean which inverts the output) /// /// /// The culture. /// /// /// Visibility property /// public object Convert(object value, Type targetType, object parameter, CultureInfo culture) { if (value == null) { return null; } // Lists if (value is IEnumerable) { return EnumHelper.GetEnumDisplayValues(typeof(VideoEncoder)); } if (value is IEnumerable) { return EnumHelper.GetEnumDisplayValues(typeof(PresetPictureSettingsMode)); } if (value is IEnumerable) { return EnumHelper.GetEnumDisplayValues(typeof(Decomb)); } if (value is IEnumerable) { return EnumHelper.GetEnumDisplayValues(typeof(Deinterlace)); } if (value is IEnumerable) { return EnumHelper.GetEnumDisplayValues(typeof(Detelecine)); } if (value is IEnumerable) { return EnumHelper.GetEnumDisplayValues(typeof(Denoise)); } if (value is IEnumerable) { return EnumHelper.GetEnumDisplayValues(typeof(VideoScaler)); } if (value is IEnumerable) { return EnumHelper.GetEnumDisplayValues(typeof(OutputFormat)); } if (value is IEnumerable) { return EnumHelper.GetEnumDisplayValues(typeof(DeinterlaceFilter)); } if (value is IEnumerable) { return EnumHelper.GetEnumDisplayValues(typeof(CombDetect)); } if (value is IEnumerable) { return EnumHelper.GetEnumDisplayValues(typeof(Sharpen)); } // Single Items if (targetType == typeof(VideoEncoder) || value.GetType() == typeof(VideoEncoder)) { return EnumHelper.GetDisplay((VideoEncoder)value); } if (targetType == typeof(PresetPictureSettingsMode) || value.GetType() == typeof(PresetPictureSettingsMode)) { return EnumHelper.GetDisplay((PresetPictureSettingsMode)value); } if (targetType == typeof(Deinterlace) || value.GetType() == typeof(Deinterlace)) { return EnumHelper.GetDisplay((Deinterlace)value); } if (targetType == typeof(Detelecine) || value.GetType() == typeof(Detelecine)) { return EnumHelper.GetDisplay((Detelecine)value); } if (targetType == typeof(Decomb) || value.GetType() == typeof(Decomb)) { return EnumHelper.GetDisplay((Decomb)value); } if (targetType == typeof(Denoise) || value.GetType() == typeof(Denoise)) { return EnumHelper.GetDisplay((Denoise)value); } if (targetType == typeof(QueueItemStatus) || value.GetType() == typeof(QueueItemStatus)) { return EnumHelper.GetDisplay((QueueItemStatus)value); } if (targetType == typeof(VideoScaler) || value.GetType() == typeof(VideoScaler)) { return EnumHelper.GetDisplay((VideoScaler)value); } if (targetType == typeof(OutputFormat) || value.GetType() == typeof(OutputFormat)) { return EnumHelper.GetDisplay((OutputFormat)value); } if (targetType == typeof(DeinterlaceFilter) || value.GetType() == typeof(DeinterlaceFilter)) { return EnumHelper.GetDisplay((DeinterlaceFilter)value); } if (targetType == typeof(CombDetect) || value.GetType() == typeof(CombDetect)) { return EnumHelper.GetDisplay((CombDetect)value); } if (targetType == typeof(Sharpen) || value.GetType() == typeof(Sharpen)) { return EnumHelper.GetDisplay((Sharpen)value); } return null; } /// /// Convert Back for the IValueConverter Interface. /// /// /// The value. /// /// /// The target type. /// /// /// The parameter. /// /// /// The culture. /// /// /// Nothing /// /// /// This method is not used! /// public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) { if (targetType == typeof(VideoEncoder) || value.GetType() == typeof(VideoEncoder)) { return EnumHelper.GetValue(value.ToString()); } if (targetType == typeof(PresetPictureSettingsMode) || value.GetType() == typeof(PresetPictureSettingsMode)) { return EnumHelper.GetValue(value.ToString()); } if (targetType == typeof(Denoise) || value.GetType() == typeof(Denoise)) { return EnumHelper.GetValue(value.ToString()); } if (targetType == typeof(Decomb) || value.GetType() == typeof(Decomb)) { return EnumHelper.GetValue(value.ToString()); } if (targetType == typeof(Deinterlace) || value.GetType() == typeof(Deinterlace)) { return EnumHelper.GetValue(value.ToString()); } if (targetType == typeof(Detelecine) || value.GetType() == typeof(Detelecine)) { return EnumHelper.GetValue(value.ToString()); } if (targetType == typeof(VideoScaler) || value.GetType() == typeof(VideoScaler)) { return EnumHelper.GetValue(value.ToString()); } if (targetType == typeof(OutputFormat) || value.GetType() == typeof(OutputFormat)) { return EnumHelper.GetValue(value.ToString()); } if (targetType == typeof(DeinterlaceFilter) || value.GetType() == typeof(DeinterlaceFilter)) { return EnumHelper.GetValue(value.ToString()); } if (targetType == typeof(CombDetect) || value.GetType() == typeof(CombDetect)) { return EnumHelper.GetValue(value.ToString()); } if (targetType == typeof(Sharpen) || value.GetType() == typeof(Sharpen)) { return EnumHelper.GetValue(value.ToString()); } return null; } } }