private static void runDelegateMenu() { const bool v_IsMainMenu = false; MethodsForMenusDelegates methodsForMenusDelegates = new MethodsForMenusDelegates(); MenuDelegates.MainMenu mainMenuDelegates = new MenuDelegates.MainMenu("Delegates Main Menu"); MenuDelegates.SubMenu subMenuDateAndTimeDelegate = new MenuDelegates.SubMenu("Show Date/Time", v_IsMainMenu); MenuDelegates.SubMenu subMenuVersionAndDigitsDelegate = new MenuDelegates.SubMenu("Version and Digits", v_IsMainMenu); MenuDelegates.MenuItemExecutable showDateDelegate = new MenuDelegates.MenuItemExecutable("Show Date"); showDateDelegate.MenuItemClicked += methodsForMenusDelegates.ShowDate; MenuDelegates.MenuItemExecutable showTimeDelegate = new MenuDelegates.MenuItemExecutable("Show Time"); showTimeDelegate.MenuItemClicked += methodsForMenusDelegates.ShowTime; MenuDelegates.MenuItemExecutable countDigitsDelegate = new MenuDelegates.MenuItemExecutable("Count Digits"); countDigitsDelegate.MenuItemClicked += methodsForMenusDelegates.CountDigits; MenuDelegates.MenuItemExecutable showVersionDelegate = new MenuDelegates.MenuItemExecutable("Show Version"); showVersionDelegate.MenuItemClicked += methodsForMenusDelegates.ShowVersion; subMenuDateAndTimeDelegate.AddItemToSubMenu(showDateDelegate); subMenuDateAndTimeDelegate.AddItemToSubMenu(showTimeDelegate); subMenuVersionAndDigitsDelegate.AddItemToSubMenu(countDigitsDelegate); subMenuVersionAndDigitsDelegate.AddItemToSubMenu(showVersionDelegate); mainMenuDelegates.AddMenuItemToMainMenu(subMenuDateAndTimeDelegate); mainMenuDelegates.AddMenuItemToMainMenu(subMenuVersionAndDigitsDelegate); mainMenuDelegates.Show(); }
public void Show() { int selection; SubMenu currentMenuItem = m_Menu; Console.Clear(); //selection = m_Menu.ShowMenuAndGetSelectionUser(m_Level); selection = (int)m_Menu.Select(m_Level, ref currentMenuItem); while (true) { Console.Clear(); //check for exit selection if (m_Level == 1 && selection == 0) { break; } //check for back selection if ((m_Level != 1 && selection == 0)) { m_Level--; currentMenuItem = (SubMenu)currentMenuItem.GetMenuItem(selection); } else { if (currentMenuItem.GetMenuItem(selection) is SubMenu) { currentMenuItem = (SubMenu)currentMenuItem.GetMenuItem(selection); if (selection == 0) { m_Level--; } else { m_Level++; } } else if (currentMenuItem.GetMenuItem(selection) is FunctionItem) { ((FunctionItem)currentMenuItem.GetMenuItem(selection)).Select(m_Level, ref currentMenuItem); } } selection = (int)((SubMenu)currentMenuItem).Select(m_Level, ref currentMenuItem); } Console.WriteLine("Bye bye"); Console.ReadLine(); }
public override void ActionWhenChoose() { Console.Clear(); int indexOfItemInMenu = MenuThatItemBelongsTo.MenuItems.IndexOf(this); string SubMenuName = string.Format("{0}. {1}", indexOfItemInMenu + 1, ItemName); SubMenu subMenuToDisplayWhenChoose = new SubMenu(SubMenuName, m_MenuItemsToShow) { ParentMenu = MenuThatItemBelongsTo }; subMenuToDisplayWhenChoose.Show(); }
public static void Show(SubMenu i_Menu) { int userChoice = -1; while (!userChoice.Equals(k_ExitOrBack)) { userChoice = UserInteraction.printManager(i_Menu); if (!userChoice.Equals(k_ExitOrBack)) { i_Menu.MenuNodes[userChoice - k_MenuOffset].OnClick(); } } }
private static void printMenu(SubMenu i_Menu) { int index = 1; Console.Clear(); Console.WriteLine(i_Menu.Title + Environment.NewLine); foreach (MenuNode item in i_Menu.MenuNodes) { Console.WriteLine("{0}. {1}", index, item.Title); index++; } Console.WriteLine("0. {0}", i_Menu.ParentMenu == null ? k_ExitMessage : k_BackMessage); Console.WriteLine("Please Choose the appropriate menu option, or 0 to {0}.", i_Menu.ParentMenu == null ? k_ExitMessage : k_BackToPreviousMenuMessage); }
private static int printManager(SubMenu i_Menu) { string userInput; int validInput; printMenu(i_Menu); userInput = Console.ReadLine(); while (!isValidMenuOption(userInput, i_Menu.MenuNodes.Count, out validInput)) { Console.WriteLine("Invalid Input. Return to menu options."); Thread.Sleep(2000); printMenu(i_Menu); userInput = Console.ReadLine(); } return(validInput); }
public override int?Select(int i_Level, ref SubMenu i_SubMenu) { i_SubMenu = this; return(ShowMenuAndGetSelectionUser(i_Level)); }
public FinalButton(string o_Name, SubMenu o_Parent) : base(o_Name, o_Parent) { }
public MainMenu(string i_MenuTitle) { m_ListOfMenuNodes = new SubMenu(i_MenuTitle); }
public SubMenu(string o_Name, SubMenu o_Parent) : base(o_Name, o_Parent) { }
public MainMenu() { m_Menu = new SubMenu("MainMenu", null); }
// Constructor for new main menu public MainMenu() { this.m_MainMenuList = new SubMenu("Main Menu"); }
public MainMenu(int i_Level, string i_ItemName, SubMenu i_PreviousMenu, List <MenuItem> i_MenuItems) : base(i_Level, i_ItemName, i_PreviousMenu, i_MenuItems) { }
/// <summary> /// This method adds a new sub menu to the current menu. /// </summary> /// <param name="i_menuTitle"> The new sub menu name.</param> public void AddMenuItemMenu(string i_menuTitle) { GeneralMenu newMenuItem = new SubMenu(i_menuTitle, this); m_menu.Add(newMenuItem); }
protected MenuItem(string i_MenuItemName, SubMenu i_ParentItem) { m_ItemText = i_MenuItemName; m_PreviousMenu = i_ParentItem; }
public override int?Select(int i_Level, ref SubMenu i_SubMenu) { m_SelectFunctionDelegate.Invoke(); return(null); }
public SubMenu(int i_Level, string i_ItemName, SubMenu i_PreviousMenu, List <MenuItem> i_MenuItems) : base(i_ItemName, i_PreviousMenu) { MenuItems = i_MenuItems; Level = i_Level; }
public MenuItemAction(string i_MenuItemName, SubMenu i_ParentItem) : base(i_MenuItemName, i_ParentItem) { }
public abstract int?Select(int i_Level, ref SubMenu i_SubMenu);
public MainMenu(string i_Titel) { m_SubMenuItem = new SubMenu(i_Titel); m_SubMenuItem.ListOfMenuItems[k_ExitOption].Title = "Exit"; }
public SubMenu(string i_Title, SubMenu i_PreviousMenu) : base(i_Title) { m_MainMenu = new MainMenu(i_Title); m_MainMenu.ChangeExitName(eBackType.Back.ToString()); }