// --------------------------------------------------------------------------------------------------------------------
//
// 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.Functions;
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(AudioEncoder));
}
// 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(AudioEncoder) || value.GetType() == typeof(AudioEncoder))
{
return EnumHelper.GetDisplay((AudioEncoder)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(AudioEncoder) || value.GetType() == typeof(AudioEncoder))
{
return EnumHelper.GetValue(value.ToString());
}
return null;
}
}
}