SadConsole.Font.ResizeGraphicsDeviceManager C# (CSharp) Method

ResizeGraphicsDeviceManager() public method

Resizes the graphics device manager based on this font's glyph size.
public ResizeGraphicsDeviceManager ( GraphicsDeviceManager manager, int width, int height, int additionalWidth, int additionalHeight ) : void
manager GraphicsDeviceManager Graphics device manager to resize.
width int The width glyphs.
height int The height glyphs.
additionalWidth int Additional pixel width to add to the resize.
additionalHeight int Additional pixel height to add to the resize.
return void
        public void ResizeGraphicsDeviceManager(GraphicsDeviceManager manager, int width, int height, int additionalWidth, int additionalHeight)
        {
            int oldWidth = manager.PreferredBackBufferWidth;
            int oldHeight = manager.PreferredBackBufferHeight;

            manager.PreferredBackBufferWidth = (Size.X * width) + additionalWidth;
            manager.PreferredBackBufferHeight = (Size.Y * height) + additionalHeight;

            Engine.WindowWidth = manager.PreferredBackBufferWidth;
            Engine.WindowHeight = manager.PreferredBackBufferHeight;

            int diffWidth = (Engine.WindowWidth - oldWidth) / 2;
            int diffHeight = (Engine.WindowHeight - oldHeight) / 2;

            if (Engine.MonoGameInstance != null)
                Engine.MonoGameInstance.Window.Position = new Point(Engine.MonoGameInstance.Window.Position.X - diffWidth, Engine.MonoGameInstance.Window.Position.Y - diffHeight);

            manager.ApplyChanges();
        }