/// <summary> /// Print the date if it has changed since we last printed the date /// </summary> public static void PrintIfChanged() { if (known.Date != DateTime.Now.Date) { known = DateTime.Now.Date; using (var _ = new ColorHandler(null, ConsoleColor.DarkGray)) PrintLine($" -={{{known.Date.ToLongDateString()}}}=- "); } }
/// <summary> /// Custom color /// </summary> /// <param name="value">Object to print. will use <see cref="object.ToString()"/></param> /// <param name="foreground"></param> public static void WriteLineC(object value, ConsoleColor?foreground, ConsoleColor?background = null) { lock (lockme) { var str = Input?.GetTypedText(); if (str != null) { Console.Write('\r'); } DatePrinter.PrintIfChanged(); Print($"[{DateTime.Now.ToLongTimeString()}] {CTN}: "); using (var _ = new ColorHandler(background, foreground)) PrintLine($"{value??"NULL"} "); if (str != null) { Console.Write(str); Console.CursorLeft = Input.CursorX; } } }
/// <summary> /// Generates a full line with the given character and color. Used to create clear visual separation /// </summary> /// <param name="character">the character to fill the line with</param> /// <param name="foreground"></param> /// <param name="background"></param> public static void FillLineC(char character, ConsoleColor?foreground, ConsoleColor?background) { using (var _ = new ColorHandler(foreground, background)) FillLine(character); }