// -------------------------------------------------------------------------------------------------------------------- // // 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.Interop.Interop.Model.Encoding; using HandBrake.Interop.Model; using HandBrakeWPF.Model.Options; using HandBrakeWPF.Services.Queue.Model; using HandBrakeWPF.Utilities; using OutputFormat = HandBrakeWPF.Services.Encode.Model.Models.OutputFormat; /// /// Enum Combo Converter /// public sealed class EnumComboConverter : IValueConverter { 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(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)); } if (value is IEnumerable) { return EnumHelper.GetEnumDisplayValues(typeof(FileOverwriteBehaviour)); } if (value is IEnumerable) { return EnumHelper.GetEnumDisplayValues(typeof(AutonameFileCollisionBehaviour)); } if (value is IEnumerable) { return EnumHelper.GetEnumDisplayValues(typeof(WhenDone)); } // Single Items if (targetType == typeof(VideoEncoder) || value.GetType() == typeof(VideoEncoder)) { return EnumHelper.GetDisplay((VideoEncoder)value); } if (targetType == typeof(Detelecine) || value.GetType() == typeof(Detelecine)) { return EnumHelper.GetDisplay((Detelecine)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); } if (targetType == typeof(FileOverwriteBehaviour) || value.GetType() == typeof(FileOverwriteBehaviour)) { return EnumHelper.GetDisplay((FileOverwriteBehaviour)value); } if (targetType == typeof(AutonameFileCollisionBehaviour) || value.GetType() == typeof(AutonameFileCollisionBehaviour)) { return EnumHelper.GetDisplay((AutonameFileCollisionBehaviour)value); } if (targetType == typeof(WhenDone) || value.GetType() == typeof(WhenDone)) { return EnumHelper.GetDisplay((WhenDone)value); } return null; } public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) { if (value is null) { return null; } if (targetType == typeof(VideoEncoder) || value.GetType() == typeof(VideoEncoder)) { return EnumHelper.GetValue(value.ToString()); } if (targetType == typeof(Denoise) || value.GetType() == typeof(Denoise)) { 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()); } if (targetType == typeof(WhenDone) || value.GetType() == typeof(WhenDone)) { return EnumHelper.GetValue(value.ToString()); } return null; } } }