Пример #1
0
 public static extern bool FillConsoleOutputAttribute(
     IntPtr hConsoleOutput,
     ushort wAttribute,
     uint nLength,
     COORD dwWriteCoord,
     out uint lpNumberOfAttrsWritten
     );
Пример #2
0
        protected override void Setup()
        {
            var letterA = new CHAR_INFO {
                AsciiChar = 'A',
            };

            letterA.Attributes = (UInt16)
                (FOREGROUND_RED | FOREGROUND_INTENSITY |
                 BACKGROUND_RED | BACKGROUND_GREEN | BACKGROUND_INTENSITY);

            var charBufSize = new COORD {
                X = 1,
                Y = 1,
            };
            var characterPos = new COORD {
                X = 0,
                Y = 0,
            };

            var writeArea = new SMALL_RECT {
                Left = 0,
                Top = 0,
                Right = 0,
                Bottom = 0,
            };

            WriteConsoleOutput(
                WriteHandle, new CHAR_INFO[] { letterA }, charBufSize, characterPos, ref writeArea);
            Console.Write("\n");
        }
Пример #3
0
        protected override void Present()
        {
            var position = new COORD {
                    X = (short)Random.Next(Width),
                    Y = (short)Random.Next(Height),
                };

                if (Random.Next() % 2 == 0) {
                    SetConsoleTextAttribute(WriteHandle, 2);
                }
                else {
                    SetConsoleTextAttribute(WriteHandle, 10);
                }

                SetConsoleCursorPosition(WriteHandle, position);

                if (Random.Next() % 2 == 0) {
                    Console.Write("0");
                }
                else {
                    Console.Write("1");
                }
        }
Пример #4
0
        protected override void Setup()
        {
            var consoleBuffer = new CHAR_INFO[Width * Height];

            for (int h = 0; h < Height; ++h) {
                for (int w = 0; w < Width; ++w) {
                    consoleBuffer[w + Width * h].AsciiChar = 'A'/*(char)Random.Next(256)*/;
                    consoleBuffer[w + Width * h].Attributes = (UInt16)Random.Next(256);
                }
            }

            var charBufSize = new COORD {
                X = Width,
                Y = Height,
            };
            var characterPos = new COORD {
                X = 0,
                Y = 0,
            };

            WriteConsoleOutput(
                WriteHandle, consoleBuffer, charBufSize, characterPos, ref WindowSize);
        }
Пример #5
0
        public static void Initialize(string title, int width, int height)
        {
            WriteHandle   = GetStdHandle(STD_OUTPUT_HANDLE);
            Console.Title = title;

            Random = new Random(Guid.NewGuid().GetHashCode());
            Width  = (short)width;
            Height = (short)height;

            WindowSize = new SMALL_RECT {
                Left   = 0,
                Top    = 0,
                Right  = (short)(width - 1),
                Bottom = (short)(height - 1),
            };
            SetConsoleWindowInfo(WriteHandle, true, ref WindowSize);

            BufferSize = new COORD {
                X = 80,
                Y = 50,
            };
            SetConsoleScreenBufferSize(WriteHandle, BufferSize);
        }
Пример #6
0
        public static void Initialize(string title, int width, int height)
        {
            WriteHandle = GetStdHandle(STD_OUTPUT_HANDLE);
            Console.Title = title;

            Random = new Random(Guid.NewGuid().GetHashCode());
            Width = (short)width;
            Height = (short)height;

            WindowSize = new SMALL_RECT {
                Left = 0,
                Top = 0,
                Right = (short)(width - 1),
                Bottom = (short)(height - 1),
            };
            SetConsoleWindowInfo(WriteHandle, true, ref WindowSize);

            BufferSize = new COORD {
                X = 80,
                Y = 50,
            };
            SetConsoleScreenBufferSize(WriteHandle, BufferSize);
        }
Пример #7
0
 public static extern bool WriteConsoleOutput(
     IntPtr hConsoleOutput,
     CHAR_INFO[] lpBuffer,
     COORD dwBufferSize,
     COORD dwBufferCoord,
     ref SMALL_RECT lpWriteRegion
     );
Пример #8
0
 public static extern bool SetConsoleScreenBufferSize(
     IntPtr hConsoleOutput,
     COORD dwSize
     );
Пример #9
0
 public static extern bool SetConsoleDisplayMode(
     IntPtr ConsoleOutput,
     uint Flags,
     out COORD NewScreenBufferDimensions
     );
Пример #10
0
 public static extern bool SetConsoleCursorPosition(
     IntPtr hConsoleOutput,
     COORD dwCursorPosition
     );
Пример #11
0
 public static extern bool ScrollConsoleScreenBuffer(
     IntPtr hConsoleOutput,
     [In] ref SMALL_RECT lpScrollRectangle,
     IntPtr lpClipRectangle,
     COORD dwDestinationOrigin,
     [In] ref CHAR_INFO lpFill
     );
Пример #12
0
 public static extern bool ReadConsoleOutputCharacter(
     IntPtr hConsoleOutput,
     [Out] StringBuilder lpCharacter,
     uint nLength,
     COORD dwReadCoord,
     out uint lpNumberOfCharsRead
     );
Пример #13
0
 public static extern bool ReadConsoleOutputAttribute(
     IntPtr hConsoleOutput,
     [Out] ushort[] lpAttribute,
     uint nLength,
     COORD dwReadCoord,
     out uint lpNumberOfAttrsRead
     );
Пример #14
0
 public WINDOW_BUFFER_SIZE_RECORD(short x, short y)
 {
     dwSize = new COORD();
     dwSize.X = x;
     dwSize.Y = y;
 }
Пример #15
0
 public static extern bool SetConsoleCursorPosition(
     IntPtr hConsoleOutput,
     COORD dwCursorPosition
     );
Пример #16
0
 public WINDOW_BUFFER_SIZE_RECORD(short x, short y)
 {
     dwSize   = new COORD();
     dwSize.X = x;
     dwSize.Y = y;
 }
Пример #17
0
 public static extern bool SetConsoleScreenBufferSize(
     IntPtr hConsoleOutput,
     COORD dwSize
     );
Пример #18
0
 public static extern bool SetConsoleDisplayMode(
     IntPtr ConsoleOutput,
     uint Flags,
     out COORD NewScreenBufferDimensions
     );
Пример #19
0
 public static extern bool FillConsoleOutputCharacter(
     IntPtr hConsoleOutput,
     char cCharacter,
     uint nLength,
     COORD dwWriteCoord,
     out uint lpNumberOfCharsWritten
     );
Пример #20
0
 public static extern bool ReadConsoleOutput(
     IntPtr hConsoleOutput,
     [Out] CHAR_INFO[] lpBuffer,
     COORD dwBufferSize,
     COORD dwBufferCoord,
     ref SMALL_RECT lpReadRegion
     );