/// <summary>
        /// Prints out the page and polls the user for a menu choice.
        /// </summary>
        // abuse of next and previous options could lead to a lot of method calls on the stack,
        // but should be okay since the speed of calls are limited to user inputs.
        internal char Prompt()
        {
            Print();
            while (true)
            {
                char key = Console.ReadKey(true).KeyChar;

                if (key == 'n' && next != null)
                {
                    next.Prompt();
                    return(key);
                }
                if (key == 'p' && previous != null)
                {
                    previous.Prompt();
                    return(key);
                }
                int val = (int)Char.GetNumericValue(key);
                if (val >= 0 && val < entries.Count())
                {
                    entries[val].PerformAction();
                    return(key);
                }
            }
        }
Exemplo n.º 2
0
 /// <summary>
 /// Call to display the menu and let the user pick one of the options.
 /// </summary>
 /// <returns>the users choice for more advanced usage</returns>
 public char Prompt()
 {
     return(headEntry.Prompt());
 }