284 {
285 get
286 {
287 bool succeeded;
288 global::Interop.Kernel32.CONSOLE_SCREEN_BUFFER_INFO bufferInfo =
GetBufferInfo(throwOnNoConsole: false, out succeeded);
289 if (!succeeded)
290 {
292 }
294 }
295 set
296 {
298 bool succeeded;
299 global::Interop.Kernel32.CONSOLE_SCREEN_BUFFER_INFO bufferInfo =
GetBufferInfo(throwOnNoConsole: false, out succeeded);
300 if (succeeded)
301 {
302 short wAttributes = bufferInfo.wAttributes;
303 wAttributes &= -16;
304 wAttributes = (
short)((ushort)wAttributes | (ushort)color);
305 global::Interop.Kernel32.SetConsoleTextAttribute(
OutputHandle, wAttributes);
306 }
307 }
308 }
static global::Interop.Kernel32.Color ConsoleColorToColorAttribute(ConsoleColor color, bool isBackground)
static ConsoleColor ColorAttributeToConsoleColor(global::Interop.Kernel32.Color c)
static IntPtr OutputHandle
static global::Interop.Kernel32.CONSOLE_SCREEN_BUFFER_INFO GetBufferInfo()