问题描述
我有一组需要相互绘制的形状.我需要重新排序它们,以便最后绘制最小的形状(即它将最接近用户).有什么方法可以检查一个形状是否重叠(包围和/或相交)另一个形状.我知道在Rect
结构中有一个称为Contains
的方法,该方法检查其中是否有对象.在WPF中是否有类似的方法或方法可以在Shapes上对其进行仿真?预先感谢您的帮助.
I have a set of shapes which need to be drawn on top of each other. I need to re-order them such that the smallest shape gets drawn last (i.e. it will be closest to the user). Is there any way to check whether a shape overlappes (encloses and/or intersects) another shape. I know there is a method in Rect
structure called Contains
which checks whether there is an object within it. Is there a similar method or a way to simulate it on Shapes in WPF? Thanks in advance for any help.
干杯
Nilu
推荐答案
您可能会使用 Geometry.FillContainsWithDetail
方法.它的名字是恕我直言的恕我直言,但描述很清楚:
You could probably use the Geometry.FillContainsWithDetail
method. Its name is ill-chosen IMHO, but the description is clear :
我以前已经成功地将其用于碰撞测试,所以它也应该对您有用...
I have successfully used it for collision testing before, so it should work for you too...
这篇关于检查WPF中的重叠形状的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!