Table of Contents

Class WindowPlacementService

Namespace
SharpConsoleUI.Core
Assembly
SharpConsoleUI.dll

Resolves a declarative Placement into concrete, absolute window bounds computed against the live usable desktop (the screen area excluding the top and bottom status bars).

public sealed class WindowPlacementService
Inheritance
WindowPlacementService
Inherited Members
Extension Methods

Remarks

The service holds a lazy Func<TResult> getter for the owning ConsoleWindowSystem rather than a direct reference, matching the constructor-order-safe wiring used by the other state services. Because geometry is read at Resolve(Placement) time, the same placement re-resolves correctly whenever the desktop size changes (e.g. on a terminal resize).

Constructors

WindowPlacementService(Func<ConsoleWindowSystem>)

Initializes a new instance of the WindowPlacementService class.

public WindowPlacementService(Func<ConsoleWindowSystem> getSystem)

Parameters

getSystem Func<ConsoleWindowSystem>

A lazy getter returning the owning console window system.

Methods

Resolve(Placement)

Resolves the given placement to absolute window bounds against the live usable desktop.

public Rectangle Resolve(Placement placement)

Parameters

placement Placement

The declarative placement to resolve.

Returns

Rectangle

A Rectangle in absolute screen coordinates. Zone/anchor math is computed in usable-desktop space (origin 0,0) and then offset vertically by DesktopUpperLeft.Y so the result sits below the top status bar. The width and height are always at least 1 and never exceed the usable desktop, and the origin is clamped so the window stays fully on-desktop.

Remarks

Zone math (usable desktop W×H, remainder of odd sizes goes to the LEFT/TOP):

  • Full → (0, 0, W, H)
  • LeftHalf → (0, 0, W/2 + W%2, H) — the wider side on odd widths is the left
  • RightHalf → (W/2 + W%2, 0, W/2, H)
  • TopHalf → (0, 0, W, H/2 + H%2) — the taller side on odd heights is the top
  • BottomHalf → (0, H/2 + H%2, W, H/2)
  • Quadrants combine the corresponding horizontal and vertical half splits.