Skip to content

Commit

Permalink
Merge pull request #438 from bbuerger/master
Browse files Browse the repository at this point in the history
NullCheck for DragPoint
  • Loading branch information
Dirkster99 authored Aug 16, 2023
2 parents 982004b + 31cf051 commit 2ce0033
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 2ce0033

Please # to comment.