Class ButtonBuilder
- Namespace
- SharpConsoleUI.Builders
- Assembly
- SharpConsoleUI.dll
Fluent builder for button controls
public sealed class ButtonBuilder
- Inheritance
-
ButtonBuilder
- Inherited Members
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
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