protected override void Setup() { var letterA = new CHAR_INFO { AsciiChar = 'A', }; letterA.Attributes = (UInt16) (FOREGROUND_RED | FOREGROUND_INTENSITY | BACKGROUND_RED | BACKGROUND_GREEN | BACKGROUND_INTENSITY); var charBufSize = new COORD { X = 1, Y = 1, }; var characterPos = new COORD { X = 0, Y = 0, }; var writeArea = new SMALL_RECT { Left = 0, Top = 0, Right = 0, Bottom = 0, }; WriteConsoleOutput( WriteHandle, new CHAR_INFO[] { letterA }, charBufSize, characterPos, ref writeArea); Console.Write("\n"); }
public static void Initialize(string title, int width, int height) { WriteHandle = GetStdHandle(STD_OUTPUT_HANDLE); Console.Title = title; Random = new Random(Guid.NewGuid().GetHashCode()); Width = (short)width; Height = (short)height; WindowSize = new SMALL_RECT { Left = 0, Top = 0, Right = (short)(width - 1), Bottom = (short)(height - 1), }; SetConsoleWindowInfo(WriteHandle, true, ref WindowSize); BufferSize = new COORD { X = 80, Y = 50, }; SetConsoleScreenBufferSize(WriteHandle, BufferSize); }
public static extern bool WriteConsoleOutput( IntPtr hConsoleOutput, CHAR_INFO[] lpBuffer, COORD dwBufferSize, COORD dwBufferCoord, ref SMALL_RECT lpWriteRegion );
public static extern bool ReadConsoleOutput( IntPtr hConsoleOutput, [Out] CHAR_INFO[] lpBuffer, COORD dwBufferSize, COORD dwBufferCoord, ref SMALL_RECT lpReadRegion );