GetWidthByWWConvert.cs 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  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. else if (WidthTypeEnum.RIGHT_CARD_40 == type)
  35. {
  36. return (config.WindowWidth - config.MenuCardWidth) - 40;
  37. }
  38. else if (WidthTypeEnum.RIGHT_CARD_70 == type)
  39. {
  40. return (config.WindowWidth - config.MenuCardWidth) - 70;
  41. }
  42. return config.WindowWidth;
  43. }
  44. public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
  45. {
  46. return null;
  47. }
  48. }
  49. }