// -------------------------------------------------------------------------------------------------------------------- // // This file is part of the HandBrake source code - It may be used under the terms of the GNU General Public License. // // // Defines the BooleanToHiddenVisibilityConverter type. // // -------------------------------------------------------------------------------------------------------------------- namespace HandBrakeWPF.Converters { using System; using System.Globalization; using System.Windows; using System.Windows.Data; /// /// Boolean to Visibility Converter (Hidden, not Collasped) /// public sealed class BooleanToHiddenVisibilityConverter : IValueConverter { /// /// Convert a boolean to visibility property. /// /// /// 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) { // Parameter is a boolean which inverts the output. var param = System.Convert.ToBoolean(parameter, CultureInfo.InvariantCulture); if (value == null) { return Visibility.Hidden; } if (value is bool) { if (param) { return (bool)value ? Visibility.Hidden : Visibility.Visible; } else { return (bool)value ? Visibility.Visible : Visibility.Hidden; } } return value; } /// /// Convert Back for the IValueConverter Interface. Not used! /// /// /// 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) { throw new NotImplementedException(); } } }