ColorBrushConvert.cs 942 B

1234567891011121314151617181920212223242526272829303132333435
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Globalization;
  4. using System.Linq;
  5. using System.Text;
  6. using System.Threading.Tasks;
  7. using System.Windows.Data;
  8. using System.Windows.Media;
  9. namespace PDF_Office.DataConvert
  10. {
  11. /// <summary>
  12. /// Color to SolidColorBrush
  13. /// </summary>
  14. public class ColorBrushConvert : IValueConverter
  15. {
  16. public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
  17. {
  18. if((Color)value!=null)
  19. {
  20. return new SolidColorBrush((Color)value);
  21. }
  22. return Brushes.White;
  23. }
  24. public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
  25. {
  26. if((SolidColorBrush)value!=null)
  27. {
  28. return ((SolidColorBrush)value).Color;
  29. }
  30. return Brushes.White.Color;
  31. }
  32. }
  33. }