Bug in geometry Hit-Testing

匆匆过客 提交于 2019-12-01 05:25:23
gliderkite

It seems like hit-testing considers the position of the shapes to which was applied a reverse order of transformations. This would explain why my path is intersected only and not fully inside the RectangleGeometry argument of MyCanvas.GetVisuals method.

Waiting for a better response, i implemented the hit-test with a not hit-testing method, now part of MyCanvas class:

public List<DrawingVisual> GetVisuals(Rect Area)
{
   this.Hits.Clear();

   foreach (DrawingVisual DVisual in this.Visuals) {
       if (Area.Contains(DVisual.DescendantBounds))
           this.Hits.Add(DVisual);
   }

   return this.Hits;
}

EDIT:

As Mike Danes (moderator on MSDN forum) explains in this thread:

"Is it really possible that this is a bug in geometry hit-testing?"

I'm 99% sure this is a bug. Drawing and hit testing should use the same transform order. The reason it works correctly with TransformGroup is because this way you only push only one transform in the drawing context and this avoids the wrong multiplication order in the hit test drawing context. Note that this has nothing to do with the fact that the order used in TranformGroup is different from the push order.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!