GetWidthByWWConvert.cs 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. using GeekDesk.Constant;
  2. using GeekDesk.ViewModel;
  3. using System;
  4. using System.Globalization;
  5. using System.Windows.Data;
  6. namespace GeekDesk.Converts
  7. {
  8. /// <summary>
  9. /// 根据主窗口width 和传入类型 获取其它宽度
  10. /// </summary>
  11. class GetWidthByWWConvert : IValueConverter
  12. {
  13. public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
  14. {
  15. WidthTypeEnum type = (WidthTypeEnum)parameter;
  16. AppConfig config = MainWindow.appData.AppConfig;
  17. if (WidthTypeEnum.LEFT_CARD == type)
  18. {
  19. return config.MenuCardWidth;
  20. }
  21. else if (WidthTypeEnum.RIGHT_CARD == type)
  22. {
  23. return config.WindowWidth - config.MenuCardWidth;
  24. } else if (WidthTypeEnum.RIGHT_CARD_HALF == type)
  25. {
  26. return (config.WindowWidth - config.MenuCardWidth) * 0.618;
  27. } else if (WidthTypeEnum.RIGHT_CARD_HALF_TEXT == type)
  28. {
  29. return (config.WindowWidth - config.MenuCardWidth) * 0.618 - config.ImageWidth - 20;
  30. } else if (WidthTypeEnum.RIGHT_CARD_20 == type)
  31. {
  32. return (config.WindowWidth - config.MenuCardWidth) - 20;
  33. }
  34. return config.WindowWidth;
  35. }
  36. public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
  37. {
  38. return null;
  39. }
  40. }
  41. }