// --------------------------------------------------------------------------------------------------------------------
//
// This file is part of the HandBrake source code - It may be used under the terms of the GNU General Public License.
//
//
// Audio Track Default Behaviour Converter
//
// --------------------------------------------------------------------------------------------------------------------
namespace HandBrakeWPF.Converters.Audio
{
using System;
using System.ComponentModel;
using System.Globalization;
using System.Linq;
using System.Windows.Data;
using HandBrake.ApplicationServices.Utilities;
using HandBrakeWPF.Model.Audio;
using HandBrakeWPF.Utilities;
///
/// Audio Behaviour Converter
///
public class AudioTrackDefaultBehaviourConverter : 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(AudioTrackDefaultsMode)).ToList());
}
if (value != null && value.GetType() == typeof(AudioTrackDefaultsMode))
{
return EnumHelper.GetDisplay((AudioTrackDefaultsMode)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;
}
}
}