Class Renderer
- Namespace
- SharpConsoleUI
- Assembly
- SharpConsoleUI.dll
Handles rendering of windows and their content to the console display. Manages window borders, scrollbars, and content rendering with support for overlapping windows.
public class Renderer
- Inheritance
-
Renderer
- Inherited Members
Constructors
Renderer(ConsoleWindowSystem)
Initializes a new instance of the Renderer class.
public Renderer(ConsoleWindowSystem consoleWindowSystem)
Parameters
consoleWindowSystemConsoleWindowSystemThe console window system that owns this renderer.
Methods
ClearArea(int, int, int, int, ITheme, IReadOnlyDictionary<string, Window>)
Clears a rectangular area with the desktop background.
public void ClearArea(int left, int top, int width, int height, ITheme theme, IReadOnlyDictionary<string, Window> windows)
Parameters
leftintThe left coordinate.
topintThe top coordinate.
widthintThe width of the area.
heightintThe height of the area.
themeIThemeThe theme to use for background colors.
windowsIReadOnlyDictionary<string, Window>The collection of windows to invalidate if they overlap.
FillDesktopBackground(ITheme, int, int)
Fills the entire desktop area with the theme's background character and colors. Used for initializing the desktop background.
public void FillDesktopBackground(ITheme theme, int screenWidth, int screenHeight)
Parameters
themeIThemeThe theme to use for desktop colors.
screenWidthintThe width of the screen.
screenHeightintThe height of the screen.
FillRect(int, int, int, int, char, Color?, Color?)
Fills a rectangular area with a specified character and colors.
public void FillRect(int left, int top, int width, int height, char character, Color? backgroundColor, Color? foregroundColor)
Parameters
leftintThe left coordinate of the rectangle.
topintThe top coordinate of the rectangle.
widthintThe width of the rectangle.
heightintThe height of the rectangle.
charactercharThe character to fill the rectangle with.
backgroundColorColor?The background color, or null to use the default.
foregroundColorColor?The foreground color, or null to use the default.
GetOverlappingRegions(Window, Window)
Gets the rectangular regions where two windows overlap.
public List<Rectangle> GetOverlappingRegions(Window window1, Window window2)
Parameters
Returns
- List<Rectangle>
A list of rectangles representing the overlapping areas. Empty if windows do not overlap.
GetOverlappingWindows(Window, HashSet<Window>?)
Gets all windows that overlap with the specified window using iterative BFS. This avoids unbounded recursion and is more efficient than the recursive approach.
public HashSet<Window> GetOverlappingWindows(Window window, HashSet<Window>? visited = null)
Parameters
windowWindowThe window to check for overlaps.
visitedHashSet<Window>Optional set of already visited windows (ignored, kept for compatibility).
Returns
IsOverlapping(Window, Window)
Determines whether two windows overlap each other.
public bool IsOverlapping(Window window1, Window window2)
Parameters
Returns
- bool
True if the windows overlap; otherwise, false.
RenderRegion(Window, Rectangle)
Renders a specific region of a window. Used for partial window updates.
public void RenderRegion(Window window, Rectangle region)
Parameters
RenderWindow(Window)
Renders a complete window including borders, content, and scrollbars. Handles visibility calculations for overlapping windows.
public void RenderWindow(Window window)
Parameters
windowWindowThe window to render.