Ejemplo n.º 1
0
        /// <summary>
        /// Sets the screen buffer window size.
        /// </summary>
        /// <param name="width">Desired window width in character columns.</param>
        /// <param name="height">Desired window height in character rows.</param>
        public void SetWindowSize(int width, int height)
        {
            SmallRect sr = GetWindowRect();

            sr.Width  = (short)width;
            sr.Height = (short)height;
            SetWindowRect(sr, true);
        }
Ejemplo n.º 2
0
 private void SetWindowRect(SmallRect sr, bool bAbsolute)
 {
     if (disposed)
     {
         throw new ObjectDisposedException(this.ToString());
     }
     if (!WinCon.SetConsoleWindowInfo(handle, bAbsolute, sr))
     {
         int err = Marshal.GetLastWin32Error();
         throw new ApplicationException(String.Format("Unable to set window rect: {0}", err));
     }
 }
Ejemplo n.º 3
0
        /// <summary>
        /// Sets the position of the window within the screen buffer.
        /// </summary>
        /// <param name="left">Column position of the top-left corner of the screen buffer window.</param>
        /// <param name="top">Row position of the top-left corner of the screen buffer window.</param>
        public void SetWindowPosition(int left, int top)
        {
            SmallRect sr     = GetWindowRect();
            int       width  = sr.Width;
            int       height = sr.Height;

            sr.left   = (short)left;
            sr.top    = (short)top;
            sr.Width  = (short)width;
            sr.Height = (short)height;
            SetWindowRect(sr, true);
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Writes character and attribute information to a rectangular portion of the screen buffer.
        /// </summary>
        /// <param name="buff">The array that contains characters and attributes to be written.</param>
        /// <param name="buffX">Column position of the first character to be written from the array.</param>
        /// <param name="buffY">Row position of the first character to be written from the array.</param>
        /// <param name="left">Column position of the top-left corner of the screen buffer area where characters are to be written.</param>
        /// <param name="top">Row position of the top-left corner of the screen buffer area where characters are to be written.</param>
        /// <param name="right">Column position of the bottom-right corner of the screen buffer area where characters are to be written.</param>
        /// <param name="bottom">Row position of the bottom-right corner of the screen buffer area where characters are to be written.</param>
        public void WriteBlock(ConsoleCharInfo[,] buff, int buffX, int buffY, int left, int top, int right, int bottom)
        {
            if (disposed)
            {
                throw new ObjectDisposedException(this.ToString());
            }
            Coord     bufferSize  = new Coord((short)buff.GetLength(1), (short)buff.GetLength(0));
            Coord     bufferPos   = new Coord((short)buffX, (short)buffY);
            SmallRect writeRegion = new SmallRect((short)left, (short)top, (short)right, (short)bottom);

            if (!WinCon.WriteConsoleOutput(handle, buff, bufferSize, bufferPos, writeRegion))
            {
                throw new IOException("Write error.", Marshal.GetLastWin32Error());
            }
        }
Ejemplo n.º 5
0
        /// <summary>
        /// Copies a specified source area of the screen buffer to a specified destination area.
        /// Vacated character cells are filled with the specified character and color attributes.
        /// </summary>
        /// <param name="sourceLeft">Column position of the source area's top-left corner.</param>
        /// <param name="sourceTop">Row position of the source arean't top-left corner.</param>
        /// <param name="sourceWidth">Width, in character columns, of the source area.</param>
        /// <param name="sourceHeight">Height, in character rows, of the source area.</param>
        /// <param name="targetLeft">Column position of the target's top-left corner.</param>
        /// <param name="targetTop">Row position of the target's top-left corner.</param>
        /// <param name="sourceChar">Character with which to fill vacated character positions.</param>
        /// <param name="sourceForeColor">Foreground color to use for filling.</param>
        /// <param name="sourceBackColor">Background color to use for filling.</param>
        public void MoveBufferArea(
            int sourceLeft,
            int sourceTop,
            int sourceWidth,
            int sourceHeight,
            int targetLeft,
            int targetTop,
            char sourceChar,
            ConsoleColor sourceForeColor,
            ConsoleColor sourceBackColor
            )
        {
            SmallRect sourceRect = new SmallRect((short)sourceLeft, (short)sourceTop,
                                                 (short)(sourceLeft + sourceWidth - 1), (short)(sourceTop + sourceHeight - 1));
            Coord           dest = new Coord((short)targetLeft, (short)targetTop);
            ConsoleCharInfo cci  = new ConsoleCharInfo(sourceChar, new ConsoleCharAttribute(sourceForeColor, sourceBackColor));

            if (!WinCon.ScrollConsoleScreenBuffer(handle, sourceRect, null, dest, ref cci))
            {
                throw new IOException("Error scrolling screen buffer", Marshal.GetLastWin32Error());
            }
        }
Ejemplo n.º 6
0
 public static extern bool WriteConsoleOutput(
     IntPtr hConsoleOutput,
     [In][MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 2)] ConsoleCharInfo[,] lpBuffer,
     Coord dwBufferSize,
     Coord dwBufferCoord,
     [In, Out][MarshalAs(UnmanagedType.LPStruct)] SmallRect lpWriteRegion);
Ejemplo n.º 7
0
 public static extern bool SetConsoleWindowInfo(
     IntPtr hConsoleOutput,
     bool bAbsolute,
     [In][MarshalAs(UnmanagedType.LPStruct)] SmallRect lpConsoleWindow);
Ejemplo n.º 8
0
 public static extern bool ScrollConsoleScreenBuffer(
     IntPtr hConsoleOutput,
     [In][MarshalAs(UnmanagedType.LPStruct)] SmallRect lpScrollRectangle,
     [In][MarshalAs(UnmanagedType.LPStruct)] SmallRect lpClipRectangle,
     Coord dwDestinationOrigin,
     ref ConsoleCharInfo lpFill);