[ColorPicker] Adjust window positioning in bottom & right corners of … (#15097)

* [ColorPicker] Adjust window positioning in bottom & right corners of the screens

* Make it window height dependent

* Right side dead zone dependent on window width
This commit is contained in:
Stefan Markovic
2021-12-22 19:35:15 +01:00
committed by GitHub
parent 57cdae724a
commit f280170021

View File

@@ -12,8 +12,9 @@ namespace ColorPicker.Behaviors
public class ChangeWindowPositionBehavior : Behavior<Window> public class ChangeWindowPositionBehavior : Behavior<Window>
{ {
// color window should not get into these zones, only mouse to avoid window getting outsize of monitor // color window should not get into these zones, only mouse to avoid window getting outsize of monitor
private const int MonitorRightSideDeadZone = 200; private const int MonitorRightSideDeadZone = 285;
private const int MonitorBottomSideDeadZone = 80; private const int MonitorBottomSideDeadZone = 90;
private const int WindowOffsetWhenInDeadZone = 10;
private const int YOffset = 10; private const int YOffset = 10;
private const int XOffset = 5; private const int XOffset = 5;
@@ -60,12 +61,12 @@ namespace ColorPicker.Behaviors
if ((windowLeft + MonitorRightSideDeadZone) > monitorBounds.Right / dpi.DpiScaleX) if ((windowLeft + MonitorRightSideDeadZone) > monitorBounds.Right / dpi.DpiScaleX)
{ {
windowLeft -= MonitorRightSideDeadZone - (((int)monitorBounds.Right / dpi.DpiScaleX) - windowLeft); windowLeft -= AssociatedObject.Width + WindowOffsetWhenInDeadZone;
} }
if ((windowTop + MonitorBottomSideDeadZone) > monitorBounds.Bottom / dpi.DpiScaleX) if ((windowTop + MonitorBottomSideDeadZone) > monitorBounds.Bottom / dpi.DpiScaleX)
{ {
windowTop -= MonitorBottomSideDeadZone - (((int)monitorBounds.Bottom / dpi.DpiScaleX) - windowTop); windowTop -= AssociatedObject.Height + WindowOffsetWhenInDeadZone;
} }
AssociatedObject.Left = windowLeft; AssociatedObject.Left = windowLeft;