using System;
using System.Windows.Data;
namespace DTS.Common.Converters
{
///
/// Represents a converter that converts a Boolean value to its inverse.
///
public class InverseBooleanConverter : IValueConverter
{
///
/// Modifies the source data before passing it to the target for display in the UI.
///
/// The source data being passed to the target.
/// The System.Type of data expected by the target dependency property.
/// An optional parameter to be used in the converter logic.
/// The culture of the conversion.
/// The value to be passed to the target dependency property.
public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
{
if (value == null) return false;
bool val;
bool.TryParse(value.ToString(), out val);
return !val;
}
///
/// Modifies the target data before passing it to the source object. This method is called only in System.Windows.Data.BindingMode.TwoWay bindings.
///
/// The target data being passed to the source.
/// The System.Type of data expected by the source object.
/// An optional parameter to be used in the converter logic.
/// The culture of the conversion.
/// The value to be passed to the source object.
public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
{
if (value == null) return false;
bool val;
bool.TryParse(value.ToString(), out val);
return !val;
}
}
}