Class MenuItemBuilder
- Namespace
- SharpConsoleUI.Builders
- Assembly
- SharpConsoleUI.dll
Fluent builder for creating MenuItem instances with a hierarchical structure.
public class MenuItemBuilder
- Inheritance
-
MenuItemBuilder
- Inherited Members
Constructors
MenuItemBuilder(string)
Initializes a new MenuItemBuilder with the specified text.
public MenuItemBuilder(string text)
Parameters
textstringThe text to display for this menu item.
Methods
AddItem(string, Action)
Adds a child menu item with text and action.
public MenuItemBuilder AddItem(string text, Action action)
Parameters
textstringThe text to display for the child item.
actionActionThe action to execute when selected.
Returns
AddItem(string, Action, Color)
Adds a child menu item with text, action, and custom foreground color.
public MenuItemBuilder AddItem(string text, Action action, Color foregroundColor)
Parameters
textstringThe text to display for the child item.
actionActionThe action to execute when selected.
foregroundColorColorThe custom foreground color for this item.
Returns
AddItem(string, Action<MenuItemBuilder>)
Adds a child menu item with nested subitems using a configuration action.
public MenuItemBuilder AddItem(string text, Action<MenuItemBuilder> configure)
Parameters
textstringThe text to display for the child item.
configureAction<MenuItemBuilder>Action to configure the child item's submenu.
Returns
AddItem(string, string, Action)
Adds a child menu item with text, shortcut, and action.
public MenuItemBuilder AddItem(string text, string shortcut, Action action)
Parameters
textstringThe text to display for the child item.
shortcutstringThe keyboard shortcut text (display only).
actionActionThe action to execute when selected.
Returns
AddItem(string, string, Action, Color)
Adds a child menu item with text, shortcut, action, and custom foreground color.
public MenuItemBuilder AddItem(string text, string shortcut, Action action, Color foregroundColor)
Parameters
textstringThe text to display for the child item.
shortcutstringThe keyboard shortcut text (display only).
actionActionThe action to execute when selected.
foregroundColorColorThe custom foreground color for this item.
Returns
AddSeparator()
Adds a separator line to the submenu.
public MenuItemBuilder AddSeparator()
Returns
Disabled()
Marks this menu item as disabled.
public MenuItemBuilder Disabled()
Returns
WithAction(Action)
Sets the action to execute when this menu item is selected.
public MenuItemBuilder WithAction(Action action)
Parameters
actionActionThe action to execute.
Returns
WithForegroundColor(Color)
Sets a custom foreground color for this menu item.
public MenuItemBuilder WithForegroundColor(Color color)
Parameters
colorColorThe foreground color to use.
Returns
WithShortcut(string)
Sets the keyboard shortcut text for this menu item (display only).
public MenuItemBuilder WithShortcut(string shortcut)
Parameters
shortcutstringThe shortcut text to display (e.g., "Ctrl+S").
Returns
WithTag(object)
Sets user-defined data associated with this menu item.
public MenuItemBuilder WithTag(object tag)
Parameters
tagobjectThe user data to associate.