From a19dc794a57f63444094c83511f4bac3a0a55e2c Mon Sep 17 00:00:00 2001 From: Dan Walmsley Date: Tue, 8 Mar 2022 11:58:26 +0000 Subject: [PATCH] add contains exclusive. --- src/Avalonia.Controls/Platform/ScreenHelper.cs | 2 +- src/Avalonia.Visuals/Rect.cs | 12 ++++++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/src/Avalonia.Controls/Platform/ScreenHelper.cs b/src/Avalonia.Controls/Platform/ScreenHelper.cs index 07affb5ecc..0bd2be69d0 100644 --- a/src/Avalonia.Controls/Platform/ScreenHelper.cs +++ b/src/Avalonia.Controls/Platform/ScreenHelper.cs @@ -11,7 +11,7 @@ namespace Avalonia.Platform { foreach (Screen screen in screens) { - if (screen.Bounds.Contains(point)) + if (screen.Bounds.ContainsExclusive(point)) { return screen; } diff --git a/src/Avalonia.Visuals/Rect.cs b/src/Avalonia.Visuals/Rect.cs index 6d7d6c2e54..7930228d99 100644 --- a/src/Avalonia.Visuals/Rect.cs +++ b/src/Avalonia.Visuals/Rect.cs @@ -252,6 +252,18 @@ namespace Avalonia return p.X >= _x && p.X <= _x + _width && p.Y >= _y && p.Y <= _y + _height; } + + /// + /// Determines whether a point is in the bounds of the rectangle, exclusive of the + /// rectangle's bottom/right edge. + /// + /// The point. + /// true if the point is in the bounds of the rectangle; otherwise false. + public bool ContainsExclusive(Point p) + { + return p.X >= _x && p.X < _x + _width && + p.Y >= _y && p.Y < _y + _height; + } /// /// Determines whether the rectangle fully contains another rectangle.