Beispiel #1
0
        private static void GridSize()
        {
            Console.Clear();
            Console.SetCursorPosition(0, Console.WindowHeight - 1);
            Console.ForegroundColor = ConsoleColor.Cyan;
            Console.WriteLine($"Enter number of columns [min: {_gridColumnsMin}, max: {_gridColumnsMax}]");

            do
            {
                // collect user input
                Console.ForegroundColor = ConsoleColor.White;
                var input = Console.ReadLine();

                try
                {
                    if (String.IsNullOrEmpty(input))
                    {
                        return;
                    }
                    _gridSize.SetCols(input);
                    break;
                }
                catch (ArgumentException)
                {
                    Console.ForegroundColor = ConsoleColor.Red;
                    Console.WriteLine($"Please enter a valid number [min: {_gridColumnsMin}, max: {_gridColumnsMax}]");
                }
            } while (true);

            Console.ForegroundColor = ConsoleColor.Cyan;
            Console.WriteLine($"Enter number of rows [min: {_gridRowsMin}, max: {_gridRowsMax}]");
            do
            {
                // collect user input
                Console.ForegroundColor = ConsoleColor.White;
                var input = Console.ReadLine();

                try
                {
                    _gridSize.SetRows(input);
                    break;
                }
                catch (ArgumentException)
                {
                    Console.ForegroundColor = ConsoleColor.Red;
                    Console.WriteLine($"Please enter a valid number [min: {_gridRowsMin}, max: {_gridRowsMax}]");
                }
            } while (true);
        }