/// <summary> /// Places a single character value and set attributes (fg/bg colors) at the specified screen location. /// </summary> /// <param name="positionLeft">The position counting from the left (starts at position 0).</param> /// <param name="positionTop">The position counting from the top (starts at position 0).</param> /// <param name="value">The character and atributes to be written to the screen.</param> private void PokeScreenCharEx(int positionLeft, int positionTop, CharEx value) { IntPtr stdout = Kernel32.GetStdHandle(Kernel32.StdHandle.Stdout); if (stdout == IntPtr.Zero) { throw new Win32Exception(); } Kernel32.COORD dwWriteCoord; dwWriteCoord.X = (short)positionLeft; dwWriteCoord.Y = (short)positionTop; uint nLength = 1; ushort[] lpAttributes = new[] { value.Attributes }; uint lpNumberOfAttrsWritten = 1; if (!Kernel32.WriteConsoleOutputAttribute(stdout, lpAttributes, nLength, dwWriteCoord, out lpNumberOfAttrsWritten)) { throw new Win32Exception(); } PokeScreenChar(positionLeft, positionTop, value.AsciiChar); }
/// <summary> /// Places a single character value and set attributes (fg/bg colors) at the specified screen location. /// </summary> /// <param name="positionLeft">The position counting from the left (starts at position 0).</param> /// <param name="positionTop">The position counting from the top (starts at position 0).</param> /// <param name="value">The character and atributes to be written to the screen.</param> private void PokeScreenCharEx(int positionLeft, int positionTop, CharEx value) { IntPtr stdout = Kernel32.GetStdHandle(Kernel32.StdHandle.Stdout); if (stdout == IntPtr.Zero) throw new Win32Exception(); Kernel32.COORD dwWriteCoord; dwWriteCoord.X = (short)positionLeft; dwWriteCoord.Y = (short)positionTop; uint nLength = 1; ushort[] lpAttributes = new[] { value.Attributes }; uint lpNumberOfAttrsWritten = 1; if (!Kernel32.WriteConsoleOutputAttribute(stdout, lpAttributes, nLength, dwWriteCoord, out lpNumberOfAttrsWritten)) throw new Win32Exception(); PokeScreenChar(positionLeft, positionTop, value.AsciiChar); }