public Console() { // Build menu tree _baseMenu = new Menu("Menu - BoatClub", (int)MenuEvent.MainMenu, null); _baseMenu.Additem((int)MenuEvent.AddNewMember, "Add Member"); Menu memberListMenu = new Menu("Menu - Member Lists", (int)MenuEvent.MemberListMenu, "View Member List"); memberListMenu.Additem((int)MenuEvent.MemberListSimple, "Simple List"); memberListMenu.Additem((int)MenuEvent.MemberListComplete, "Complete List"); memberListMenu.Additem((int)MenuEvent.Back, "...Back"); _baseMenu.AddSubMenu(memberListMenu); Menu memberInfoMenu = new Menu("Menu - Member Information", (int)MenuEvent.MemberInfoMenu, "View Member Info"); memberInfoMenu.Additem((int)MenuEvent.EditMemberName, "Edit Name"); memberInfoMenu.Additem((int)MenuEvent.EditMemberPersonalNumber, "Edit Personal Number"); Menu manageBoatsMenu = new Menu("Menu - Manage Boats", (int)MenuEvent.ManageBoatsMenu, "Manage Boats"); manageBoatsMenu.Additem((int)MenuEvent.AddBoat, "Add Boat"); Menu editBoatMenu = new Menu("Menu - Edit Boat", (int)MenuEvent.EditBoatMenu, "Edit Boat"); editBoatMenu.Additem((int)MenuEvent.EditBoatModel, "Edit Model"); editBoatMenu.Additem((int)MenuEvent.EditBoatLength, "Edit Length"); editBoatMenu.Additem((int)MenuEvent.Back, "...Back"); manageBoatsMenu.AddSubMenu(editBoatMenu); manageBoatsMenu.Additem((int)MenuEvent.DeleteBoat, "Delete Boat"); manageBoatsMenu.Additem((int)MenuEvent.Back, "...Back"); memberInfoMenu.AddSubMenu(manageBoatsMenu); memberInfoMenu.Additem((int)MenuEvent.Back, "...Back"); _baseMenu.AddSubMenu(memberInfoMenu); _baseMenu.Additem((int)MenuEvent.DeleteMember, "Delete Member"); _baseMenu.Additem((int)MenuEvent.Exit, "Quit"); }
public void AddSubMenu(Menu menu) { _menu.Add(menu); }
///<summary> /// Show menu, supply member if member information /// should be shown above menu. /// </summary> public void ShowMenu(MenuEvent menuId, Model.Member member) { Menu menu = _baseMenu.GetSubMenu((int)menuId); // true Menu for menuId exists. if(menu != null) { _currentMenu = menu; System.Console.Clear(); if (member != null) { PrintHeader("Member Information"); PrintMemberInfo(member); System.Console.WriteLine(); } PrintHeader(menu.Header); foreach (View.MenuItem i in menu.GetItems()) { System.Console.WriteLine("{0}. {1}", menu.GetListIndex(i), i.Title); } } }