LedConverter.cs 804 B

123456789101112131415161718192021222324252627
  1. using System;
  2. using System.Globalization;
  3. using System.Windows.Data;
  4. using System.Windows.Media;
  5. namespace Aitex.Sorter.UI.Converter
  6. {
  7. public class LedConverter : IMultiValueConverter
  8. {
  9. static Brush GreenBrush = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#FF07FF07"));
  10. static Brush GrayBrush = new SolidColorBrush(Colors.LightGray);
  11. static Brush RedBrush = new SolidColorBrush(Colors.Red);
  12. public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture)
  13. {
  14. var value = (bool)values[0];
  15. var red = (bool)values[1];
  16. return value ? red ? RedBrush : GreenBrush : GrayBrush;
  17. }
  18. public object[] ConvertBack(object value, Type[] targetTypes, object parameter, CultureInfo culture)
  19. {
  20. throw new NotImplementedException();
  21. }
  22. }
  23. }