public static AppEnum.MenuOptions GetUserMenuOption()
        {
            DisplayReset();

            AppEnum.MenuOptions userMenuOption = AppEnum.MenuOptions.None;

            string leftTab = ConsoleUtil.FillStringWithSpaces(DISPLAY_HORIZONTAL_MARGIN);

            DisplayMessage("");
            Console.WriteLine(ConsoleUtil.Center("Main Menu", WINDOW_WIDTH));
            DisplayMessage("");

            Console.WriteLine(
                leftTab + "1. Display All Firearms" + Environment.NewLine +
                leftTab + "2. Display Firearm Info" + Environment.NewLine +
                leftTab + "3. Add a Firearm" + Environment.NewLine +
                leftTab + "4. Delete a Firearm" + Environment.NewLine +
                leftTab + "5. Update a Firearm" + Environment.NewLine +
                leftTab + "6. Query By ID" + Environment.NewLine +
                leftTab + "E. Exit" + Environment.NewLine);

            Console.WriteLine("");
            Console.WriteLine(ConsoleUtil.Center("Enter a menu option.", WINDOW_WIDTH));
            ConsoleKeyInfo userResponse = Console.ReadKey(true);

            switch (userResponse.KeyChar)
            {
            case '1':
                userMenuOption = AppEnum.MenuOptions.ViewAllFirearms;
                break;

            case '2':
                userMenuOption = AppEnum.MenuOptions.DisplayFirearmInfo;
                break;

            case '3':
                userMenuOption = AppEnum.MenuOptions.AddFirearm;
                break;

            case '4':
                userMenuOption = AppEnum.MenuOptions.DeleteFirearm;
                break;

            case '5':
                userMenuOption = AppEnum.MenuOptions.UpdateFirearm;
                break;

            case '6':
                userMenuOption = AppEnum.MenuOptions.QueryBy;
                break;

            case 'e':
            case 'E':
                userMenuOption = AppEnum.MenuOptions.Quit;
                break;

            default:
                DisplayMessage("");
                DisplayMessage("");
                DisplayMessage("It appears you have selected an incorrect choice.");
                DisplayMessage("");
                DisplayMessage("Press any key to try again or the ESC key to exit.");

                userResponse = Console.ReadKey(true);
                if (userResponse.Key == ConsoleKey.Escape)
                {
                    userMenuOption = AppEnum.MenuOptions.Quit;
                }
                break;
            }
            return(userMenuOption);
        }
예제 #2
0
        public static AppEnum.MenuOptions GetUserMenuOption()
        {
            DisplayReset();

            AppEnum.MenuOptions userMenuOption = AppEnum.MenuOptions.None;
            Console.WriteLine();
            Console.WriteLine("                                                     Enter a menu option.", System.Drawing.Color.CadetBlue);
            Console.WriteLine();
            Console.WriteLine("************************************************************************************************************************", System.Drawing.Color.CadetBlue);
            Console.WriteLine();
            Console.WriteLine();
            Console.WriteLine();
            Console.WriteLine();
            Console.WriteLine();



            Console.ForegroundColor = System.Drawing.Color.DarkKhaki;
            Console.WriteLine(
                "                                       1.            Display All Great People" + Environment.NewLine +
                "" + Environment.NewLine +
                "                                       2.            Display Great Person Detail" + Environment.NewLine +
                "" + Environment.NewLine +
                "                                       3.            Add a Great Person" + Environment.NewLine +
                "" + Environment.NewLine +
                "                                       4.            Delete a Great Person" + Environment.NewLine +
                "" + Environment.NewLine +
                "                                       5.            Update a Great Person" + Environment.NewLine +
                "" + Environment.NewLine +
                "                                       6.            Sort By Year Born");

            //"                                       7.            Query By");
            Console.WriteLine();
            Console.WriteLine();
            Console.WriteLine();
            Console.WriteLine();
            Console.WriteLine();
            Console.WriteLine();
            Console.ForegroundColor = System.Drawing.Color.MediumVioletRed;
            Console.WriteLine("                                             Press 'E' to exit the application.");
            Console.ResetColor();

            Console.WriteLine("");
            Console.WriteLine("");
            ConsoleKeyInfo userResponse = Console.ReadKey(true);

            switch (userResponse.KeyChar)
            {
            case '1':
                userMenuOption = AppEnum.MenuOptions.ViewAllGreatPeople;
                break;

            case '2':
                userMenuOption = AppEnum.MenuOptions.DisplayGreatPersonDetail;
                break;

            case '3':
                userMenuOption = AppEnum.MenuOptions.AddGreatPerson;
                break;

            case '4':
                userMenuOption = AppEnum.MenuOptions.DeleteGreatPerson;
                break;

            case '5':
                userMenuOption = AppEnum.MenuOptions.UpdateGreatPerson;
                break;

            case '6':
                userMenuOption = AppEnum.MenuOptions.SortByDateBorn;
                break;

            case '7':
                userMenuOption = AppEnum.MenuOptions.QueryBy;
                break;

            case 'e':
            case 'E':
                userMenuOption = AppEnum.MenuOptions.Quit;
                break;

            default:
                break;
            }
            return(userMenuOption);
        }