/// <summary> /// Writes a test line to the console using the specified ColorFormater /// </summary> /// <param name="colorFormatter"></param> /// <param name="value"></param> private void WriteLine(ColorFormatter colorFormatter, string value, bool useSeparator) { //Temp values. var background = Console.BackgroundColor; var foreground = Console.ForegroundColor; Console.BackgroundColor = colorFormatter.Background; Console.ForegroundColor = colorFormatter.Foreground; if (formatter.Separator != null && useSeparator) { Console.WriteLine(formatter.Separator); } Console.WriteLine(value); Console.BackgroundColor = background; Console.ForegroundColor = foreground; }
/// <summary> /// Default Constructior when invoked uses default formatting /// </summary> public ConsoleFormatter() { DescriptionColor = new ColorFormatter(); DescriptionColor.Background = ConsoleColor.Black; DescriptionColor.Foreground = ConsoleColor.White; NameColor = new ColorFormatter(); NameColor.Background = ConsoleColor.DarkGreen; NameColor.Foreground = ConsoleColor.White; SuccessResultColor = new ColorFormatter(); SuccessResultColor.Background = ConsoleColor.Black; SuccessResultColor.Foreground = ConsoleColor.Green; ErrorResultColor = new ColorFormatter(); ErrorResultColor.Background = ConsoleColor.Black; ErrorResultColor.Foreground = ConsoleColor.Red; InfoColor = new ColorFormatter(); InfoColor.Background = ConsoleColor.Black; InfoColor.Foreground = ConsoleColor.Gray; Separator = "----------------------"; }
/// <summary> /// Writes a test line to the console using the specified ColorFormater /// </summary> /// <param name="colorFormatter"></param> /// <param name="value"></param> private void WriteLine(ColorFormatter colorFormatter, string value, bool useSeparator) { //Temp values. var background = Console.BackgroundColor; var foreground = Console.ForegroundColor; Console.BackgroundColor = colorFormatter.Background; Console.ForegroundColor = colorFormatter.Foreground; if (formatter.Separator != null && useSeparator) Console.WriteLine(formatter.Separator); Console.WriteLine(value); Console.BackgroundColor = background; Console.ForegroundColor = foreground; }