Class GeometryHelpers
- Namespace
- SharpConsoleUI.Helpers
- Assembly
- SharpConsoleUI.dll
Provides static helper methods for Rectangle geometry operations. Extracted from ConsoleWindowSystem as part of Phase 3.1 refactoring. Consolidates duplicate geometry logic from multiple classes.
public static class GeometryHelpers
- Inheritance
-
GeometryHelpers
- Inherited Members
Methods
CalculateExposedRegions(Rectangle, Rectangle)
Calculates regions that were covered by oldBounds but are not covered by newBounds.
public static List<Rectangle> CalculateExposedRegions(Rectangle oldBounds, Rectangle newBounds)
Parameters
Returns
CalculateUncoveredRegions(Rectangle, List<Window>)
Calculates which parts of a region are not covered by a list of windows.
public static List<Rectangle> CalculateUncoveredRegions(Rectangle region, List<Window> coveringWindows)
Parameters
regionRectangleThe region to check.
coveringWindowsList<Window>The windows that may cover the region.
Returns
DoesRectangleIntersect(Rectangle, Rectangle)
Checks if two rectangles intersect.
public static bool DoesRectangleIntersect(Rectangle rect1, Rectangle rect2)
Parameters
Returns
- bool
True if the rectangles intersect; false otherwise.
DoesRectangleOverlapWindow(Rectangle, Window)
Checks if a rectangle overlaps with a window's bounds.
public static bool DoesRectangleOverlapWindow(Rectangle rect, Window window)
Parameters
Returns
- bool
True if the rectangle overlaps the window; false otherwise.
GetRectangleIntersection(Rectangle, Rectangle)
Calculates the intersection of two rectangles.
public static Rectangle GetRectangleIntersection(Rectangle rect1, Rectangle rect2)
Parameters
Returns
- Rectangle
The intersection rectangle, or Rectangle.Empty if no intersection.
OptimizeExposedRegions(List<Rectangle>)
Optimizes exposed regions by removing empty rectangles. Could be enhanced to merge adjacent rectangles.
public static List<Rectangle> OptimizeExposedRegions(List<Rectangle> regions)
Parameters
Returns
SubtractRectangleFromRegions(List<Rectangle>, Rectangle)
Subtracts a rectangle from a list of regions. Returns the parts of the regions that are not covered by the subtracted rectangle.
public static List<Rectangle> SubtractRectangleFromRegions(List<Rectangle> regions, Rectangle subtract)
Parameters
regionsList<Rectangle>The list of regions to subtract from.
subtractRectangleThe rectangle to subtract.
Returns
TranslateToAbsolute(Window, Point, int)
Translates a window-relative point to absolute screen coordinates.
public static (int absoluteLeft, int absoluteTop) TranslateToAbsolute(Window window, Point point, int desktopTopOffset)
Parameters
windowWindowThe window containing the point.
pointPointThe point in window-relative coordinates.
desktopTopOffsetintThe Y offset of the desktop (from status bars).
Returns
- (int absoluteLeft, int absoluteTop)
A tuple containing the absolute screen coordinates (absoluteLeft, absoluteTop).
TranslateToRelative(Window, Point?, int)
Translates an absolute screen point to window-relative coordinates.
public static Point TranslateToRelative(Window window, Point? point, int desktopTopOffset)
Parameters
windowWindowThe window to translate coordinates relative to.
pointPoint?The point in absolute screen coordinates, or null.
desktopTopOffsetintThe Y offset of the desktop (from status bars).
Returns
- Point
The point in window-relative coordinates. Returns (0,0) if point is null.