终端一体化运控平台
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

StatusIconConverter.cs 1.5 KiB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6. using System.Data;
  7. using System.Windows.Data;
  8. using System.Globalization;
  9. using System.Text.RegularExpressions;
  10. namespace BPASmartClient.SmallBatchingSystem.Converter
  11. {
  12. public class StatusIconConverter : IValueConverter
  13. {
  14. public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
  15. {
  16. if (value != null)
  17. {
  18. if (value.ToString() == Status.等待配料.ToString())
  19. return Regex.Unescape(StringToUnicode(""));
  20. else if (value.ToString() == Status.正在配料.ToString())
  21. return Regex.Unescape(StringToUnicode(""));
  22. else if (value.ToString() == Status.配料完成.ToString())
  23. return Regex.Unescape(StringToUnicode(""));
  24. }
  25. return value;
  26. }
  27. public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
  28. {
  29. throw new NotImplementedException();
  30. }
  31. /// <summary>
  32. /// 字符串转为UniCode码字符串
  33. /// </summary>
  34. public static string StringToUnicode(string s)
  35. {
  36. if (!string.IsNullOrEmpty(s))
  37. {
  38. //这里把格式&#xe625; 转为 \ue625
  39. return s.Replace(@"&#x", @"\u").Replace(";", "");
  40. }
  41. return s;
  42. }
  43. }
  44. }