Exemplo n.º 1
0
        /// <summary>
        /// Starts the Painter with the specified size and refresh rate.
        /// </summary>
        /// <param name="width">The width of the console, in units.</param>
        /// <param name="height">The height of the console, in units.</param>
        /// <param name="bufferRefreshRate">The refresh rate for the back buffer.</param>
        public static void Run(int width, int height, int bufferRefreshRate)
        {
            Console.CursorVisible = false;
            Console.SetWindowSize(width, height);
            Console.SetBufferSize(width, height);

            refreshInterval = bufferRefreshRate;

            // Make the buffers

            backBuffer = activeBuffer = ConsoleBuffer.CreateScreenBuffer();
            frontBuffer = ConsoleBuffer.CreateScreenBuffer();

            // Trigger any Starting events and set the Enabled flag to true.

            if (Starting != null)
            {
                Starting(null, null);
            }

            enabled = true;

            // Center the console window.

            Rectangle windowRect = new Rectangle();
            Native.GetWindowRect(consoleHandle, out windowRect);
            int halfWidth = windowRect.Right / 2;
            int halfHeight = windowRect.Bottom / 2;
            var screenBounds = Screen.PrimaryScreen.Bounds;
            Native.SetWindowPos(consoleHandle, HWND.Top, screenBounds.Width / 2 - halfWidth, screenBounds.Height / 2 - halfHeight, windowRect.Width, windowRect.Height, SWP.SHOWWINDOW);

            // Start threads, add hooks.

            drawThread = null;
            drawThread = new Thread(GraphicsDrawThread);
            drawThread.Start();

            renderThread = null;
            renderThread = new Thread(GraphicsRenderThread);
            renderThread.Start();

            AddHooks();

            Native.SetConsoleCtrlHandler(closeEvent, true);

            Application.Run();
        }
Exemplo n.º 2
0
 public static extern bool GetWindowRect(IntPtr hwnd, out Rectangle lpRect);
Exemplo n.º 3
0
 /// <summary>
 /// Draws a box from the specified rectangle and brush information.
 /// </summary>
 /// <param name="rectangle">The bounds of the box to draw.</param>
 /// <param name="thickness">The border thickness of the box.</param>
 /// <param name="border">the border brush of the box.</param>
 /// <param name="fill">The fill brush of the box.</param>
 public void DrawBox(ref Rectangle rectangle, int thickness, BufferBrush border, BufferBrush fill)
 {
     DrawBox(rectangle.Top, rectangle.Left, rectangle.Width, rectangle.Height, thickness, border, fill);
 }
Exemplo n.º 4
0
 public static extern bool GetClientRect(IntPtr hwnd, out Rectangle lpRect);