/// <summary> /// Reads a rectangular block of character and attribute information from the screen buffer into the passed array. /// </summary> /// <param name="buff">The array into which character information is to be placed.</param> /// <param name="buffX">The column position in the array where the first character is to be placed.</param> /// <param name="buffY">The row position in the array where the first character is to be placed.</param> /// <param name="left">Column position of the top-left corner of the screen buffer area from which characters are to be read.</param> /// <param name="top">Row position of the top-left corner of the screen buffer area from which characters are to be read.</param> /// <param name="right">Column position of the bottom-right corner of the screen buffer area from which characters are to be read.</param> /// <param name="bottom">Row position of the bottom-right corner of the screen buffer area from which characters are to be read.</param> public void ReadBlock(ConsoleCharInfo[,] buff, int buffX, int buffY, int left, int top, int right, int bottom) { if (disposed) { throw new ObjectDisposedException(this.ToString()); } // determine size of the buffer Coord bufferSize = new Coord((short)buff.GetLength(1), (short)buff.GetLength(0)); Coord bufferPos = new Coord((short)buffX, (short)buffY); SmallRect readRegion = new SmallRect((short)left, (short)top, (short)right, (short)bottom); if (!WinCon.ReadConsoleOutput(_handle, buff, bufferSize, bufferPos, readRegion)) { throw new IOException("Read error.", Marshal.GetLastWin32Error()); } }