public static void ToggleFullscreen() { isFullScreen = !isFullScreen; changeResolution = true; if (isFullScreen) { window.IsBorderless = true; window.Position = new Point(0, 0); graphics.PreferredBackBufferWidth = GraphicsAdapter.DefaultAdapter.CurrentDisplayMode.Width; //System.Windows.Forms.Screen.PrimaryScreen.Bounds.Width; graphics.PreferredBackBufferHeight = GraphicsAdapter.DefaultAdapter.CurrentDisplayMode.Height; //System.Windows.Forms.Screen.PrimaryScreen.Bounds.Height; graphics.ApplyChanges(); } else { window.IsBorderless = false; graphics.PreferredBackBufferWidth = windowResX; graphics.PreferredBackBufferHeight = windowResY; graphics.ApplyChanges(); CenterWindow(); } changeResolution = false; DrawM.ResizeWindow(); }
public void ToggleFullscreen() { isFullScreen = !isFullScreen; changeResolution = true; if (isFullScreen) { Rectangle screenRect = GetCurrentScreenRectangle(); window.Position = screenRect.Location; //window.Position = new Point((((int)window.Position.X + window.ClientBounds.Width / 2) / 1920) * 1920, 0); Thread.Sleep(50); // testing (maybe prevent fullscreen not working??) graphics.PreferredBackBufferWidth = screenRect.Width; //GraphicsAdapter.DefaultAdapter.CurrentDisplayMode.Width;//System.Windows.Forms.Screen.PrimaryScreen.Bounds.Width; graphics.PreferredBackBufferHeight = screenRect.Height; // GraphicsAdapter.DefaultAdapter.CurrentDisplayMode.Height;//System.Windows.Forms.Screen.PrimaryScreen.Bounds.Height; graphics.ApplyChanges(); #if DIRECTX window.IsBorderless = true; #else graphics.ToggleFullScreen(); #endif } else { #if DIRECTX window.IsBorderless = false; #else graphics.ToggleFullScreen(); #endif graphics.PreferredBackBufferWidth = windowResX; graphics.PreferredBackBufferHeight = windowResY; graphics.ApplyChanges(); CenterWindow(); } changeResolution = false; DrawM.ResizeWindow(); }