Class RadioBuilder<T>
- Namespace
- SharpConsoleUI.Builders
- Assembly
- SharpConsoleUI.dll
Fluent builder for RadioControl<T>.
public sealed class RadioBuilder<T> : IControlBuilder<RadioControl<T>>
Type Parameters
TThe value type this radio represents.
- Inheritance
-
RadioBuilder<T>
- Implements
- Inherited Members
- Extension Methods
Constructors
RadioBuilder(RadioGroup<T>, T, string)
Initializes a new RadioBuilder<T> for the given group and value.
public RadioBuilder(RadioGroup<T> group, T value, string label = "")
Parameters
groupRadioGroup<T>The coordinating group.
valueTThe value this radio represents.
labelstringThe text label displayed next to the radio.
Methods
Build()
Builds and returns a configured RadioControl<T>.
public RadioControl<T> Build()
Returns
- RadioControl<T>
Outline(bool)
Renders the radio in outline style (role colour on text, surface fill).
public RadioBuilder<T> Outline(bool outline = true)
Parameters
outlineboolWhether to use outline style.
Returns
- RadioBuilder<T>
The builder for chaining.
Selected()
Marks this radio as the initially selected option. In Build(), the group's SelectedValue is set to this radio's value.
public RadioBuilder<T> Selected()
Returns
- RadioBuilder<T>
The builder for chaining.
WithAlignment(HorizontalAlignment)
Sets the horizontal alignment of the radio within its allocated space.
public RadioBuilder<T> WithAlignment(HorizontalAlignment alignment)
Parameters
alignmentHorizontalAlignmentThe horizontal alignment.
Returns
- RadioBuilder<T>
The builder for chaining.
WithColorRole(ColorRole, ThemeMode?)
Sets the control's semantic colour role.
public RadioBuilder<T> WithColorRole(ColorRole role, ThemeMode? mode = null)
Parameters
roleColorRoleThe semantic role determining the radio's colours.
modeThemeMode?Optional ThemeMode override. When null, the active theme's mode is used.
Returns
- RadioBuilder<T>
The builder for chaining.
WithLabel(string)
Sets the label text displayed next to the radio.
public RadioBuilder<T> WithLabel(string label)
Parameters
labelstringThe label text.
Returns
- RadioBuilder<T>
The builder for chaining.
WithMargin(int)
Sets a uniform margin on all sides.
public RadioBuilder<T> WithMargin(int margin)
Parameters
marginintThe margin value.
Returns
- RadioBuilder<T>
The builder for chaining.
WithMargin(int, int, int, int)
Sets the margin around the control.
public RadioBuilder<T> WithMargin(int left, int top, int right, int bottom)
Parameters
Returns
- RadioBuilder<T>
The builder for chaining.
WithName(string)
Sets the control name for programmatic lookup.
public RadioBuilder<T> WithName(string name)
Parameters
namestringThe control name.
Returns
- RadioBuilder<T>
The builder for chaining.
WithSelectedCharacter(string)
Sets the character displayed when this radio is selected (default "●").
public RadioBuilder<T> WithSelectedCharacter(string character)
Parameters
characterstringThe selected character.
Returns
- RadioBuilder<T>
The builder for chaining.
WithUnselectedCharacter(string)
Sets the character displayed when this radio is unselected (default "○").
public RadioBuilder<T> WithUnselectedCharacter(string character)
Parameters
characterstringThe unselected character.
Returns
- RadioBuilder<T>
The builder for chaining.
WithVerticalAlignment(VerticalAlignment)
Sets the vertical alignment of the radio within its allocated space.
public RadioBuilder<T> WithVerticalAlignment(VerticalAlignment alignment)
Parameters
alignmentVerticalAlignmentThe vertical alignment.
Returns
- RadioBuilder<T>
The builder for chaining.
Wrap(bool)
Enables or disables label wrapping across lines.
public RadioBuilder<T> Wrap(bool wrap = true)
Parameters
wrapboolWhether to wrap the label.
Returns
- RadioBuilder<T>
The builder for chaining.
Operators
implicit operator RadioControl<T>(RadioBuilder<T>)
Implicit conversion to RadioControl<T>.
public static implicit operator RadioControl<T>(RadioBuilder<T> builder)
Parameters
builderRadioBuilder<T>
Returns
- RadioControl<T>