public void CheckInput(DrawContext context) { var record = new NativeMethods.INPUT_RECORD(); uint recordLen = 0; if (!(NativeMethods.ReadConsoleInput(eventHandle, ref record, 1, ref recordLen))) { throw new Win32Exception(); } switch (record.EventType) { case NativeMethods.MOUSE_EVENT: //do something context.SetCursorPosition(record.MouseEvent.dwMousePosition.X, record.MouseEvent.dwMousePosition.Y); MouseEvent(new MouseEvent() { Position = new Position(record.MouseEvent.dwMousePosition.X, record.MouseEvent.dwMousePosition.Y), ButtonState = record.MouseEvent.dwButtonState, }); context.Invert(); break; case NativeMethods.KEY_EVENT: if (record.KeyEvent.wVirtualKeyCode == (int)ConsoleKey.Escape) { return; } break; } }
public override void Paint(DrawContext context) { base.Paint(context); context.SetCursorPosition(Position.X, Position.Y); context.Write(Title); }
private void DrawBackground(DrawContext context) { for (int col = 0; col < Size.Width; col++) { for (int row = 0; row < Size.Height; row++) { context.SetCursorPosition(col, row); context.Write(Background); } } }
public override void Paint(DrawContext context) { base.Paint(context); var parent = context.ControlStack.First(); for (int col = 0; col < parent.Size.Width; col++) { context.SetCursorPosition(col, 0); context.Write(Style[0]); } for (int col = 0; col < parent.Size.Width; col++) { context.SetCursorPosition(col, 0 + parent.Size.Height - 1); context.Write(Style[0]); } for (int row = 0; row < parent.Size.Height; row++) { context.SetCursorPosition(parent.Size.Width - 1, row); context.Write(Style[1]); } for (int row = 0; row < parent.Size.Height; row++) { context.SetCursorPosition(0, row); context.Write(Style[1]); } context.SetCursorPosition(0, 0); context.Write(Style[2]); context.SetCursorPosition(parent.Size.Width - 1, 0); context.Write(Style[3]); context.SetCursorPosition(0, parent.Size.Height - 1); context.Write(Style[4]); context.SetCursorPosition(+parent.Size.Width - 1, 0 + parent.Size.Height - 1); context.Write(Style[5]); }
public override void Paint(DrawContext context) { base.Paint(context); context.SetCursorPosition(1, 0); context.Write('┤'); context.SetCursorPosition(Size.Width - 2, 0); context.Write('├'); context.SetColor(ConsoleColor.Blue, ConsoleColor.White); for (int col = 2; col < Size.Width - 2; col++) { context.SetCursorPosition(col, 0); context.Write(' '); } context.SetCursorPosition(Size.Width - 8, 0); context.Write('-'); context.SetCursorPosition(Size.Width - 6, 0); context.Write('↕'); TitleLabel.Paint(context); CloseButton.Paint(context); for (int col = 1; col <= Size.Width; col++) { context.SetCursorPosition(col, Size.Height); context.Dark(); } for (int row = 1; row <= Size.Height; row++) { context.SetCursorPosition(Size.Width, row); context.Dark(); } }