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; } }
public MainGame() { base.Content.RootDirectory = "Content"; Content = base.Content; this.graphics = new GraphicsDeviceManager(this); //原本的分辨率默认值为720*1080,在其他大小的屏幕上会变形 //将当前屏幕的分辨率作为默认值…… this.previousWindowWidth = FullScreenHelper.GetSystemMetrics(FullScreenHelper.SM_CXSCREEN); this.previousWindowHeight = FullScreenHelper.GetSystemMetrics(FullScreenHelper.SM_CYSCREEN); this.graphics.PreferredBackBufferWidth = this.previousWindowWidth; this.graphics.PreferredBackBufferHeight = this.previousWindowHeight; base.Window.AllowUserResizing = true; DateTime buildDate = new FileInfo(Assembly.GetExecutingAssembly().Location).LastWriteTime; base.Window.Title = "中华三国志威力加强版(已命名修改版v.26 build-" + buildDate.Year + "-" + buildDate.Month + "-" + buildDate.Day + ")"; //System.Windows.Forms.Control control = System.Windows.Forms.Control.FromHandle(base.Window.Handle); this.GameForm = (System.Windows.Forms.Form)System.Windows.Forms.Form.FromHandle(this.Window.Handle); this.GameForm.WindowState = System.Windows.Forms.FormWindowState.Maximized; //this.GameForm = control as System.Windows.Forms.Form; this.GameForm.KeyDown += new KeyEventHandler(this.GameForm_KeyDown); int uFlags = 0x400; IntPtr systemMenu = GetSystemMenu(base.Window.Handle, false); int menuItemCount = GetMenuItemCount(systemMenu); RemoveMenu(systemMenu, menuItemCount - 1, uFlags); RemoveMenu(systemMenu, menuItemCount - 2, uFlags); Plugin.Plugins.FindPlugins(AppDomain.CurrentDomain.BaseDirectory + "GameComponents"); Plugin.Plugins.FindPlugins(AppDomain.CurrentDomain.BaseDirectory + "GamePlugins"); this.mainGameScreen = new MainGameScreen(this); base.Components.Add(this.mainGameScreen); }