Ejemplo n.º 1
0
        public MenuEvent GetMenuSelection()
        {
            ConsoleKeyInfo cki = System.Console.ReadKey(true);

            // special case, allow navigate back using backspace.
            if (cki.Key == ConsoleKey.Backspace)
            {
                return(MenuEvent.Back);
            }

            int selection = (int)MenuEvent.Invalid;

            Int32.TryParse(cki.KeyChar.ToString(), out selection);

            if (selection != (int)MenuEvent.Invalid)
            {
                if (selection >= _currentMenu.GetListIndex(_currentMenu.GetItems().First()) &&
                    selection <= _currentMenu.GetListIndex(_currentMenu.GetItems().Last()))
                {
                    return((MenuEvent)_currentMenu.GetItemId(selection));
                }
            }

            return(MenuEvent.Invalid);
        }
Ejemplo n.º 2
0
        ///<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);
                }
            }
        }