DirectionConverter.cs 978 B

123456789101112131415161718192021222324252627282930313233
  1. using Muchinfo.MTPClient.Data.Enums;
  2. using System;
  3. using System.Windows;
  4. using System.Windows.Data;
  5. namespace Muchinfo.MTPClient.Infrastructure.Converters
  6. {
  7. public class DirectionConverter : IValueConverter
  8. {
  9. public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
  10. {
  11. if (!(value is Direction))
  12. {
  13. return TextAlignment.Left;
  14. }
  15. switch ((Direction)value)
  16. {
  17. case Direction.Ask:
  18. return TextAlignment.Right;
  19. case Direction.Bid:
  20. return TextAlignment.Left;
  21. }
  22. //默认左对齐
  23. return TextAlignment.Left;
  24. }
  25. public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
  26. {
  27. throw new NotImplementedException();
  28. }
  29. }
  30. }