示例#1
0
        protected void UserActions()
        {
            bool leaveMenu = false;

            do
            {
                char key = Console.ReadKey(intercept: true).KeyChar;
                if (leaveMenu = Dictionary.ContainsKey(key))
                {
                    MenuRow menuRow = Dictionary[key];
                    //A menuRow either contains an action or a new Menu
                    if (menuRow.Action != null)
                    {
                        menuRow.Action();
                        Console.WriteLine("Press any key to continue");
                        Console.ReadKey(intercept: true);
                    }
                    else
                    {
                        OnLeaveMenu(this, menuRow.Menu);
                    }
                }
                else
                {
                    Console.WriteLine($"Key '{key}' is not an option");
                }
            } while (!leaveMenu);
        }
示例#2
0
 public void AddMenuRow(MenuRow row)
 {
     MenuRows.Add(row);
     if (row.Menu != null)
     {
         AddChild(row.Menu);
     }
     Dictionary[GetRowKey(MenuRows.Count)] = row;
 }