// -----------------------------------------------------------------------
//
// Copyright (c) Microsoft Corporation. All rights reserved.
//
// -----------------------------------------------------------------------
namespace Microsoft.Samples.Kinect.WebserverBasics
{
using System;
using System.Windows.Data;
///
/// Converts a boolean value to its inverse.
///
[ValueConversion(typeof(bool), typeof(bool))]
public class InverseBooleanConverter : IValueConverter
{
#region IValueConverter Members
///
/// Converts a value.
///
///
/// The value produced by the binding source.
///
///
/// The type of the binding target property.
///
///
/// The converter parameter to use.
///
///
/// The culture to use in the converter.
///
///
/// A converted value. If the method returns null, the valid null value is used.
///
public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
{
if (targetType != typeof(bool))
{
throw new InvalidOperationException("The target must be a boolean");
}
return !(bool)value;
}
///
/// Converts a value.
///
///
/// The value that is produced by the binding target.
///
///
/// The type to convert to.
///
///
/// The converter parameter to use.
///
///
/// The culture to use in the converter.
///
///
/// A converted value. If the method returns null, the valid null value is used.
///
public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
{
if (targetType != typeof(bool))
{
throw new InvalidOperationException("The target must be a boolean");
}
return !(bool)value;
}
#endregion
}
}