private Rectangle GetMaze() { if (!Rectangles.Any()) { return(Rectangle.Empty); } var top = Rectangles.Min(rectangle => rectangle.Top); var bottom = Rectangles.Max(rectangle => rectangle.Bottom); var left = Rectangles.Min(rectangle => rectangle.Left); var right = Rectangles.Max(rectangle => rectangle.Right); return(new Rectangle(left, top, Math.Abs(right - left), Math.Abs(bottom - top))); }