Class PanelElement
- Namespace
- SharpConsoleUI.Panel
- Assembly
- SharpConsoleUI.dll
Abstract base class implementing IPanelElement with sensible defaults. Elements that don't need to inherit from something else should extend this.
public abstract class PanelElement : IPanelElement
- Inheritance
-
PanelElement
- Implements
- Derived
- Inherited Members
- Extension Methods
Constructors
PanelElement(string)
Initializes a new PanelElement with the given name.
protected PanelElement(string name)
Parameters
namestringThe unique name of this element.
Properties
FixedWidth
Gets the fixed width of this element, or null if it uses MeasureWidth() or flex sizing.
public virtual int? FixedWidth { get; }
Property Value
- int?
FlexGrow
Gets the flex grow factor. 0 = fixed sizing, >0 = flex proportional to other flex elements.
public virtual int FlexGrow { get; }
Property Value
MaxWidth
Gets the maximum width constraint for flex elements.
public virtual int? MaxWidth { get; }
Property Value
- int?
MinWidth
Gets the minimum width constraint for flex elements.
public virtual int? MinWidth { get; }
Property Value
- int?
Name
Gets the unique name of this element.
public string Name { get; }
Property Value
Owner
Gets the parent panel this element is attached to, or null if detached.
protected Panel? Owner { get; }
Property Value
Visible
Gets or sets whether this element is visible.
public bool Visible { get; set; }
Property Value
WindowSystem
Gets the console window system via the parent panel, or null if not attached.
protected ConsoleWindowSystem? WindowSystem { get; }
Property Value
Methods
Invalidate()
Notifies the parent panel that this element needs to be redrawn.
protected void Invalidate()
MeasureWidth()
Measures the natural content width of this element. Used when FixedWidth is null and FlexGrow is 0.
public virtual int MeasureWidth()
Returns
- int
The measured width in columns.
OnAttached(Panel)
Called when this element is added to a panel.
public void OnAttached(Panel panel)
Parameters
panelPanelThe parent panel.
OnDetached()
Called when this element is removed from a panel.
public void OnDetached()
ProcessMouseEvent(MouseEventArgs, int, int)
Processes a mouse event that occurred within this element's bounds.
public virtual bool ProcessMouseEvent(MouseEventArgs args, int elementX, int elementWidth)
Parameters
argsMouseEventArgsThe mouse event arguments.
elementXintThe x position of this element on screen.
elementWidthintThe allocated width of this element.
Returns
- bool
True if the event was handled.
Render(CharacterBuffer, int, int, int, Color, Color)
Renders the element into the character buffer at the specified position.
public abstract void Render(CharacterBuffer buffer, int x, int y, int width, Color fg, Color bg)