Esempio n. 1
0
        private static string ReadFromInput(bool isNumber, out uint inpLen)
        {
            ConsoleColors.SetAndPushDefaultColors();
            var  input = "";
            char ch;

            inpLen = 0;

            while (!(ch = Console.ReadKey(true).KeyChar).Equals(Nl[0]) || inpLen.Equals(0))
            {
                switch (ch)
                {
                case '\r':
                    continue;

                case '\b' when inpLen != 0:
                    input = input.Remove(input.Length - 1);
                    inpLen--;
                    Console.Write("\b \b");
                    break;

                default: {
                    if (inpLen != 9 && ch != '\b')
                    {
                        if (isNumber && (ch < '0' || ch > '9'))
                        {
                            continue;
                        }

                        Console.Write(ch);
                        input += ch;
                        inpLen++;
                    }

                    break;
                }
                }
            }

            ConsoleColors.SetPreviousAndPopColors();
            return(input);
        }