コード例 #1
0
ファイル: Program.cs プロジェクト: alp2003/CSharpCourse
        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();
        }
コード例 #2
0
        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;
        }
コード例 #3
0
        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();
        }
コード例 #4
0
        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();
        }
コード例 #5
0
ファイル: UserInteraction.cs プロジェクト: OrShilon/Menus
        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();
                }
            }
        }
コード例 #6
0
ファイル: UserInteraction.cs プロジェクト: OrShilon/Menus
        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);
        }
コード例 #7
0
ファイル: UserInteraction.cs プロジェクト: OrShilon/Menus
        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);
        }
コード例 #8
0
        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;
        }
コード例 #9
0
 public override int?Select(int i_Level, ref SubMenu i_SubMenu)
 {
     m_Function.Invoke();
     return(null);
 }
コード例 #10
0
 public MenuItemAction(string i_ItemName, SubMenu i_PreviousMenu, IMenuItemAction i_MenuItemAction)
     : base(i_ItemName, i_PreviousMenu)
 {
     m_MenuItemaction = i_MenuItemAction;
 }
コード例 #11
0
 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;
 }
コード例 #12
0
ファイル: MainMenu.cs プロジェクト: OrShilon/Menus
 public MainMenu(string i_MenuTitle)
 {
     m_ListOfMenuNodes = new SubMenu(i_MenuTitle);
 }
コード例 #13
0
 public MainMenu()
 {
     m_Menu = new SubMenu("MainMenu", null);
 }
コード例 #14
0
 public FinalButton(string o_Name, SubMenu o_Parent, IActionButtonListener i_Listener) : base(o_Name, o_Parent)
 {
     r_ActionListener = i_Listener;
 }
コード例 #15
0
ファイル: MenuItem.cs プロジェクト: omerha/csharp4
 public MenuItem(string i_ItemText, SubMenu i_PreviousMenu)
 {
     m_ItemText     = i_ItemText;
     m_PreviousMenu = i_PreviousMenu;
 }
コード例 #16
0
 public SubMenu(string o_Name, SubMenu o_Parent) : base(o_Name, o_Parent)
 {
 }
コード例 #17
0
 // Constructor for MainMenu
 public MainMenu()
 {
     this.r_MainMenuList = new SubMenu("Main Menu");
 }
コード例 #18
0
 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";
 }
コード例 #20
0
ファイル: MainMenu.cs プロジェクト: omerha/csharp4
 public MainMenu(int i_Level, string i_ItemName, SubMenu i_PreviousMenu, List <MenuItem> i_MenuItems)
     : base(i_Level, i_ItemName, i_PreviousMenu, i_MenuItems)
 {
 }
コード例 #21
0
 public override int?Select(int i_Level, ref SubMenu i_SubMenu)
 {
     i_SubMenu = this;
     return(ShowMenuAndGetSelectionUser(i_Level));
 }