From 8000c4689245d2d6e24c1ef94cadafa369a8e8cb Mon Sep 17 00:00:00 2001
From: the_fiddler <the_fiddler@ebc5dd9b-fb1d-0410-b6f8-d24c324e9604>
Date: Sun, 20 Apr 2008 17:59:05 +0000
Subject: [PATCH] Changed all GameWindow.Fullscreen properties to
 GameWindow.WindowState. Added WindowState test app.

---
 Source/Examples/Tests/GameWindowStates.cs     | 63 +++++++++++++++++++
 Source/Examples/Tutorial/T01_Simple_Window.cs |  6 +-
 Source/Examples/Tutorial/T02_Vertex_Arrays.cs |  7 ++-
 .../Examples/Tutorial/T04_Vertex_Lighting.cs  |  7 ++-
 Source/Examples/Tutorial/T10_GLSL_Cube.cs     |  7 ++-
 5 files changed, 80 insertions(+), 10 deletions(-)
 create mode 100644 Source/Examples/Tests/GameWindowStates.cs

diff --git a/Source/Examples/Tests/GameWindowStates.cs b/Source/Examples/Tests/GameWindowStates.cs
new file mode 100644
index 00000000..a858cd7b
--- /dev/null
+++ b/Source/Examples/Tests/GameWindowStates.cs
@@ -0,0 +1,63 @@
+#region --- License ---
+/* Copyright (c) 2006, 2007 Stefanos Apostolopoulos
+ * See license.txt for license info
+ */
+#endregion
+
+using System;
+using System.Collections.Generic;
+using System.Text;
+using System.Diagnostics;
+
+using OpenTK;
+using OpenTK.Graphics;
+
+namespace Examples.Tests
+{
+    [Example("GameWindow states.", ExampleCategory.Test)]
+    public class GameWindowStates : GameWindow
+    {
+        public GameWindowStates()
+            : base(800, 600)
+        {
+            this.VSync = VSyncMode.On;
+            this.Keyboard.KeyRepeat = true;
+            this.Keyboard.KeyUp += new OpenTK.Input.KeyUpEvent(Keyboard_KeyUp);
+
+            GL.ClearColor(System.Drawing.Color.SteelBlue);
+        }
+
+        void Keyboard_KeyUp(OpenTK.Input.KeyboardDevice sender, OpenTK.Input.Key key)
+        {
+            if (key == OpenTK.Input.Key.Escape)
+                this.Exit();
+
+            if (key == OpenTK.Input.Key.Space)
+            {
+                switch (this.WindowState)
+                {
+                    case WindowState.Normal: this.WindowState = WindowState.Maximized; break;
+                    case WindowState.Maximized: this.WindowState = WindowState.Minimized; break;
+                    case WindowState.Minimized: this.WindowState = WindowState.Fullscreen; break;
+                    case WindowState.Fullscreen: this.WindowState = WindowState.Normal; break;
+                }
+            }
+        }
+
+        public override void OnRenderFrame(RenderFrameEventArgs e)
+        {
+            GL.Clear(ClearBufferMask.ColorBufferBit);
+
+            SwapBuffers();
+        }
+
+        public static void Main()
+        {
+            using (GameWindowStates ex = new GameWindowStates())
+            {
+                Utilities.SetWindowTitle(ex);
+                ex.Run(20.0);
+            }
+        }
+    }
+}
diff --git a/Source/Examples/Tutorial/T01_Simple_Window.cs b/Source/Examples/Tutorial/T01_Simple_Window.cs
index b935ebc0..61abe5a6 100644
--- a/Source/Examples/Tutorial/T01_Simple_Window.cs
+++ b/Source/Examples/Tutorial/T01_Simple_Window.cs
@@ -38,8 +38,10 @@ namespace Examples.Tutorial
         /// <param name="key">The key that was pressed.</param>
         void Keyboard_KeyDown(KeyboardDevice sender, Key key)
         {
-            if ((sender[Key.AltLeft] || sender[Key.AltRight]) && sender[Key.Enter])
-                this.Fullscreen = !this.Fullscreen;
+            if (WindowState != WindowState.Fullscreen)
+                WindowState = WindowState.Fullscreen;
+            else
+                WindowState = WindowState.Normal;
 
             if (sender[Key.Escape])
                 this.Exit();
diff --git a/Source/Examples/Tutorial/T02_Vertex_Arrays.cs b/Source/Examples/Tutorial/T02_Vertex_Arrays.cs
index fe2aa3f6..59d3cde1 100644
--- a/Source/Examples/Tutorial/T02_Vertex_Arrays.cs
+++ b/Source/Examples/Tutorial/T02_Vertex_Arrays.cs
@@ -119,9 +119,10 @@ namespace Examples.Tutorial
 
             // Alt+Enter toggles fullscreen mode.
             if ((Keyboard[Key.AltLeft] || Keyboard[Key.AltRight]) && Keyboard[Key.Enter])
-            {
-                Fullscreen = !Fullscreen;
-            }
+                if (WindowState != WindowState.Fullscreen)
+                    WindowState = WindowState.Fullscreen;
+                else
+                    WindowState = WindowState.Normal;
 
             // Plus/Minus change the target render frequency.
             // PageUp/PageDown change the target update frequency.
diff --git a/Source/Examples/Tutorial/T04_Vertex_Lighting.cs b/Source/Examples/Tutorial/T04_Vertex_Lighting.cs
index 1ed5d4b4..e6229039 100644
--- a/Source/Examples/Tutorial/T04_Vertex_Lighting.cs
+++ b/Source/Examples/Tutorial/T04_Vertex_Lighting.cs
@@ -110,9 +110,10 @@ namespace Examples.Tutorial
 
             if ((Keyboard[OpenTK.Input.Key.AltLeft] || Keyboard[OpenTK.Input.Key.AltRight]) &&
                 Keyboard[OpenTK.Input.Key.Enter])
-            {
-                Fullscreen = !Fullscreen;
-            }
+                if (WindowState != WindowState.Fullscreen)
+                    WindowState = WindowState.Fullscreen;
+                else
+                    WindowState = WindowState.Normal;
 
             if (Mouse[OpenTK.Input.MouseButton.Left])
                 x_angle += Mouse.XDelta;
diff --git a/Source/Examples/Tutorial/T10_GLSL_Cube.cs b/Source/Examples/Tutorial/T10_GLSL_Cube.cs
index 91b56021..0b36314c 100644
--- a/Source/Examples/Tutorial/T10_GLSL_Cube.cs
+++ b/Source/Examples/Tutorial/T10_GLSL_Cube.cs
@@ -14,7 +14,7 @@ using System.ComponentModel;
 using System.Drawing;
 using System.Text;
 using System.Windows.Forms;
-using System.Threading;
+using System.Threading;
 using System.Diagnostics;
 using System.IO;
 
@@ -221,7 +221,10 @@ namespace Examples.Tutorial
 
             if ((Keyboard[OpenTK.Input.Key.AltLeft] || Keyboard[OpenTK.Input.Key.AltRight]) &&
                 Keyboard[OpenTK.Input.Key.Enter])
-                Fullscreen = !Fullscreen;
+                if (WindowState != WindowState.Fullscreen)
+                    WindowState = WindowState.Fullscreen;
+                else
+                    WindowState = WindowState.Normal;
         }
 
         #endregion