public void DrawMenu(ConsoleMenu menu) { ConsoleMenu test = menu; int depth = 0; while (test.InSubMenu) { test = test.MenuItems[test.CursorIndex]; depth++; } for (int i = 0; i < menu.MenuItems.Count; i++) { for (int j = 0; j <= depth; j++) { int offset = 0; if (j != 0) offset = menu.GetMenuAtDepth(j - 1).CursorIndex; ConsoleMenu currentMenu = menu.GetMenuAtDepth(j); int maxLength = currentMenu.MenuItems.Max(x => x.Heading.Length); ConsoleMenu item = currentMenu.MenuItems[i - offset]; if (currentMenu.CursorIndex == i - offset) MenuPanel.Write(String.Format(" > {0," + maxLength + "}", item.Heading), ConsoleColor.Cyan); else MenuPanel.Write(String.Format(" {0," + maxLength + "}", item.Heading), ConsoleColor.Gray); } MenuPanel.Write("\n", ConsoleColor.Blue); } Flush(); }
public void DrawMainMenu() { ConsoleMenu menu = new ConsoleMenu(); }
public void InventoryTest() { Display = new DecayDisplay(); ConsoleMenu menu = new ConsoleMenu(); menu.MenuItems.Add(new ConsoleMenu() { Heading = "Item 1" }); ConsoleMenu menu2 = new ConsoleMenu() { Heading = "Item 2", MenuType = MenuItemType.Menu }; menu2.MenuItems.Add(new ConsoleMenu() { Heading = "Item 2.1" }); menu2.MenuItems.Add(new ConsoleMenu() { Heading = "Item 2.2" }); menu2.MenuItems.Add(new ConsoleMenu() { Heading = "Item 2.3" }); menu.MenuItems.Add(menu2); menu.MenuItems.Add(new ConsoleMenu() { Heading = "Item 3" }); do { Console.Clear(); Display.DrawMenu(menu); } while (menu.Process() == false); BaseAction action = menu.GetUserAction(); }