C# Class ConsoleMenu.CMenu

A console menu structure, comprised of various menu items. To create a menu which displays the current time: var menu = new CMenu (); menu.Add ("time", s => Console.WriteLine (DateTime.UtcNow)); menu.Run ();
Inheritance: CMenuItem
Mostrar archivo Open project: nerai/CMenu Class Usage Examples

Public Properties

Property Type Description
ImmediateMenuMode bool
PromptCharacter string

Public Methods

Method Description
CMenu ( string selector = null, bool addDefaultItems = true ) : System

Create a new CMenu.

Iff no selector was specified, the menu will initially contain the following commands: help quit

Execute ( string arg ) : void

If this item gets selected in its parent menu, run it as a menu itself.

Quit ( ) : void

Stops menu processing. Control will return to the parent menu.

Processing can be restarted by calling Run again.

Run ( ) : void

Start console prompting and processing.

Immediately before processing begins, the event OnRun is called. Immediately after processing has ended, the event OnQuit called.

Method Details

CMenu() public method

Create a new CMenu.

Iff no selector was specified, the menu will initially contain the following commands: help quit

public CMenu ( string selector = null, bool addDefaultItems = true ) : System
selector string
addDefaultItems bool
return System

Execute() public method

If this item gets selected in its parent menu, run it as a menu itself.
public Execute ( string arg ) : void
arg string /// If an additional nonnull, nonwhitespace argument is given, it will be executed /// in the local menu context immediately. ///
return void

Quit() public method

Stops menu processing. Control will return to the parent menu.

Processing can be restarted by calling Run again.

public Quit ( ) : void
return void

Run() public method

Start console prompting and processing.

Immediately before processing begins, the event OnRun is called. Immediately after processing has ended, the event OnQuit called.

public Run ( ) : void
return void

Property Details

ImmediateMenuMode public_oe property

In immediate mode, instead of typing the name of a command, only a number associated with each command is entered. All available commands and their numbers will be displayed at any opportunity.
public bool ImmediateMenuMode
return bool

PromptCharacter public_oe property

The string which is displayed in front of every prompt (i.e. query for user input).

Set to null if no prompt should be displayed.

public string PromptCharacter
return string