WindowStateToThicknessConverter.cs 975 B

12345678910111213141516171819202122232425262728293031323334
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Globalization;
  4. using System.Linq;
  5. using System.Text;
  6. using System.Threading.Tasks;
  7. using System.Windows.Data;
  8. using System.Windows;
  9. namespace compdfkit_tools.Common
  10. {
  11. [ValueConversion(typeof(WindowState), typeof(Thickness))]
  12. public class WindowStateToThicknessConverter : IValueConverter
  13. {
  14. public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
  15. {
  16. var ws = (WindowState)value;
  17. if (ws == WindowState.Maximized)
  18. {
  19. return new Thickness(6);
  20. }
  21. else
  22. {
  23. // left, right and bottom borders are still drawn by the system
  24. return new Thickness(0, 1, 0, 0);
  25. }
  26. }
  27. public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
  28. {
  29. return null;
  30. }
  31. }
  32. }