示例#1
0
        public override void SetBufferContents(Coordinates origin, BufferCell[,] contents)
        {
            IntPtr stdHandle = PS2EXEHostRawUI.GetStdHandle(-11);

            PS2EXEHostRawUI.CHAR_INFO[,] cHARINFOArray = new PS2EXEHostRawUI.CHAR_INFO[contents.GetLength(0), contents.GetLength(1)];
            PS2EXEHostRawUI.COORD cOORD = new PS2EXEHostRawUI.COORD()
            {
                X = (short)contents.GetLength(1),
                Y = (short)contents.GetLength(0)
            };
            PS2EXEHostRawUI.COORD cOORD1 = cOORD;
            PS2EXEHostRawUI.COORD cOORD2 = new PS2EXEHostRawUI.COORD()
            {
                X = 0,
                Y = 0
            };
            PS2EXEHostRawUI.COORD      cOORD3    = cOORD2;
            PS2EXEHostRawUI.SMALL_RECT sMALLRECT = new PS2EXEHostRawUI.SMALL_RECT()
            {
                Left   = (short)origin.X,
                Top    = (short)origin.Y,
                Right  = (short)(origin.X + contents.GetLength(1) - 1),
                Bottom = (short)(origin.Y + contents.GetLength(0) - 1)
            };
            PS2EXEHostRawUI.SMALL_RECT sMALLRECT1 = sMALLRECT;
            for (int i = 0; i < contents.GetLength(0); i++)
            {
                for (int j = 0; j < contents.GetLength(1); j++)
                {
                    PS2EXEHostRawUI.CHAR_INFO cHARINFO = new PS2EXEHostRawUI.CHAR_INFO()
                    {
                        AsciiChar  = contents[i, j].Character,
                        Attributes = (ushort)((int)contents[i, j].ForegroundColor + (int)contents[i, j].BackgroundColor * 16)
                    };
                    cHARINFOArray[i, j] = cHARINFO;
                }
            }
            PS2EXEHostRawUI.WriteConsoleOutput(stdHandle, cHARINFOArray, cOORD1, cOORD3, ref sMALLRECT1);
        }
示例#2
0
        public override void ScrollBufferContents(Rectangle source, Coordinates destination, Rectangle clip, BufferCell fill)
        {
            if (source.Left > clip.Right || source.Right < clip.Left || source.Top > clip.Bottom || source.Bottom < clip.Top)
            {
                return;
            }
            IntPtr stdHandle = PS2EXEHostRawUI.GetStdHandle(-11);

            PS2EXEHostRawUI.SMALL_RECT sMALLRECT = new PS2EXEHostRawUI.SMALL_RECT()
            {
                Left   = (short)source.Left,
                Top    = (short)source.Top,
                Right  = (short)source.Right,
                Bottom = (short)source.Bottom
            };
            PS2EXEHostRawUI.SMALL_RECT sMALLRECT1 = sMALLRECT;
            PS2EXEHostRawUI.SMALL_RECT sMALLRECT2 = new PS2EXEHostRawUI.SMALL_RECT()
            {
                Left   = (short)clip.Left,
                Top    = (short)clip.Top,
                Right  = (short)clip.Right,
                Bottom = (short)clip.Bottom
            };
            PS2EXEHostRawUI.SMALL_RECT sMALLRECT3 = sMALLRECT2;
            PS2EXEHostRawUI.COORD      cOORD      = new PS2EXEHostRawUI.COORD()
            {
                X = (short)destination.X,
                Y = (short)destination.Y
            };
            PS2EXEHostRawUI.COORD     cOORD1   = cOORD;
            PS2EXEHostRawUI.CHAR_INFO cHARINFO = new PS2EXEHostRawUI.CHAR_INFO()
            {
                AsciiChar  = fill.Character,
                Attributes = (ushort)((int)fill.ForegroundColor + (int)fill.BackgroundColor * 16)
            };
            PS2EXEHostRawUI.CHAR_INFO cHARINFO1 = cHARINFO;
            PS2EXEHostRawUI.ScrollConsoleScreenBuffer(stdHandle, ref sMALLRECT1, ref sMALLRECT3, cOORD1, ref cHARINFO1);
        }
示例#3
0
        public override BufferCell[,] GetBufferContents(Rectangle rectangle)
        {
            IntPtr stdHandle = PS2EXEHostRawUI.GetStdHandle(-11);

            PS2EXEHostRawUI.CHAR_INFO[,] cHARINFOArray = new PS2EXEHostRawUI.CHAR_INFO[rectangle.Bottom - rectangle.Top + 1, rectangle.Right - rectangle.Left + 1];
            PS2EXEHostRawUI.COORD cOORD = new PS2EXEHostRawUI.COORD()
            {
                X = (short)(rectangle.Right - rectangle.Left + 1),
                Y = (short)(rectangle.Bottom - rectangle.Top + 1)
            };
            PS2EXEHostRawUI.COORD cOORD1 = cOORD;
            PS2EXEHostRawUI.COORD cOORD2 = new PS2EXEHostRawUI.COORD()
            {
                X = 0,
                Y = 0
            };
            PS2EXEHostRawUI.COORD      cOORD3    = cOORD2;
            PS2EXEHostRawUI.SMALL_RECT sMALLRECT = new PS2EXEHostRawUI.SMALL_RECT()
            {
                Left   = (short)rectangle.Left,
                Top    = (short)rectangle.Top,
                Right  = (short)rectangle.Right,
                Bottom = (short)rectangle.Bottom
            };
            PS2EXEHostRawUI.SMALL_RECT sMALLRECT1 = sMALLRECT;
            PS2EXEHostRawUI.ReadConsoleOutput(stdHandle, cHARINFOArray, cOORD1, cOORD3, ref sMALLRECT1);
            BufferCell[,] bufferCell = new BufferCell[rectangle.Bottom - rectangle.Top + 1, rectangle.Right - rectangle.Left + 1];
            for (int i = 0; i <= rectangle.Bottom - rectangle.Top; i++)
            {
                for (int j = 0; j <= rectangle.Right - rectangle.Left; j++)
                {
                    bufferCell[i, j] = new BufferCell(cHARINFOArray[i, j].AsciiChar, (ConsoleColor)(cHARINFOArray[i, j].Attributes & 15), (ConsoleColor)((cHARINFOArray[i, j].Attributes & 240) / 16), BufferCellType.Complete);
                }
            }
            return(bufferCell);
        }