public static extern bool FillConsoleOutputAttribute( IntPtr hConsoleOutput, ushort wAttribute, uint nLength, COORD dwWriteCoord, out uint lpNumberOfAttrsWritten );
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"); }
protected override void Present() { var position = new COORD { X = (short)Random.Next(Width), Y = (short)Random.Next(Height), }; if (Random.Next() % 2 == 0) { SetConsoleTextAttribute(WriteHandle, 2); } else { SetConsoleTextAttribute(WriteHandle, 10); } SetConsoleCursorPosition(WriteHandle, position); if (Random.Next() % 2 == 0) { Console.Write("0"); } else { Console.Write("1"); } }
protected override void Setup() { var consoleBuffer = new CHAR_INFO[Width * Height]; for (int h = 0; h < Height; ++h) { for (int w = 0; w < Width; ++w) { consoleBuffer[w + Width * h].AsciiChar = 'A'/*(char)Random.Next(256)*/; consoleBuffer[w + Width * h].Attributes = (UInt16)Random.Next(256); } } var charBufSize = new COORD { X = Width, Y = Height, }; var characterPos = new COORD { X = 0, Y = 0, }; WriteConsoleOutput( WriteHandle, consoleBuffer, charBufSize, characterPos, ref WindowSize); }
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 SetConsoleScreenBufferSize( IntPtr hConsoleOutput, COORD dwSize );
public static extern bool SetConsoleDisplayMode( IntPtr ConsoleOutput, uint Flags, out COORD NewScreenBufferDimensions );
public static extern bool SetConsoleCursorPosition( IntPtr hConsoleOutput, COORD dwCursorPosition );
public static extern bool ScrollConsoleScreenBuffer( IntPtr hConsoleOutput, [In] ref SMALL_RECT lpScrollRectangle, IntPtr lpClipRectangle, COORD dwDestinationOrigin, [In] ref CHAR_INFO lpFill );
public static extern bool ReadConsoleOutputCharacter( IntPtr hConsoleOutput, [Out] StringBuilder lpCharacter, uint nLength, COORD dwReadCoord, out uint lpNumberOfCharsRead );
public static extern bool ReadConsoleOutputAttribute( IntPtr hConsoleOutput, [Out] ushort[] lpAttribute, uint nLength, COORD dwReadCoord, out uint lpNumberOfAttrsRead );
public WINDOW_BUFFER_SIZE_RECORD(short x, short y) { dwSize = new COORD(); dwSize.X = x; dwSize.Y = y; }
public static extern bool FillConsoleOutputCharacter( IntPtr hConsoleOutput, char cCharacter, uint nLength, COORD dwWriteCoord, out uint lpNumberOfCharsWritten );
public static extern bool ReadConsoleOutput( IntPtr hConsoleOutput, [Out] CHAR_INFO[] lpBuffer, COORD dwBufferSize, COORD dwBufferCoord, ref SMALL_RECT lpReadRegion );