Class CanvasControlBuilder
- Namespace
- SharpConsoleUI.Builders
- Assembly
- SharpConsoleUI.dll
Fluent builder for creating CanvasControl instances.
public sealed class CanvasControlBuilder : IControlBuilder<CanvasControl>
- Inheritance
-
CanvasControlBuilder
- Implements
- Inherited Members
- Extension Methods
Methods
AutoClear(bool)
Enables auto-clear mode where the buffer is cleared each frame.
public CanvasControlBuilder AutoClear(bool autoClear = true)
Parameters
autoClearbool
Returns
AutoSize(bool)
Enables auto-size mode where the canvas resizes to match layout bounds.
public CanvasControlBuilder AutoSize(bool autoSize = true)
Parameters
autoSizebool
Returns
Build()
Builds the CanvasControl instance.
public CanvasControl Build()
Returns
Enabled(bool)
Sets whether the control is enabled.
public CanvasControlBuilder Enabled(bool enabled = true)
Parameters
enabledbool
Returns
OnGotFocus(EventHandler)
Sets the GotFocus event handler.
public CanvasControlBuilder OnGotFocus(EventHandler handler)
Parameters
handlerEventHandler
Returns
OnKeyPressed(EventHandler<ConsoleKeyInfo>)
Sets the key pressed event handler.
public CanvasControlBuilder OnKeyPressed(EventHandler<ConsoleKeyInfo> handler)
Parameters
handlerEventHandler<ConsoleKeyInfo>
Returns
OnLostFocus(EventHandler)
Sets the LostFocus event handler.
public CanvasControlBuilder OnLostFocus(EventHandler handler)
Parameters
handlerEventHandler
Returns
OnMouseClick(EventHandler<CanvasMouseEventArgs>)
Sets the mouse click event handler with canvas-local coordinates.
public CanvasControlBuilder OnMouseClick(EventHandler<CanvasMouseEventArgs> handler)
Parameters
handlerEventHandler<CanvasMouseEventArgs>
Returns
OnMouseMove(EventHandler<CanvasMouseEventArgs>)
Sets the mouse move event handler with canvas-local coordinates.
public CanvasControlBuilder OnMouseMove(EventHandler<CanvasMouseEventArgs> handler)
Parameters
handlerEventHandler<CanvasMouseEventArgs>
Returns
OnMouseRightClick(EventHandler<CanvasMouseEventArgs>)
Sets the mouse right-click event handler with canvas-local coordinates.
public CanvasControlBuilder OnMouseRightClick(EventHandler<CanvasMouseEventArgs> handler)
Parameters
handlerEventHandler<CanvasMouseEventArgs>
Returns
OnPaint(EventHandler<CanvasPaintEventArgs>)
Sets the Paint event handler fired during each render cycle.
public CanvasControlBuilder OnPaint(EventHandler<CanvasPaintEventArgs> handler)
Parameters
handlerEventHandler<CanvasPaintEventArgs>
Returns
StickyBottom()
Makes the control stick to the bottom of the window.
public CanvasControlBuilder StickyBottom()
Returns
StickyTop()
Makes the control stick to the top of the window.
public CanvasControlBuilder StickyTop()
Returns
Visible(bool)
Sets the visibility.
public CanvasControlBuilder Visible(bool visible = true)
Parameters
visiblebool
Returns
WithAlignment(HorizontalAlignment)
Sets the horizontal alignment.
public CanvasControlBuilder WithAlignment(HorizontalAlignment alignment)
Parameters
alignmentHorizontalAlignment
Returns
WithBackgroundColor(Color)
Sets the background color.
public CanvasControlBuilder WithBackgroundColor(Color color)
Parameters
colorColor
Returns
WithCanvasHeight(int)
Sets the canvas height in characters.
public CanvasControlBuilder WithCanvasHeight(int height)
Parameters
heightint
Returns
WithCanvasWidth(int)
Sets the canvas width in characters.
public CanvasControlBuilder WithCanvasWidth(int width)
Parameters
widthint
Returns
WithColors(Color, Color)
Sets both foreground and background colors.
public CanvasControlBuilder WithColors(Color foreground, Color background)
Parameters
Returns
WithForegroundColor(Color)
Sets the foreground color.
public CanvasControlBuilder WithForegroundColor(Color color)
Parameters
colorColor
Returns
WithMargin(int)
Sets uniform margin on all sides.
public CanvasControlBuilder WithMargin(int margin)
Parameters
marginint
Returns
WithMargin(int, int, int, int)
Sets the margin.
public CanvasControlBuilder WithMargin(int left, int top, int right, int bottom)
Parameters
Returns
WithName(string)
Sets the control name for lookup.
public CanvasControlBuilder WithName(string name)
Parameters
namestring
Returns
WithSize(int, int)
Sets the canvas size in characters.
public CanvasControlBuilder WithSize(int width, int height)
Parameters
Returns
WithStickyPosition(StickyPosition)
Sets the sticky position.
public CanvasControlBuilder WithStickyPosition(StickyPosition position)
Parameters
positionStickyPosition
Returns
WithTag(object)
Sets a tag object.
public CanvasControlBuilder WithTag(object tag)
Parameters
tagobject
Returns
WithVerticalAlignment(VerticalAlignment)
Sets the vertical alignment.
public CanvasControlBuilder WithVerticalAlignment(VerticalAlignment alignment)
Parameters
alignmentVerticalAlignment
Returns
Operators
implicit operator CanvasControl(CanvasControlBuilder)
Implicit conversion to CanvasControl.
public static implicit operator CanvasControl(CanvasControlBuilder builder)
Parameters
builderCanvasControlBuilder