ErrItemDisplayConverter.cs 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Windows.Data;
  6. namespace Aitex.UI.RecipeEditor
  7. {
  8. public class ErrItemDisplayConverter : IValueConverter
  9. {
  10. public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
  11. {
  12. try
  13. {
  14. if (value == null)
  15. return "";
  16. var list1 = value as List<Tuple<int, int, string, string>>;
  17. var list2 = new List<string>();
  18. int no = 1;
  19. foreach (var item in list1)
  20. {
  21. list2.Add(string.Format("{0}. 第{1}步,第{2}行,变量名:{3},原因:{4}", no++, item.Item2 + 1, item.Item1 + 1, item.Item3, item.Item4));
  22. }
  23. return list2;
  24. }
  25. catch (Exception ex)
  26. {
  27. System.Diagnostics.Debug.WriteLine(ex.Message);
  28. }
  29. return null;
  30. }
  31. public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
  32. {
  33. return value.ToString();
  34. }
  35. }
  36. }