SystemStateConverter.cs 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. using athosCore;
  2. using System;
  3. using System.Windows.Data;
  4. using System.Windows.Media;
  5. namespace athosThemes.Converters
  6. {
  7. internal class SystemStateConverter : IValueConverter
  8. {
  9. public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
  10. {
  11. if (value == null) return new SolidColorBrush((Color)ColorConverter.ConvertFromString("#D79C11"));
  12. RtState currentState = (RtState)Enum.Parse(typeof(RtState), value.ToString());
  13. switch (currentState)
  14. {
  15. case RtState.Init:
  16. //return new SolidColorBrush(Colors.Yellow);
  17. return new SolidColorBrush((Color)ColorConverter.ConvertFromString("#D79C11"));
  18. case RtState.Idle:
  19. return new SolidColorBrush(Colors.WhiteSmoke);
  20. case RtState.Error:
  21. return new SolidColorBrush(Colors.Red);
  22. default:
  23. //return new SolidColorBrush(Colors.Lime);
  24. return new SolidColorBrush((Color)ColorConverter.ConvertFromString("#07B699"));
  25. }
  26. }
  27. public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
  28. {
  29. return null;
  30. }
  31. }
  32. }