To use different colors than provided via ConsoleColor
I implemented code you can find on p/invoke here.
This solution works fine, I can use every color/colorcode I want to visualize.
But CONSOLE_SCREEN_BUFFER_INFO_EX
only contains a few different colors. If I changed for example ConsoleColor.White
to Color.LimeGreen
and write text with this color, it'll be recolored, if I change ConsoleColor.White
later to another Color. For example:
Console.ForegroundColor = ConsoleColor.White;
Console.WriteLine("White text"); //text is white
Console.ReadKey(true);
ConsoleExtender.SetScreenColors(Color.Goldenrod, Color.Black);
Console.WriteLine("Goldenrod text"); //both lines are goldenrod
Console.ReadKey(true);
ConsoleExtender.SetScreenColors(Color.LimeGreen, Color.Black);
Console.WriteLine("LimeGreen text"); //all three lines are limegreen
Console.ReadKey(true);
Is it possible to changes colors on runtime, without restyling text, which is already visible?