ErrColorConverter.cs 1.0 KB

123456789101112131415161718192021222324252627282930313233343536
  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 ErrColorConverter : 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 Brushes.White;
  17. var errors = value as List<Tuple<int/*row no*/, int/*col no*/, string/*var name*/, string/*reason*/>>;
  18. if (errors.Count > 0)
  19. return Brushes.Red;
  20. return Brushes.White;
  21. }
  22. catch (Exception ex)
  23. {
  24. System.Diagnostics.Debug.WriteLine(ex.Message);
  25. }
  26. return Brushes.White;
  27. }
  28. public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
  29. {
  30. return null;
  31. }
  32. }
  33. }