Esempio n. 1
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());
            }
        }