Exemplo n.º 1
0
 public void NavigateUserToMenuResult(MenuUser user, IMenuResult menu)
 {
     if (menu.receivingMenu != null)
     {
         user.currentMenu = menu.receivingMenu;
         user.DisplayCurrentMenu();
     }
     else
     {
         NavigateUserToMainMenu(user);
     }
 }
Exemplo n.º 2
0
        /// <summary>
        /// Executes action provided by the menu.
        /// </summary>
        /// <param name="user">User for which to apply the action to.</param>
        /// <param name="msg">Message to to pass to menu action.</param>
        /// <returns>True or false depending on whether the action successfully executed.</returns>
        public bool ExecuteMenuActionFor(MenuUser user, IMessage msg)
        {
            if (!(user.currentMenu is IMenuAction))
            {
                return(false);
            }
            var action = (IMenuAction)user.currentMenu;

            // Process input using menu's method
            // Queue message returned from action menu
            try
            {
                user.QueueMessage(action.Execute(msg));
            }
            catch (Exception e)
            {
                PrettyPrint.WriteLine("Unable to execute action:\n" + e.Message + '\n' + e.StackTrace, ConsoleColor.Red);
                return(false);
            }
            return(true);
        }
Exemplo n.º 3
0
        public void EnterMenu(MenuBase menu, IUser user)
        {
            try
            {
                if (UserInMenu(user))
                {
                    _users.TryGetValue(user.Id, out var usermenu);
                    usermenu?.Dispose();
                }
            }
            catch (Exception e)
            {
                PrettyPrint.WriteLine(e.Message);
            }

            // Initialize Menu and Display to User
            var menuUser = new MenuUser(user, menu, _users);

            _users.Add(user.Id, menuUser);

            menuUser.DisplayCurrentMenu();
        }
Exemplo n.º 4
0
 /// <summary>
 /// Returns specified user to the module's main menu.
 /// </summary>
 /// <param name="user">Desired user to move back to main menu.</param>
 public void NavigateUserToMainMenu(MenuUser user)
 {
     user.currentMenu = user.mainMenu;
     user.DisplayCurrentMenu();
 }