Created
November 14, 2014 17:02
-
-
Save Delaire/2ec8c1326bb0b42386b3 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//the object of this methode is to create 2 rectangles, from our two objects and see they intersect or not | |
protected bool IsObjectHidden(FrameworkElement child, FrameworkElement scrollViewer, int Offset) | |
{ | |
//Getting the information related to the scrollViewer | |
GeneralTransform childTransform = child.TransformToVisual(scrollViewer); | |
//creating out first rectangle using the object that i wish to ttrack | |
Rect childRectangle = childTransform.TransformBounds(new Rect(new Point(0, 0), child.RenderSize)); | |
//creating out second rectangle using the scrollViewer | |
Rect ownerRectangle = new Rect(new Point(0, 0), scrollViewer.RenderSize); | |
//Testing | |
bool isInterset = IntersectsWith(childRectangle, ownerRectangle, Offset); | |
return !isInterset; | |
} | |
//the object of this methode is to create 2 rectangles, from our two objects and see they intersect or not | |
public static bool IntersectsWith(Rect rect, Rect other, int offset) | |
{ | |
// Test for separating axis on the two rectangles | |
if (other.Bottom < rect.Top || other.Right < rect.Left | |
|| other.Top > rect.Bottom || other.Left > (rect.Right - offset)) | |
{ | |
return false; | |
} | |
return true; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment