/// <summary> /// Reads character attributes from the screen buffer, starting at the given position. /// </summary> /// <param name="nattrs">Number of attributes to read.</param> /// <param name="x">Column position of the first attribute to read.</param> /// <param name="y">Row position of the first attribute to read.</param> /// <returns>An array containing the attributes read from the screen buffer.</returns> public ConsoleCharAttribute[] ReadAtrributesXY(int nColors, int x, int y) { if (disposed) { throw new ObjectDisposedException(this.ToString()); } ConsoleCharAttribute[] buff = new ConsoleCharAttribute[nColors]; int colorsRead = 0; if (!WinCon.ReadConsoleOutputAttribute(_handle, buff, nColors, new Coord((short)x, (short)y), ref colorsRead)) { throw new System.IO.IOException("Read error", Marshal.GetLastWin32Error()); } if (colorsRead < nColors) { ConsoleCharAttribute[] newBuff = new ConsoleCharAttribute[colorsRead]; Array.Copy(buff, newBuff, colorsRead); return(newBuff); } return(buff); }