Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

NullCheck for DragPoint #438

Merged
merged 1 commit into from
Aug 16, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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