示例#1
0
 public void SetOutputHandle(ConsoleOutputHandle outputHandle)
 {
     if (!NativeMethods.SetStdHandle(NativeMethods.STDOUT, outputHandle.DangerousGetHandle()))
     {
         throw Exceptions.Win32();
     }
 }
示例#2
0
 public void SetConsoleScreenBufferSize(ConsoleOutputHandle consoleOutputHandle, Size size)
 {
     if (!NativeMethods.SetConsoleScreenBufferSize(consoleOutputHandle, new COORD(size)))
     {
         throw Exceptions.Win32();
     }
 }
示例#3
0
 public void SetConsoleMode(ConsoleOutputHandle consoleOutputHandle, ConsoleOutputModes outputMode)
 {
     if (!NativeMethods.SetConsoleMode(consoleOutputHandle, outputMode))
     {
         throw Exceptions.Win32();
     }
 }
示例#4
0
        public void SetConsoleWindowSize(ConsoleOutputHandle consoleOutputHandle, Size size)
        {
            SMALL_RECT rect = new SMALL_RECT(size);

            if (!NativeMethods.SetConsoleWindowInfo(consoleOutputHandle, true, ref rect))
            {
                throw Exceptions.Win32();
            }
        }
示例#5
0
        public void WriteConsoleOutput(ConsoleOutputHandle consoleOutputHandle, CHAR_INFO[] buffer, Rectangle region)
        {
            SMALL_RECT rect = new SMALL_RECT(region);

            if (!NativeMethods.WriteConsoleOutput(consoleOutputHandle, buffer, new COORD(region), default, ref rect))
            {
                throw Exceptions.Win32();
            }
        }
示例#6
0
        public CHAR_INFO[] ReadConsoleOutput(ConsoleOutputHandle consoleOutputHandle, Rectangle region)
        {
            SMALL_RECT rect = new SMALL_RECT(region);

            CHAR_INFO[] buffer = new CHAR_INFO[region.Width * region.Height];
            if (!NativeMethods.ReadConsoleOutput(consoleOutputHandle, buffer, new COORD(region), default, ref rect))
            {
                throw Exceptions.Win32();
            }
            return(buffer);
        }
示例#7
0
        public CONSOLE_SCREEN_BUFFER_INFOEX GetConsoleScreenBufferInfo(ConsoleOutputHandle consoleOutputHandle)
        {
            CONSOLE_SCREEN_BUFFER_INFOEX info = new CONSOLE_SCREEN_BUFFER_INFOEX
            {
                Size = Marshal.SizeOf <CONSOLE_SCREEN_BUFFER_INFOEX>()
            };

            if (!NativeMethods.GetConsoleScreenBufferInfoEx(consoleOutputHandle, ref info))
            {
                throw Exceptions.Win32();
            }
            return(info);
        }
示例#8
0
        public void SetCursorInfo(ConsoleOutputHandle consoleOutputHandle, bool visible, int size, Point position)
        {
            if (!NativeMethods.SetConsoleCursorPosition(consoleOutputHandle, new COORD(position)))
            {
                throw Exceptions.Win32();
            }
            CONSOLE_CURSOR_INFO info = new CONSOLE_CURSOR_INFO
            {
                Size    = size,
                Visible = visible
            };

            if (!NativeMethods.SetConsoleCursorInfo(consoleOutputHandle, ref info))
            {
                throw Exceptions.Win32();
            }
        }
示例#9
0
        public (bool visible, int size, Point position) GetCursorInfo(ConsoleOutputHandle consoleOutputHandle)
        {
            if (!NativeMethods.GetConsoleCursorInfo(consoleOutputHandle, out var info))
            {
                throw Exceptions.Win32();
            }
            var infoEx = new CONSOLE_SCREEN_BUFFER_INFOEX
            {
                Size = Marshal.SizeOf <CONSOLE_SCREEN_BUFFER_INFOEX>()
            };

            if (!NativeMethods.GetConsoleScreenBufferInfoEx(consoleOutputHandle, ref infoEx))
            {
                throw Exceptions.Win32();
            }

            return(info.Visible, info.Size, new Point(infoEx.CursorPosition.X, infoEx.CursorPosition.Y));
        }
示例#10
0
 internal static extern bool GetConsoleScreenBufferInfoEx(ConsoleOutputHandle consoleOutputHandle, ref CONSOLE_SCREEN_BUFFER_INFOEX info);
示例#11
0
 public ConsoleOutputModes GetConsoleMode(ConsoleOutputHandle consoleOutputHandle) =>
 NativeMethods.GetConsoleMode(consoleOutputHandle.DangerousGetHandle(), out ConsoleOutputModes mode) ? mode : throw Exceptions.Win32();
示例#12
0
 internal static extern bool SetConsoleActiveScreenBuffer(ConsoleOutputHandle handle);
示例#13
0
 internal static extern bool SetConsoleCursorInfo(ConsoleOutputHandle consoleOutputHandle, ref CONSOLE_CURSOR_INFO cursorInfo);
示例#14
0
 internal static extern bool SetConsoleCursorPosition(ConsoleOutputHandle consoleOutputHandle, COORD position);
示例#15
0
 internal static extern bool SetConsoleMode(ConsoleOutputHandle consoleOutputHandle, ConsoleOutputModes outputMode);
示例#16
0
 internal static extern bool ReadConsoleOutput(
     ConsoleOutputHandle consoleOutputHandle,
     [Out] CHAR_INFO[] charInfoBuffer,
     COORD buffersize,
     COORD offset,
     ref SMALL_RECT useRegion);
示例#17
0
 public bool SetActiveConsoleScreenBuffer(ConsoleOutputHandle handle) => NativeMethods.SetConsoleActiveScreenBuffer(handle);
示例#18
0
 internal static extern bool SetConsoleWindowInfo(ConsoleOutputHandle outputHandle, bool absolute, [In] ref SMALL_RECT rect);
示例#19
0
 internal static extern bool SetConsoleScreenBufferSize(ConsoleOutputHandle outputHandle, [In] COORD size);