private void enterFullScreen() { //save window state before entering full screen so that it can be restored when exiting fullScreenSaveState.WindowState = this.WindowState; if (this.WindowState == FormWindowState.Maximized) { fullScreenSaveState.Location = this.RestoreBounds.Location; fullScreenSaveState.Size = this.RestoreBounds.Size; } else { fullScreenSaveState.Location = this.Location; fullScreenSaveState.Size = this.Size; } WinTaskbar.Hide(); this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None; //if the panel does not contain anything, setting the border to none completely breaks the layout for //some odd reason. Seems to be a WinForms bug and this is the workaround if (pictureBox.Bitmap != null) { pictureBox.BorderStyle = BorderStyle.None; } this.TopMost = true; this.WindowState = FormWindowState.Normal; this.Location = new Point(0, 0); this.Size = new Size(Screen.PrimaryScreen.Bounds.Size.Width, Screen.PrimaryScreen.Bounds.Size.Height); toolStrip.Visible = false; statusStrip.Visible = false; menuStrip.Visible = false; fullscreen = true; pictureBox.Refresh(); }
private void exitFullScreen() { WinTaskbar.Show(); toolStrip.Visible = true; statusStrip.Visible = true; menuStrip.Visible = true; this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.Sizable; this.TopMost = false; pictureBox.BorderStyle = BorderStyle.Fixed3D; //restore window state this.WindowState = fullScreenSaveState.WindowState; this.Location = fullScreenSaveState.Location; this.Size = fullScreenSaveState.Size; //if slideshow was on we disable it if (timerSlideShow.Enabled) { timerSlideShow.Stop(); } fullscreen = false; }