SystemStateConverter.cs 1.3 KB

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