257 {
258 get
259 {
260 bool succeeded;
261 global::Interop.Kernel32.CONSOLE_SCREEN_BUFFER_INFO bufferInfo =
GetBufferInfo(throwOnNoConsole: false, out succeeded);
262 if (!succeeded)
263 {
265 }
267 }
268 set
269 {
271 bool succeeded;
272 global::Interop.Kernel32.CONSOLE_SCREEN_BUFFER_INFO bufferInfo =
GetBufferInfo(throwOnNoConsole: false, out succeeded);
273 if (succeeded)
274 {
275 short wAttributes = bufferInfo.wAttributes;
276 wAttributes &= -241;
277 wAttributes = (
short)((ushort)wAttributes | (ushort)color);
278 global::Interop.Kernel32.SetConsoleTextAttribute(
OutputHandle, wAttributes);
279 }
280 }
281 }
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()