终端一体化运控平台
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.

StringToIconConverter.cs 1.2 KiB

преди 2 години
123456789101112131415161718192021222324252627282930313233343536373839404142
  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.CustomResource.Converters
  11. {
  12. public class StringToIconConverter : IValueConverter
  13. {
  14. public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
  15. {
  16. if (value != null)
  17. {
  18. return Regex.Unescape(StringToUnicode(value.ToString()));
  19. }
  20. return value;
  21. }
  22. public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
  23. {
  24. throw new NotImplementedException();
  25. }
  26. /// <summary>
  27. /// 字符串转为UniCode码字符串
  28. /// </summary>
  29. public static string StringToUnicode(string s)
  30. {
  31. if (!string.IsNullOrEmpty(s))
  32. {
  33. //这里把格式&#xe625; 转为 \ue625
  34. return s.Replace(@"&#x", @"\u").Replace(";", "");
  35. }
  36. return s;
  37. }
  38. }
  39. }