IoButton.cs 1.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. using System;
  2. using System.Windows;
  3. using System.Windows.Controls.Primitives;
  4. using System.Windows.Data;
  5. namespace EfemDualSimulator.Views
  6. {
  7. public class IoButton : ToggleButton
  8. {
  9. public static readonly DependencyProperty ONProperty;
  10. static IoButton()
  11. {
  12. ONProperty = DependencyProperty.Register("ON", typeof(bool), typeof(IoButton));
  13. }
  14. public bool ON
  15. {
  16. get { return (bool)GetValue(ONProperty); }
  17. set { SetValue(ONProperty, value); }
  18. }
  19. }
  20. public class BoolBackgroundConverter : IValueConverter
  21. {
  22. public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
  23. {
  24. bool? ret = (bool?)value;
  25. return ret.HasValue && ret.Value ? "LightBlue" : "Transparent";
  26. }
  27. public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
  28. {
  29. return null;
  30. }
  31. }
  32. }