Example #1
0
    /// <summary>
    /// Initializes a new instance of the <see cref="ConsoleMenu"/> class
    /// with possibility to pre-select items via console parameter.
    /// </summary>
    /// <param name="args">args collection from Main.</param>
    /// <param name="level">Level of whole menu.</param>
    public ConsoleMenu(string[] args, int level)
    {
        if (args == null)
        {
            throw new ArgumentNullException(nameof(args));
        }

        if (level < 0)
        {
            throw new ArgumentException("Cannot be below 0", nameof(level));
        }

        this.menuItems    = new ItemsCollection(args, level);
        this.closeTrigger = new CloseTrigger();
    }
 public ConsoleMenuDisplay(
     ItemsCollection menuItems,
     IConsole console,
     List <string> titles,
     MenuConfig config,
     CloseTrigger closeTrigger)
 {
     this.menuItems      = menuItems;
     this.console        = console;
     this.titles         = titles;
     this.config         = config;
     this.visibility     = new VisibilityManager(menuItems.Items.Count);
     this.closeTrigger   = closeTrigger;
     this.noSelectorLine = new string(' ', this.config.Selector.Length);
 }
Example #3
0
 /// <summary>
 /// Initializes a new instance of the <see cref="ConsoleMenu"/> class.
 /// </summary>
 public ConsoleMenu()
 {
     this.menuItems    = new ItemsCollection();
     this.closeTrigger = new CloseTrigger();
 }