Skip to content

Commit

Permalink
NullCheck for DragPoint
Browse files Browse the repository at this point in the history
  • Loading branch information
Benny Bürger committed Apr 28, 2023
1 parent 982004b commit 31cf051
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,8 @@ bool IOverlayWindowHost.HitTestScreen(Point dragPoint)

bool HitTest(Point dragPoint)
{
if (dragPoint == default(Point))
return false;
var detectionRect = new Rect(this.PointToScreenDPIWithoutFlowDirection(new Point()), this.TransformActualSizeToAncestor());
return detectionRect.Contains(dragPoint);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,8 @@ bool IOverlayWindowHost.HitTestScreen(Point dragPoint)

bool HitTest(Point dragPoint)
{
if (dragPoint == default(Point))
return false;
var detectionRect = new Rect(this.PointToScreenDPIWithoutFlowDirection(new Point()), this.TransformActualSizeToAncestor());
return detectionRect.Contains(dragPoint);
}
Expand Down
7 changes: 5 additions & 2 deletions source/Components/AvalonDock/Controls/TransformExtentions.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/************************************************************************
/************************************************************************
AvalonDock
Copyright (C) 2007-2013 Xceed Software Inc.
Expand Down Expand Up @@ -59,7 +59,10 @@ public static Rect GetScreenArea(this FrameworkElement element)

public static Point TransformToDeviceDPI(this Visual visual, Point pt)
{
Matrix m = PresentationSource.FromVisual(visual).CompositionTarget.TransformToDevice;
var compositionTarget = PresentationSource.FromVisual(visual).CompositionTarget;
if (compositionTarget == null)
return default;
Matrix m = compositionTarget.TransformToDevice;
return new Point(pt.X / m.M11, pt.Y / m.M22);
}

Expand Down

0 comments on commit 31cf051

Please sign in to comment.