// --------------------------------------------------------------------------------------------------------------------
//
// This file is part of the HandBrake source code - It may be used under the terms of the GNU General Public License.
//
//
// Subtitle Behaviour Converter
//
// --------------------------------------------------------------------------------------------------------------------
namespace HandBrakeWPF.Converters.Subtitles
{
using System;
using System.ComponentModel;
using System.Globalization;
using System.Linq;
using System.Windows.Data;
using HandBrake.ApplicationServices.Utilities;
using HandBrakeWPF.Model.Subtitles;
using HandBrakeWPF.Utilities;
///
/// Subtitle Behaviour Converter
///
public class SubtitleBehaviourConverter : IValueConverter
{
///
/// The convert.
///
///
/// The value.
///
///
/// The target type.
///
///
/// The parameter.
///
///
/// The culture.
///
///
/// The .
///
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
if (value != null && value.GetType() == typeof(BindingList))
{
return
new BindingList(
EnumHelper.GetEnumDisplayValues(typeof(SubtitleBehaviourModes)).ToList());
}
if (value != null && value.GetType() == typeof(SubtitleBehaviourModes))
{
return EnumHelper.GetDisplay((SubtitleBehaviourModes)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)
{
string name = value as string;
if (!string.IsNullOrEmpty(name))
{
return EnumHelper.GetValue(name);
}
return null;
}
}
}