private static void runInterfaceMenu() { const bool v_IsMainMenu = false; MenuInterfaces.MainMenu mainMenuInterfaces = new MenuInterfaces.MainMenu("Interfaces Main Menu"); MenuInterfaces.SubMenu subMenuDateAndTimeInterface = new MenuInterfaces.SubMenu("Show Date/Time", v_IsMainMenu); MenuInterfaces.SubMenu subMenuVersionAndDigitsInterface = new MenuInterfaces.SubMenu("Version and Digits", v_IsMainMenu); MenuInterfaces.MenuItemExecutable showDateInterface = new MenuInterfaces.MenuItemExecutable("Show Date"); showDateInterface.AddListener(new ShowDate() as MenuInterfaces.IMenuClickListener); MenuInterfaces.MenuItemExecutable showTimeInterface = new MenuInterfaces.MenuItemExecutable("Show Time"); showTimeInterface.AddListener(new ShowTime() as MenuInterfaces.IMenuClickListener); MenuInterfaces.MenuItemExecutable countDigitsInterface = new MenuInterfaces.MenuItemExecutable("Count Digits"); countDigitsInterface.AddListener(new CountDigits() as MenuInterfaces.IMenuClickListener); MenuInterfaces.MenuItemExecutable showVersionInterface = new MenuInterfaces.MenuItemExecutable("Show Version"); showVersionInterface.AddListener(new ShowVersion() as MenuInterfaces.IMenuClickListener); subMenuDateAndTimeInterface.AddItemToSubMenu(showDateInterface); subMenuDateAndTimeInterface.AddItemToSubMenu(showTimeInterface); subMenuVersionAndDigitsInterface.AddItemToSubMenu(countDigitsInterface); subMenuVersionAndDigitsInterface.AddItemToSubMenu(showVersionInterface); mainMenuInterfaces.AddMenuItemToMainMenu(subMenuDateAndTimeInterface); mainMenuInterfaces.AddMenuItemToMainMenu(subMenuVersionAndDigitsInterface); mainMenuInterfaces.Show(); }
public MainMenu(string i_Title) { m_MainMenu = new SubMenu(i_Title); // replacing back of submenu for exit MenuItem exitOption = new ActionItem(sr_ExitName); exitOption.ItemIndex = sr_ExitIndex; m_MainMenu.MenuOptions[sr_ExitIndex] = exitOption; }
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 MainMenu(params MenuItem[] subMenues) { m_MenuExit = false; m_HierarchyStack = new Stack <MenuItem>(); m_Exit = new Button("Exit", this as IClickObserver); m_Back = new Button("Back", this as IClickObserver); m_Menu = new SubMenu("Menu Menu"); foreach (MenuItem menuItem in subMenues) { if (menuItem is SubMenu) { (menuItem as SubMenu).SetReturnMenu(m_Back); } m_Menu.AddAsSubMenu(menuItem); } m_Menu.SetReturnMenu(m_Exit); m_CurentChosenMenuItem = m_Menu; }
public override int?Select(int i_Level, ref SubMenu i_SubMenu) { m_Function.Invoke(); return(null); }
public MenuItemAction(string i_ItemName, SubMenu i_PreviousMenu, IMenuItemAction i_MenuItemAction) : base(i_ItemName, i_PreviousMenu) { m_MenuItemaction = i_MenuItemAction; }
public SubMenu(int i_Level, string i_ItemName, SubMenu i_PreviousMenu, List <MenuItem> i_MenuItems) : base(i_ItemName, i_PreviousMenu) { m_MenuItems = i_MenuItems; m_Level = i_Level; }
public MainMenu(string i_MenuTitle) { m_ListOfMenuNodes = new SubMenu(i_MenuTitle); }
public MainMenu() { m_Menu = new SubMenu("MainMenu", null); }
public FinalButton(string o_Name, SubMenu o_Parent, IActionButtonListener i_Listener) : base(o_Name, o_Parent) { r_ActionListener = i_Listener; }
public MenuItem(string i_ItemText, SubMenu i_PreviousMenu) { m_ItemText = i_ItemText; m_PreviousMenu = i_PreviousMenu; }
public SubMenu(string o_Name, SubMenu o_Parent) : base(o_Name, o_Parent) { }
// Constructor for MainMenu public MainMenu() { this.r_MainMenuList = new SubMenu("Main Menu"); }
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 MainMenu(int i_Level, string i_ItemName, SubMenu i_PreviousMenu, List <MenuItem> i_MenuItems) : base(i_Level, i_ItemName, i_PreviousMenu, i_MenuItems) { }
public override int?Select(int i_Level, ref SubMenu i_SubMenu) { i_SubMenu = this; return(ShowMenuAndGetSelectionUser(i_Level)); }