Example #1
0
        public void ToggleFullScreen()
        {
            //原来的代码会和单挑程序冲突

            /*
             * if (this.graphics.GraphicsDevice.PresentationParameters.IsFullScreen)
             * {
             *  this.graphics.PreferredBackBufferWidth = this.previousWindowWidth;
             *  this.graphics.PreferredBackBufferHeight = this.previousWindowHeight;
             * }
             * else
             * {
             *  this.previousWindowWidth = this.graphics.GraphicsDevice.Viewport.Width;
             *  this.previousWindowHeight = this.graphics.GraphicsDevice.Viewport.Height;
             *  GraphicsAdapter adapter = this.graphics.GraphicsDevice.CreationParameters.Adapter;
             *  FullScreenHelper.FullScreen();
             *  this.graphics.PreferredBackBufferWidth = adapter.CurrentDisplayMode.Width;
             *  this.graphics.PreferredBackBufferHeight = adapter.CurrentDisplayMode.Height;
             * }
             * this.graphics.ToggleFullScreen();
             * GlobalVariables.FullScreen = this.graphics.GraphicsDevice.PresentationParameters.IsFullScreen;
             */
            //修改后的全屏代码
            if (this.IsFullScreen)
            {
                FullScreenHelper.RestoreFullScreen(this.GameForm.Handle);//传入窗体句柄
                this.IsFullScreen = false;
            }
            else
            {
                FullScreenHelper.FullScreen(this.GameForm.Handle);
                this.IsFullScreen = true;
            }
        }