C# - 检测 PictureBox 重叠

C# - Detect PictureBox overlap

是否可以检测一个 pictureBox 是否与另一个 pictureBox with/overlapping 发生碰撞?很抱歉问题表述含糊不清。

您可以使用 Rectangle.Intersect.
只需将两个 PictureBoxes 的 Bounds 给方法:

Rectangle unionRect = Rectangle.Intersect(pictureBox1.Bounds, pictureBox2.Bounds);
if (unionRect.IsEmpty) {
    // no intersecion
}

要检查 2 个矩形是否重叠,您可以使用 IntersectsWith:

bool overlapped= pictureBox1.Bounds.IntersectsWith(pictureBox12.Bounds);

要找到交叉区域,您可以使用 Rectangle.Intersect:

Rectangle intersectionArea = Rectangle.Intersect(pictureBox1.Bounds, pictureBox2.Bounds);