示例#1
0
        //---------------------------------------------------------------------------

        public static void SetWindowFormat(GraphicsDeviceManager graphics, GameWindow window, EWindowFormat eWindowFormat)
        {
            switch (eWindowFormat)
            {
            case EWindowFormat.Windowed:
            {
                graphics.PreferredBackBufferWidth  = m_WindowWidth;
                graphics.PreferredBackBufferHeight = m_WindowHeight;
                graphics.IsFullScreen    = false;
                window.IsBorderless      = false;
                window.Position          = new Point(100, 100);
                window.AllowUserResizing = true;
                break;
            }

            case EWindowFormat.CenteredWindow:
            {
                graphics.PreferredBackBufferWidth  = m_WindowWidth;
                graphics.PreferredBackBufferHeight = m_WindowHeight;
                graphics.IsFullScreen    = false;
                window.IsBorderless      = false;
                window.Position          = new Point((int)((m_displayWidth - graphics.PreferredBackBufferWidth) / 2), (int)((m_displayHeight - graphics.PreferredBackBufferHeight) / 2));
                window.AllowUserResizing = false;
                break;
            }

            case EWindowFormat.Fullscreen:
            {
                graphics.PreferredBackBufferWidth  = m_displayWidth;
                graphics.PreferredBackBufferHeight = m_displayHeight;
                window.IsBorderless      = false;
                window.Position          = Point.Zero;
                window.AllowUserResizing = true;
                break;
            }

            case EWindowFormat.BorderlessFullscreen:
            {
                graphics.IsFullScreen    = true;
                window.IsBorderless      = true;
                window.AllowUserResizing = false;
                break;
            }
            }
        }
示例#2
0
        //---------------------------------------------------------------------------

        public static void SetWindowSettings(GraphicsDeviceManager graphics, GameWindow window, int width = 960, int height = 540, int xPos = 100, int yPos = 100, EWindowFormat eWindowFormat = 0)
        {
            graphics.PreferredBackBufferWidth  = width;
            graphics.PreferredBackBufferHeight = height;
            m_WindowWidth  = width;
            m_WindowHeight = height;

            window.Position = new Point(xPos, yPos);

            SetWindowFormat(graphics, window, eWindowFormat);

            graphics.ApplyChanges();
        }