Beispiel #1
0
        public static string PasswordPrompt(ConsoleColorCombo colors, string promptMessage = null)
        {
            promptMessage = promptMessage ?? "Please enter your password ";
            string pass = string.Empty;

            Out($"{promptMessage} >>", colors);
            ConsoleKeyInfo keyInfo;

            do
            {
                keyInfo = Console.ReadKey(true);
                if (keyInfo.Key != ConsoleKey.Backspace && keyInfo.Key != ConsoleKey.Enter)
                {
                    pass += keyInfo.KeyChar;
                    Out("*", colors);
                }
                else
                {
                    if (keyInfo.Key == ConsoleKey.Backspace && pass.Length > 0)
                    {
                        pass = pass.Substring(0, (pass.Length - 1));
                        Out("\b \b");
                    }
                }
            }while (keyInfo.Key != ConsoleKey.Enter);
            return(pass);
        }
Beispiel #2
0
 public static void OutLine(string message, ConsoleColorCombo colors)
 {
     Out($"{message}\r\n", colors);
 }
Beispiel #3
0
 public static void Out(string message, ConsoleColorCombo colors)
 {
     ColoredBackgroundMessageProvider(message, colors);
 }
Beispiel #4
0
 public static void OutFormat(string message, ConsoleColorCombo colors, params object[] formatArgs)
 {
     Out(string.Format(message, formatArgs), colors);
 }
Beispiel #5
0
 public static string Prompt(string message, string promptTxt, ConsoleColorCombo colors, bool allowQuit)
 {
     return(PromptProvider(message, promptTxt, colors, allowQuit));
 }
Beispiel #6
0
 public ConsoleMessage(string msg, ConsoleColorCombo colors) : this(msg)
 {
     Colors = colors;
 }
Beispiel #7
0
 public static void SetConsoleColors(ConsoleColorCombo combo)
 {
     Console.ForegroundColor = combo.ForegroundColor;
     Console.BackgroundColor = combo.BackgroundColor;
 }