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); }
public void AddMenuRow(MenuRow row) { MenuRows.Add(row); if (row.Menu != null) { AddChild(row.Menu); } Dictionary[GetRowKey(MenuRows.Count)] = row; }