IntToColorConverter.cs 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  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. namespace CyberX8_Themes.Converters
  9. {
  10. internal class IntToColorConverter : IValueConverter
  11. {
  12. public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
  13. {
  14. switch (value)
  15. {
  16. //Init
  17. case 0:
  18. return new SolidColorBrush(Colors.Yellow);
  19. //Idle状态 无色
  20. case 1:
  21. return new SolidColorBrush(Colors.Transparent);
  22. //Busy状态 绿色
  23. case 2:
  24. return new SolidColorBrush(Colors.Lime);
  25. //Disable状态 深灰色
  26. case 3:
  27. return new SolidColorBrush(Colors.DarkGray);
  28. //Error状态 红色
  29. case 4:
  30. return new SolidColorBrush(Colors.Red);
  31. default:
  32. return new SolidColorBrush(Colors.Transparent);
  33. }
  34. }
  35. public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
  36. {
  37. if (!(value is bool))
  38. return false;
  39. return !(bool)value;
  40. }
  41. }
  42. }