ErrTooltipConverter.cs 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Windows.Data;
  6. using System.Windows;
  7. using System.Windows.Media;
  8. namespace Aitex.UI.RecipeEditor
  9. {
  10. class ErrTooltipConverter : IValueConverter
  11. {
  12. public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
  13. {
  14. try
  15. {
  16. if (value == null) return " 0 Error";
  17. var errors = value as List<Tuple<int/*row no*/, int/*col no*/, string/*var name*/, string/*reason*/>>;
  18. string errStr = string.Format("Found {0} erros\r\n", errors.Count);
  19. int index = 1;
  20. foreach (var e in errors)
  21. {
  22. errStr += string.Format("\r\n({0}). step {1},Line {2},{3},{4}。", index++, e.Item2 + 1, e.Item1 + 1, e.Item3, e.Item4);
  23. }
  24. return errStr;
  25. }
  26. catch (Exception ex)
  27. {
  28. System.Diagnostics.Debug.WriteLine(ex.Message);
  29. }
  30. return " Unknown Error";
  31. }
  32. public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
  33. {
  34. return null;
  35. }
  36. }
  37. }