public static void MoveBufferArea(int sourceLeft, int sourceTop, int sourceWidth, int sourceHeight, int targetLeft, int targetTop, char sourceChar, ConsoleColor sourceForeColor, ConsoleColor sourceBackColor) { lock (typeof(Console)) { SpecialMode(); int width, height; Stdio.GetBufferSize(out width, out height); if (sourceLeft < 0 || sourceLeft >= width) { throw new ArgumentOutOfRangeException ("sourceLeft", _("ArgRange_XCoordinate")); } if (sourceTop < 0 || sourceTop >= height) { throw new ArgumentOutOfRangeException ("sourceTop", _("ArgRange_YCoordinate")); } if (sourceWidth < 0 || (sourceLeft + sourceWidth) > width) { throw new ArgumentOutOfRangeException ("sourceWidth", _("ArgRange_Width")); } if (sourceHeight < 0 || (sourceTop + sourceHeight) > height) { throw new ArgumentOutOfRangeException ("sourceHeight", _("ArgRange_Height")); } if (targetLeft < 0 || targetLeft >= width) { throw new ArgumentOutOfRangeException ("targetLeft", _("ArgRange_XCoordinate")); } if (targetTop < 0 || targetTop >= height) { throw new ArgumentOutOfRangeException ("targetTop", _("ArgRange_YCoordinate")); } if ((((int)sourceForeColor) & ~0x0F) != 0) { throw new ArgumentException (_("Arg_InvalidColor"), "sourceForeColor"); } if ((((int)sourceBackColor) & ~0x0F) != 0) { throw new ArgumentException (_("Arg_InvalidColor"), "sourceBackColor"); } Stdio.MoveBufferArea(sourceLeft, sourceTop, sourceWidth, sourceHeight, targetLeft, targetTop, sourceChar, ((int)(sourceForeColor)) | (((int)(sourceBackColor)) << 4)); } }
// Set the cursor position. public static void SetCursorPosition(int left, int top) { lock (typeof(Console)) { SpecialMode(); int width, height; Stdio.GetBufferSize(out width, out height); if (left < 0 || left >= width) { throw new ArgumentOutOfRangeException ("left", _("ArgRange_XCoordinate")); } if (top < 0 || top >= height) { throw new ArgumentOutOfRangeException ("top", _("ArgRange_YCoordinate")); } Stdio.SetCursorPosition(left, top); } }
// Set the window size. public static void SetWindowSize(int width, int height) { lock (typeof(Console)) { SpecialMode(); int bwidth, bheight; Stdio.GetBufferSize(out bwidth, out bheight); int wleft, wtop, wwidth, wheight; Stdio.GetWindowSize (out wleft, out wtop, out wwidth, out wheight); if (width <= 0 || (wleft + width) > bwidth) { throw new ArgumentOutOfRangeException ("width", _("ArgRange_Width")); } if (height <= 0 || (wtop + height) > bheight) { throw new ArgumentOutOfRangeException ("height", _("ArgRange_Height")); } Stdio.SetWindowSize(wleft, wtop, width, height); } }
// Set the window position. public static void SetWindowPosition(int left, int top) { lock (typeof(Console)) { SpecialMode(); int width, height; Stdio.GetBufferSize(out width, out height); int wleft, wtop, wwidth, wheight; Stdio.GetWindowSize (out wleft, out wtop, out wwidth, out wheight); if (left < 0 || (left + wwidth) > width) { throw new ArgumentOutOfRangeException ("left", _("ArgRange_XCoordinate")); } if (top < 0 || (left + wheight) > height) { throw new ArgumentOutOfRangeException ("left", _("ArgRange_YCoordinate")); } Stdio.SetWindowSize(left, top, wwidth, wheight); } }