// --------------------------------------------------------------------------------------------------------------------
//
// 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.Collections.Generic;
using System.Globalization;
using System.Windows.Data;
using System;
using HandBrake.ApplicationServices.Model;
using HandBrake.ApplicationServices.Utilities;
using HandBrake.Interop.Model.Encoding;
using HandBrake.Interop.Model.Encoding.x264;
///
/// 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)
{
// Lists
if (value is IEnumerable)
{
return EnumHelper.GetEnumDisplayValues(typeof(x264Preset));
}
if (value is IEnumerable)
{
return EnumHelper.GetEnumDisplayValues(typeof(x264Profile));
}
if (value is IEnumerable)
{
return EnumHelper.GetEnumDisplayValues(typeof(x264Tune));
}
if (value is IEnumerable)
{
return EnumHelper.GetEnumDisplayValues(typeof(VideoEncoder));
}
if (value is IEnumerable)
{
return EnumHelper.GetEnumDisplayValues(typeof(Mixdown));
}
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));
}
// Single Items
if (targetType == typeof(x264Preset) || value.GetType() == typeof(x264Preset))
{
return EnumHelper.GetDisplay((x264Preset)value);
}
if (targetType == typeof(x264Profile) || value.GetType() == typeof(x264Profile))
{
return EnumHelper.GetDisplay((x264Profile)value);
}
if (targetType == typeof(x264Tune) || value.GetType() == typeof(x264Tune))
{
return EnumHelper.GetDisplay((x264Tune)value);
}
if (targetType == typeof(VideoEncoder) || value.GetType() == typeof(VideoEncoder))
{
return EnumHelper.GetDisplay((VideoEncoder)value);
}
if (targetType == typeof(Mixdown) || value.GetType() == typeof(Mixdown))
{
return EnumHelper.GetDisplay((Mixdown)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);
}
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(x264Preset) || value.GetType() == typeof(x264Preset))
{
return EnumHelper.GetValue(value.ToString());
}
if (targetType == typeof(x264Profile) || value.GetType() == typeof(x264Profile))
{
return EnumHelper.GetValue(value.ToString());
}
if (targetType == typeof(x264Tune) || value.GetType() == typeof(x264Tune))
{
return EnumHelper.GetValue(value.ToString());
}
if (targetType == typeof(VideoEncoder) || value.GetType() == typeof(VideoEncoder))
{
return EnumHelper.GetValue(value.ToString());
}
if (targetType == typeof(Mixdown) || value.GetType() == typeof(Mixdown))
{
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());
}
return null;
}
}
}