终端一体化运控平台
Não pode escolher mais do que 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.
 
 
 

43 linhas
1.2 KiB

  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. }