LineColorConverter.cs 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  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.Media;
  7. using DataAnalysisControl.Core;
  8. namespace Aitex.UI.Charting.Converter
  9. {
  10. public class LineColorConverter : IValueConverter
  11. {
  12. public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
  13. {
  14. try
  15. {
  16. Color color = (Color)value;
  17. return new SolidColorBrush(color);
  18. }
  19. catch (Exception ex)
  20. {
  21. CONTEXT.WriteLog(ex);
  22. }
  23. return Brushes.Black;
  24. }
  25. public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
  26. {
  27. try
  28. {
  29. Brush brush = (SolidColorBrush)value;
  30. Color color = (Color)ColorConverter.ConvertFromString(brush.ToString());
  31. return color;
  32. }
  33. catch (Exception ex)
  34. {
  35. CONTEXT.WriteLog(ex);
  36. }
  37. return Colors.Black;
  38. }
  39. }
  40. }