Changed all GameWindow.Fullscreen properties to GameWindow.WindowState.

Added WindowState test app.
This commit is contained in:
the_fiddler 2008-04-20 17:59:05 +00:00
parent 35b58ffda7
commit c60558ed16
5 changed files with 80 additions and 10 deletions

View file

@ -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);
}
}
}
}

View file

@ -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();

View file

@ -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.

View file

@ -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;

View file

@ -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