检查WPF中的重叠形状 [英] Check for overlapping shapes in WPF

查看:83
本文介绍了检查WPF中的重叠形状的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一组需要相互绘制的形状.我需要重新排序它们,以便最后绘制最小的形状(即它将最接近用户).有什么方法可以检查一个形状是否重叠(包围和/或相交)另一个形状.我知道在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 :

返回一个值,该值描述当前几何图形和指定几何图形之间的交集.

Returns a value that describes the intersection between the current geometry and the specified geometry.

我以前已经成功地将其用于碰撞测试,所以它也应该对您有用...

I have successfully used it for collision testing before, so it should work for you too...

这篇关于检查WPF中的重叠形状的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆