NotConverter.cs 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. namespace OINA.Extender.WPF.Testharness
  2. {
  3. using System;
  4. using System.Collections.Generic;
  5. using System.Linq;
  6. using System.Text;
  7. using System.Threading.Tasks;
  8. using System.Windows.Data;
  9. /// <summary>
  10. /// Negates a boolean.
  11. /// </summary>
  12. public class NotConverter : IValueConverter
  13. {
  14. /// <summary>
  15. /// Converts a value.
  16. /// </summary>
  17. /// <param name="value">The value produced by the binding source.</param>
  18. /// <param name="targetType">The type of the binding target property.</param>
  19. /// <param name="parameter">The converter parameter to use.</param>
  20. /// <param name="culture">The culture to use in the converter.</param>
  21. /// <returns>
  22. /// A converted value. If the method returns null, the valid null value is used.
  23. /// </returns>
  24. public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
  25. {
  26. return !(bool)value;
  27. }
  28. /// <summary>
  29. /// Converts a value.
  30. /// </summary>
  31. /// <param name="value">The value that is produced by the binding target.</param>
  32. /// <param name="targetType">The type to convert to.</param>
  33. /// <param name="parameter">The converter parameter to use.</param>
  34. /// <param name="culture">The culture to use in the converter.</param>
  35. /// <returns>
  36. /// A converted value. If the method returns null, the valid null value is used.
  37. /// </returns>
  38. public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
  39. {
  40. return !(bool)value;
  41. }
  42. }
  43. }