private static Native.COORD ConsPosToCOORDS(ConsolePos pos) { return(new Native.COORD() { x = pos.x, y = pos.y }); }
public static void SetColor(int length, ConsolePos pos, ConsoleColor textColor, ConsoleColor backgroundColor) { int written = -1; Native.wAttribute attr = ColorsToWAttribute(textColor, backgroundColor); Native.FillConsoleOutputAttribute(outputHandle, attr, length, ConsPosToCOORDS(pos), ref written); }
public static ConsolePos GetBufferSize() { Native.CONSOLE_SCREEN_BUFFER_INFO info = new Native.CONSOLE_SCREEN_BUFFER_INFO(); Native.GetConsoleScreenBufferInfo(outputHandle, ref info); ConsolePos size = new ConsolePos() { x = info.bufferSize.x, y = info.bufferSize.y }; return(size); }
public static ConsolePos GetWindowSize() { Native.CONSOLE_SCREEN_BUFFER_INFO info = new Native.CONSOLE_SCREEN_BUFFER_INFO(); Native.GetConsoleScreenBufferInfo(outputHandle, ref info); ConsolePos size = new ConsolePos() { x = (short)(info.visibleSegment.Right - info.visibleSegment.Left), y = (short)(info.visibleSegment.Bottom - info.visibleSegment.Top) }; return(size); }
public static ConsolePos GetWindowPosition() { Native.CONSOLE_SCREEN_BUFFER_INFO info = new Native.CONSOLE_SCREEN_BUFFER_INFO(); Native.GetConsoleScreenBufferInfo(outputHandle, ref info); ConsolePos pos = new ConsolePos() { x = info.visibleSegment.Left, y = info.visibleSegment.Top }; return(pos); }
public static void CopyArrayToScreen(ConsChar[,] buffer, ConsolePos destPos) { short width = (short)buffer.GetLength(0); short height = (short)buffer.GetLength(1); Native.SMALL_RECT rect = new Native.SMALL_RECT() { Top = destPos.y, Left = destPos.x, Right = (short)(destPos.x + width - 1), Bottom = (short)(destPos.y + height - 1) }; Native.CHAR_INFO[] outBuffer = new Native.CHAR_INFO[buffer.Length]; for (int j = 0; j < height; j++) { for (int i = 0; i < width; i++) { Native.wAttribute attribute = ColorsToWAttribute(buffer[i, j].TextColor, buffer[i, j].BgColor); Native.CHAR_INFO info = new Native.CHAR_INFO() { c = (short)buffer[i, j].Character, attr = attribute }; outBuffer[i + buffer.GetLength(0) * j] = info; } } Native.COORD outBufferDim = new Native.COORD() { x = width, y = height }; Native.WriteConsoleOutputW(outputHandle, outBuffer, outBufferDim, new Native.COORD() { x = 0, y = 0 }, ref rect); }
public static void Write(string text, ConsolePos pos, ConsoleColor textColor, ConsoleColor backgroundColor) { Write(text, pos); SetColor(text.Length, pos, textColor, backgroundColor); }
public static void Write(string text, ConsolePos pos) { int written = -1; Native.WriteConsoleOutputCharacter(outputHandle, text, text.Length, ConsPosToCOORDS(pos), ref written); }