LevelIdToTextConverter.cs 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. namespace GDNXFD.Alert.Config.Converters
  2. {
  3. using System;
  4. using System.IO;
  5. using System.Windows.Data;
  6. using System.Windows.Media.Imaging;
  7. /// <summary>
  8. /// Byte to image converter
  9. /// </summary>
  10. public class LevelIdToTextConverter : IValueConverter
  11. {
  12. /// <summary>
  13. /// Convert a byte array to an image.
  14. /// </summary>
  15. /// <param name="value"></param>
  16. /// <param name="targetType"></param>
  17. /// <param name="parameter"></param>
  18. /// <param name="culture"></param>
  19. /// <returns></returns>
  20. public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
  21. {
  22. if (value != null)
  23. {
  24. string code = value.ToString().Trim();
  25. switch (code)
  26. {
  27. case "LOLO":
  28. return "低";
  29. case "LO":
  30. return "中低";
  31. case "MEDIUM":
  32. return "中";
  33. case "HI":
  34. return "中高";
  35. case "HIHI":
  36. return "高";
  37. }
  38. }
  39. return "未知";
  40. }
  41. /// <summary>
  42. /// Convert an image to a byte array
  43. /// </summary>
  44. /// <param name="value"></param>
  45. /// <param name="targetType"></param>
  46. /// <param name="parameter"></param>
  47. /// <param name="culture"></param>
  48. /// <returns></returns>
  49. public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
  50. {
  51. throw new NotImplementedException();
  52. }
  53. }
  54. }