private void OnResize(object sender, EventArgs e)
{
// Ignore resize events until intialization is complete
if (Game == null)
return;
var winWidth = window.ClientRectangle.Width;
var winHeight = window.ClientRectangle.Height;
var winRect = new Rectangle(0, 0, winWidth, winHeight);
// If window size is zero, leave bounds unchanged
// OpenTK appears to set the window client size to 1x1 when minimizing
if (winWidth <= 1 || winHeight <= 1)
return;
//If we've already got a pending change, do nothing
if (updateClientBounds)
return;
Game.GraphicsDevice.PresentationParameters.BackBufferWidth = winWidth;
Game.GraphicsDevice.PresentationParameters.BackBufferHeight = winHeight;
Game.GraphicsDevice.Viewport = new Viewport(0, 0, winWidth, winHeight);
clientBounds = winRect;
OnClientSizeChanged();
}