private void ResetWindowBounds()
{
RectangleF frame;
RectangleF content;
var graphicsDeviceManager = (GraphicsDeviceManager)Game.Services.GetService(typeof(IGraphicsDeviceManager));
if (graphicsDeviceManager.IsFullScreen)
{
frame = NSScreen.MainScreen.Frame;
content = NSScreen.MainScreen.Frame;
}
else
{
content = _gameWindow.Bounds;
content.Width = Math.Min(
graphicsDeviceManager.PreferredBackBufferWidth,
NSScreen.MainScreen.VisibleFrame.Width);
content.Height = Math.Min(
graphicsDeviceManager.PreferredBackBufferHeight,
NSScreen.MainScreen.VisibleFrame.Height - GetTitleBarHeight());
frame = _mainWindow.Frame;
frame.X = Math.Max(frame.X, NSScreen.MainScreen.VisibleFrame.X);
frame.Y = Math.Max(frame.Y, NSScreen.MainScreen.VisibleFrame.Y);
frame.Width = content.Width;
frame.Height = content.Height + GetTitleBarHeight();
}
_mainWindow.SetFrame(frame, true);
_gameWindow.Bounds = content;
_gameWindow.Size = content.Size.ToSize();
// Now we set our Presentation Parameters
var device = (GraphicsDevice)graphicsDeviceManager.GraphicsDevice;
// FIXME: Eliminate the need for null checks by only calling
// ResetWindowBounds after the device is ready. Or,
// possibly break this method into smaller methods.
if (device != null)
{
PresentationParameters parms = device.PresentationParameters;
parms.BackBufferHeight = (int)content.Size.Height;
parms.BackBufferWidth = (int)content.Size.Width;
}
}