Can I pass a collection of locations to HitTest(object, location). I have a line for an object and a points that make the edge of a shape, which are the locations. Is this an efficien开发者_开发知识库t way of finding the intersection point?
Insead of a collection of points for the edges of an ellipse, can't you use an EllipseGeometry?
Here is an example
void SomeControl_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
{
UIElement element = sender as UIElement;
Point point = e.GetPosition(element);
EllipseGeometry hitGeometry = new EllipseGeometry(point, 1.0, 1.0);
VisualTreeHelper.HitTest(element,
null,
new HitTestResultCallback(HitTestCallback),
new GeometryHitTestParameters(hitGeometry));
}
public HitTestResultBehavior HitTestCallback(HitTestResult result)
{
// Do your hit testing
}
精彩评论