private int? GetRectangleAt(Point location) { for (int i = 0; i < rectangles.Length; i++) { if (rectangles[i].Contains(location.X, location.Y)) return i; } return null; }