Class ButtonBuilder
- Namespace
- SharpConsoleUI.Builders
- Assembly
- SharpConsoleUI.dll
Fluent builder for button controls
public sealed class ButtonBuilder : IControlBuilder<ButtonControl>
- Inheritance
-
ButtonBuilder
- Implements
- Inherited Members
- Extension Methods
Methods
Build()
Builds the button control
public ButtonControl Build()
Returns
- ButtonControl
The configured button control
Centered()
Centers the button
public ButtonBuilder Centered()
Returns
- ButtonBuilder
The builder for chaining
Disabled()
Disables the button
public ButtonBuilder Disabled()
Returns
- ButtonBuilder
The builder for chaining
Enabled(bool)
Sets the enabled state
public ButtonBuilder Enabled(bool enabled = true)
Parameters
enabledboolWhether the button is enabled
Returns
- ButtonBuilder
The builder for chaining
OnClick(WindowEventHandler<ButtonControl>)
Sets the click event handler with window access
public ButtonBuilder OnClick(WindowEventHandler<ButtonControl> handler)
Parameters
handlerWindowEventHandler<ButtonControl>Handler that receives sender, event data, and window
Returns
- ButtonBuilder
The builder for chaining
OnClick(EventHandler<ButtonControl>)
Sets the click event handler
public ButtonBuilder OnClick(EventHandler<ButtonControl> handler)
Parameters
handlerEventHandler<ButtonControl>The click handler
Returns
- ButtonBuilder
The builder for chaining
OnGotFocus(WindowEventHandler<EventArgs>)
Sets the GotFocus event handler with window access
public ButtonBuilder OnGotFocus(WindowEventHandler<EventArgs> handler)
Parameters
handlerWindowEventHandler<EventArgs>Handler that receives sender, event data, and window
Returns
- ButtonBuilder
The builder for chaining
OnGotFocus(EventHandler)
Sets the GotFocus event handler
public ButtonBuilder OnGotFocus(EventHandler handler)
Parameters
handlerEventHandlerThe event handler to invoke when the button receives focus
Returns
- ButtonBuilder
The builder for chaining
OnLostFocus(WindowEventHandler<EventArgs>)
Sets the LostFocus event handler with window access
public ButtonBuilder OnLostFocus(WindowEventHandler<EventArgs> handler)
Parameters
handlerWindowEventHandler<EventArgs>Handler that receives sender, event data, and window
Returns
- ButtonBuilder
The builder for chaining
OnLostFocus(EventHandler)
Sets the LostFocus event handler
public ButtonBuilder OnLostFocus(EventHandler handler)
Parameters
handlerEventHandlerThe event handler to invoke when the button loses focus
Returns
- ButtonBuilder
The builder for chaining
StickyBottom()
Makes the control stick to the bottom of the window
public ButtonBuilder StickyBottom()
Returns
- ButtonBuilder
The builder for chaining
StickyTop()
Makes the control stick to the top of the window
public ButtonBuilder StickyTop()
Returns
- ButtonBuilder
The builder for chaining
Visible(bool)
Sets the visibility
public ButtonBuilder Visible(bool visible = true)
Parameters
visibleboolWhether the button is visible
Returns
- ButtonBuilder
The builder for chaining
WithAlignment(HorizontalAlignment)
Sets the button alignment
public ButtonBuilder WithAlignment(HorizontalAlignment alignment)
Parameters
alignmentHorizontalAlignmentThe alignment
Returns
- ButtonBuilder
The builder for chaining
WithBackgroundColor(Color)
Sets the normal-state background color
public ButtonBuilder WithBackgroundColor(Color color)
Parameters
colorColorThe background color
Returns
- ButtonBuilder
The builder for chaining
WithBorder(ButtonBorderStyle)
Sets the button border style
public ButtonBuilder WithBorder(ButtonBorderStyle style)
Parameters
styleButtonBorderStyleThe border style
Returns
- ButtonBuilder
The builder for chaining
WithBorderBackgroundColor(Color)
Sets the background color for border cells. When null, uses the button's background color.
public ButtonBuilder WithBorderBackgroundColor(Color color)
Parameters
colorColor
Returns
WithBorderColor(Color)
public ButtonBuilder WithBorderColor(Color color)
Parameters
colorColor
Returns
WithColors(Color, Color)
public ButtonBuilder WithColors(Color foregroundColor, Color backgroundColor)
Parameters
Returns
WithDisabledBackgroundColor(Color)
Sets the disabled-state background color
public ButtonBuilder WithDisabledBackgroundColor(Color color)
Parameters
colorColorThe background color when disabled
Returns
- ButtonBuilder
The builder for chaining
WithDisabledForegroundColor(Color)
Sets the disabled-state foreground color
public ButtonBuilder WithDisabledForegroundColor(Color color)
Parameters
colorColorThe foreground color when disabled
Returns
- ButtonBuilder
The builder for chaining
WithFocusedBackgroundColor(Color)
Sets the focused-state background color
public ButtonBuilder WithFocusedBackgroundColor(Color color)
Parameters
colorColorThe background color when focused
Returns
- ButtonBuilder
The builder for chaining
WithFocusedColors(Color, Color)
Sets both focused-state foreground and background colors
public ButtonBuilder WithFocusedColors(Color foregroundColor, Color backgroundColor)
Parameters
foregroundColorColorThe foreground color when focused
backgroundColorColorThe background color when focused
Returns
- ButtonBuilder
The builder for chaining
WithFocusedForegroundColor(Color)
Sets the focused-state foreground color
public ButtonBuilder WithFocusedForegroundColor(Color color)
Parameters
colorColorThe foreground color when focused
Returns
- ButtonBuilder
The builder for chaining
WithForegroundColor(Color)
Sets the normal-state foreground color
public ButtonBuilder WithForegroundColor(Color color)
Parameters
colorColorThe foreground color
Returns
- ButtonBuilder
The builder for chaining
WithMargin(int)
Sets uniform margin
public ButtonBuilder WithMargin(int margin)
Parameters
marginintThe margin value for all sides
Returns
- ButtonBuilder
The builder for chaining
WithMargin(int, int, int, int)
Sets the button margin
public ButtonBuilder WithMargin(int left, int top, int right, int bottom)
Parameters
Returns
- ButtonBuilder
The builder for chaining
WithName(string)
Sets the control name for lookup
public ButtonBuilder WithName(string name)
Parameters
namestringThe control name
Returns
- ButtonBuilder
The builder for chaining
WithStickyPosition(StickyPosition)
Sets the sticky position
public ButtonBuilder WithStickyPosition(StickyPosition position)
Parameters
positionStickyPositionThe sticky position
Returns
- ButtonBuilder
The builder for chaining
WithTag(object)
Sets a tag object
public ButtonBuilder WithTag(object tag)
Parameters
tagobjectThe tag object
Returns
- ButtonBuilder
The builder for chaining
WithText(string)
Sets the button text
public ButtonBuilder WithText(string text)
Parameters
textstringThe button text
Returns
- ButtonBuilder
The builder for chaining
WithVerticalAlignment(VerticalAlignment)
Sets the vertical alignment
public ButtonBuilder WithVerticalAlignment(VerticalAlignment alignment)
Parameters
alignmentVerticalAlignmentThe vertical alignment
Returns
- ButtonBuilder
The builder for chaining
WithWidth(int)
Sets the button width
public ButtonBuilder WithWidth(int width)
Parameters
widthintThe button width
Returns
- ButtonBuilder
The builder for chaining
Operators
implicit operator ButtonControl(ButtonBuilder)
Implicit conversion to ButtonControl
public static implicit operator ButtonControl(ButtonBuilder builder)
Parameters
builderButtonBuilderThe builder
Returns
- ButtonControl
The built button control