// --------------------------------------------------------------------------------------------------------------------
//
// This file is part of the HandBrake source code - It may be used under the terms of the GNU General Public License.
//
//
// Defines the BooleanConverter type.
//
// --------------------------------------------------------------------------------------------------------------------
namespace HandBrakeWPF.Converters
{
using System;
using System.Globalization;
using System.Windows.Data;
///
/// Boolean to Visibility Converter
///
public sealed class BooleanConverter : 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 is bool)
{
return param ? !(bool)value : value;
}
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)
{
return this.Convert(value, targetType, parameter, culture);
}
}
}