/// <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();
}