Exemplo n.º 1
0
 /// <summary>
 /// Sets the active console screen buffer to the buffer referrenced by the sb parameter
 /// </summary>
 /// <param name="sb">The screen buffer that will become the active screen buffer.</param>
 public static void SetActiveScreenBuffer(ConsoleScreenBuffer sb)
 {
     if (!WinCon.SetConsoleActiveScreenBuffer(sb.Handle))
     {
         throw new IOException("Error setting active screen buffer.", Marshal.GetLastWin32Error());
     }
 }
Exemplo n.º 2
0
        public string ReadAll()
        {
            AttachConsole(_process.Id);
            _outputBuffer = GetActiveScreenBuffer();

            var builder = new StringBuilder(_outputBuffer.Width * _outputBuffer.Height);
            for (int i = 0; i < _outputBuffer.CursorTop + 1; i++)
            {
                bool isLastLine = i == _outputBuffer.CursorTop;
                if (isLastLine)
                {
                    builder.Append(Read(i, _outputBuffer.CursorLeft));
                    return builder.ToString();
                }

                builder.Append(Read(i, _outputBuffer.Width));
            }

            return builder.ToString();
        }
Exemplo n.º 3
0
 /// <summary>
 /// Sets the active console screen buffer to the buffer referrenced by the sb parameter
 /// </summary>
 /// <param name="sb">The screen buffer that will become the active screen buffer.</param>
 public static void SetActiveScreenBuffer(ConsoleScreenBuffer sb)
 {
     if (!WinCon.SetConsoleActiveScreenBuffer(sb.Handle))
     {
         throw new IOException("Error setting active screen buffer.", Marshal.GetLastWin32Error());
     }
 }