// -------------------------------------------------------------------------------------------------------------------- // // This file is part of the HandBrake source code - It may be used under the terms of the GNU General Public License. // // // The inverse boolean converter. // // -------------------------------------------------------------------------------------------------------------------- namespace HandBrakeWPF.Converters { using System; using System.Globalization; using System.Windows.Data; /// /// The inverse boolean converter. /// [ValueConversion(typeof(bool?), typeof(bool))] public class InverseBooleanConverter : 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 (targetType != typeof(bool?) && targetType != typeof(bool)) { throw new InvalidOperationException("The target must be a boolean"); } bool result; bool.TryParse(value.ToString(), out result); return !result; } /// /// The convert back. /// /// /// The value. /// /// /// The target type. /// /// /// The parameter. /// /// /// The culture. /// /// /// The . /// public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) { return null; } } }