/// <summary> /// Reads the next line of characters from the standard input stream. /// </summary> /// <param name="prompt">A string prompting the user to enter something.</param> /// <param name="consoleColor">The color of the user input.</param> /// <returns></returns> public static string Input(string prompt, ConsoleColorExtension consoleColor) { formatPrompt = consoleColor.ToString() + prompt; Console.ForegroundColor = consoleColor.ToConsoleColor(); Console.Write(prompt); string userInput = ReadLineSafe(); Console.ForegroundColor = ConsoleColorExtension.Default.ToConsoleColor(); return(userInput); }
/// <summary> /// Reads the next line of characters from the standard input stream. /// </summary> /// <param name="prompt">A string prompting the user to enter something.</param> /// <param name="advancedConsoleColor">The color of the user input.</param> /// <param name="colorParameters">-1 : Draw the whole line in the same color. 0 : Only the user input will be drawn in provided color. 1 : Only the text prompt will be drawn in provided color. DEFAULT: -1</param> /// <returns></returns> public static string Input(string prompt, ConsoleColorExtension advancedConsoleColor, int colorParameters) { string userInput = string.Empty; switch (colorParameters) { case -1: { Input(prompt, advancedConsoleColor); break; } case 0: { formatPrompt = ConsoleColorExtension.Default.ToString() + prompt + advancedConsoleColor.ToString(); Console.Write(prompt); Console.ForegroundColor = advancedConsoleColor.ToConsoleColor(); userInput = ReadLineSafe(); Console.ForegroundColor = ConsoleColorExtension.Default.ToConsoleColor(); break; } case 1: { formatPrompt = advancedConsoleColor.ToString() + prompt + ConsoleColorExtension.Default.ToString(); Console.ForegroundColor = advancedConsoleColor.ToConsoleColor(); Console.Write(prompt); Console.ForegroundColor = ConsoleColorExtension.Default.ToConsoleColor(); userInput = ReadLineSafe(); break; } default: { throw new IndexOutOfRangeException("COLOR_PARAMETER_OUT_OF_RANGE"); } } return(userInput); }
public void SetDefault() { Default = new ConsoleColorExtension(value, name); }