Converter.cs 975 B

123456789101112131415161718192021222324252627282930313233
  1. using System;
  2. using System.Globalization;
  3. using System.Windows.Data;
  4. namespace DeviceCenter
  5. {
  6. [ValueConversion(typeof(DeviceStatus), typeof(String))]
  7. class DeviceStatusColorConverter : IValueConverter
  8. {
  9. public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
  10. {
  11. if (value != null)
  12. {
  13. DeviceStatus status = (DeviceStatus)value;
  14. switch (status)
  15. {
  16. case DeviceStatus.CONNECTING:
  17. return "#E6A23C";
  18. case DeviceStatus.CONNECTED:
  19. return "#67C23A";
  20. case DeviceStatus.FAIL:
  21. return "#F56C6C";
  22. }
  23. }
  24. return "";
  25. }
  26. public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
  27. {
  28. return null;
  29. }
  30. }
  31. }