Ejemplo n.º 1
0
        //public static void DisplayQueryResults(IEnumerable<Firearm> matchingFirearms)
        //{
        //    DisplayReset();

        //    DisplayMessage("");
        //    Console.WriteLine(ConsoleUtil.Center("Display Firearm Query Results", WINDOW_WIDTH));
        //    DisplayMessage("");

        //    DisplayMessage("All of the matching Firearms are displayed below;");
        //    DisplayMessage("");

        //    StringBuilder columnHeader = new StringBuilder();

        //    columnHeader.Append("ID".PadRight(8));
        //    columnHeader.Append("Firearm".PadRight(25));

        //    DisplayMessage(columnHeader.ToString());

        //    foreach (Firearm firearm in matchingFirearms)
        //    {
        //        StringBuilder firearmInfo = new StringBuilder();

        //        firearmInfo.Append(firearm.ID.ToString().PadRight(8));
        //        firearmInfo.Append(firearm.Name.PadRight(25));

        //        DisplayMessage(firearmInfo.ToString());
        //    }
        //}

        /// <summary>
        /// reset display to default size and colors including the header
        /// </summary>
        public static void DisplayReset()
        {
            Console.SetWindowSize(WINDOW_WIDTH, WINDOW_HEIGHT);

            Console.Clear();
            Console.ResetColor();

            Console.ForegroundColor = ConsoleColor.Red;
            Console.BackgroundColor = ConsoleColor.White;

            Console.WriteLine(ConsoleUtil.FillStringWithSpaces(WINDOW_WIDTH));
            Console.WriteLine(ConsoleUtil.Center("Guns R Us", WINDOW_WIDTH));
            Console.WriteLine(ConsoleUtil.FillStringWithSpaces(WINDOW_WIDTH));

            Console.ResetColor();
            Console.WriteLine();
        }
Ejemplo n.º 2
0
        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);
        }