CellBorderConverter.cs 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  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 CellBorderConverter : IValueConverter
  9. {
  10. public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
  11. {
  12. try
  13. {
  14. bool v = (bool)value;
  15. if (v)
  16. return new System.Windows.Thickness(4, 0, 4, 0);
  17. else
  18. return new System.Windows.Thickness(0, 0, 0, 0);
  19. }
  20. catch (Exception ex)
  21. {
  22. System.Diagnostics.Debug.WriteLine(ex.Message);
  23. }
  24. return new System.Windows.Thickness(0, 0, 0, 0);
  25. }
  26. public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
  27. {
  28. return null;
  29. }
  30. }
  31. public class JumpCellBorderConverter : IValueConverter
  32. {
  33. public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
  34. {
  35. bool v;
  36. bool.TryParse(value.ToString(), out v);
  37. double t = v ? 2 : 0;
  38. return new System.Windows.Thickness(t, t, t, t);
  39. }
  40. public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
  41. {
  42. return null;
  43. }
  44. }
  45. }