SystemStateConverter.cs 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  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. RtState currentState = (RtState)Enum.Parse(typeof(RtState), value.ToString());
  16. switch (currentState)
  17. {
  18. case RtState.Init:
  19. //return new SolidColorBrush(Colors.Yellow);
  20. return new SolidColorBrush((Color)ColorConverter.ConvertFromString("#D79C11"));
  21. case RtState.Idle:
  22. return new SolidColorBrush(Colors.WhiteSmoke);
  23. case RtState.Error:
  24. return new SolidColorBrush(Colors.Red);
  25. default:
  26. return new SolidColorBrush(Colors.Lime);
  27. }
  28. }
  29. public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
  30. {
  31. return null;
  32. }
  33. }
  34. }