/// <summary> /// Invokes an action with predefined colors on the console. /// </summary> /// <param name="printing"></param> /// <param name="textColor"></param> /// <param name="backColor"></param> public static void InvokeWithColors(Action printing, FColor textColor, FColor backColor) { lock (lockP) { ConsoleColor previousBackColor = GetBackground(); SetBackground(backColor.MatchColor(previousBackColor)); InvokeWithColors(printing, textColor); SetBackground(previousBackColor); } }
/// <summary> /// Prints the string value with the specified colors. /// </summary> /// <param name="value"></param> /// <param name="textColor"></param> /// <param name="backColor"></param> public static void Print(object value, FColor textColor, FColor backColor) { lock (lockP) { ConsoleColor previousBackColor = GetBackground(); SetBackground(backColor.MatchColor(previousBackColor)); Print(value, textColor); SetBackground(previousBackColor); } }
/// <summary> /// /// Invokes an action with predefined colors on the console. /// </summary> /// <param name="printing"></param> /// <param name="textColor"></param> public static void InvokeWithColors(Action printing, FColor textColor) { lock (lockP) { ConsoleColor previousColor = GetForeground(); SetForeground(textColor.MatchColor(previousColor)); printing?.Invoke(); SetForeground(previousColor); } }
/// <summary> /// Prints the string representation of the value with the specified text color. /// </summary> /// <param name="value"></param> /// <param name="textColor"></param> public static void Print(object value, FColor textColor) { lock (lockP) { ConsoleColor previousColor = GetForeground(); SetForeground(textColor.MatchColor(previousColor)); Print(value); SetForeground(previousColor); } }