TradeModeVisibilityConverter.cs 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. using System;
  2. //----------------------------------------------------------------
  3. //Module Name: $safeprojectname$
  4. //Purpose:
  5. //CopyRight: Muchinfo
  6. //History:
  7. //----------------------------------------------------------------
  8. //DateTime 2016/5/10 18:58:00
  9. //Author
  10. //Description Create
  11. //----------------------------------------------------------------
  12. using System.Windows;
  13. using System.Windows.Data;
  14. namespace Muchinfo.MTPClient.Infrastructure.Converters
  15. {
  16. public class TradeModeVisibilityConverter : IValueConverter
  17. {
  18. public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
  19. {
  20. if (value != null && parameter != null)
  21. {
  22. try
  23. {
  24. int paramValue;
  25. eTradeMode tradeMode;
  26. if (!int.TryParse(parameter.ToString(), out paramValue))
  27. {
  28. paramValue = 0;
  29. }
  30. if (!Enum.TryParse(value.ToString(), out tradeMode))
  31. {
  32. tradeMode = eTradeMode.TRADEMODE_MARKETMAKE;
  33. }
  34. ////parameter == 0; 即期模式报价
  35. if (paramValue.Equals(0) && tradeMode == eTradeMode.TRADEMODE_MARKETMAKE) return Visibility.Visible;
  36. ////parameter == 1; 竞价模式报价
  37. //if (paramValue.Equals(1) &&
  38. // (tradeMode == eTradeMode.TRADEMODE_BIDDING ||
  39. // tradeMode == eTradeMode.TRADEMODE_BIDDINGMARKETMAKE)) return Visibility.Visible;
  40. if (paramValue.Equals(1) &&
  41. (tradeMode == eTradeMode.TRADEMODE_BIDDING)) return Visibility.Visible;
  42. return Visibility.Collapsed;
  43. }
  44. catch
  45. {
  46. return Visibility.Collapsed;
  47. }
  48. }
  49. return Visibility.Collapsed;
  50. }
  51. public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
  52. {
  53. return false;
  54. }
  55. }
  56. }