From 827b76b6e9666411ba92ac48bafac834d92402b3 Mon Sep 17 00:00:00 2001 From: the_fiddler Date: Sun, 9 Sep 2007 11:53:25 +0000 Subject: [PATCH] Improved documentation for DummyGLContext and Dummy. Disabled S02_RawInput_Logger for updating. Added WindowInfo.cs --- Source/Examples/Tests/S02_RawInput_Logger.cs | 2 +- Source/OpenTK/Platform/DummyGLContext.cs | 4 +- Source/OpenTK/Platform/DummyGLControl.cs | 4 +- Source/OpenTK/Platform/WindowInfo.cs | 127 +++++++++++++++++++ 4 files changed, 132 insertions(+), 5 deletions(-) create mode 100644 Source/OpenTK/Platform/WindowInfo.cs diff --git a/Source/Examples/Tests/S02_RawInput_Logger.cs b/Source/Examples/Tests/S02_RawInput_Logger.cs index a1de71d6..fc0f2c4f 100644 --- a/Source/Examples/Tests/S02_RawInput_Logger.cs +++ b/Source/Examples/Tests/S02_RawInput_Logger.cs @@ -18,7 +18,7 @@ using System.Diagnostics; namespace Examples.Tests { - public class S02_RawInput_Logger : GameWindow, IExample + public class S02_RawInput_Logger : GameWindow//, IExample { #region IExample Members diff --git a/Source/OpenTK/Platform/DummyGLContext.cs b/Source/OpenTK/Platform/DummyGLContext.cs index 709d953e..ccdc1da1 100644 --- a/Source/OpenTK/Platform/DummyGLContext.cs +++ b/Source/OpenTK/Platform/DummyGLContext.cs @@ -5,9 +5,9 @@ using System.Text; namespace OpenTK.Platform { /// - /// A dummy GLContext to be used inside the Visual Studio designer. + /// An empty IGLContext implementation to be used inside the Visual Studio designer. /// - internal class DummyGLContext : IGLContext + internal sealed class DummyGLContext : IGLContext { #region --- IGLContext Members --- diff --git a/Source/OpenTK/Platform/DummyGLControl.cs b/Source/OpenTK/Platform/DummyGLControl.cs index 88493fd8..eb16ef72 100644 --- a/Source/OpenTK/Platform/DummyGLControl.cs +++ b/Source/OpenTK/Platform/DummyGLControl.cs @@ -5,9 +5,9 @@ using System.Text; namespace OpenTK.Platform { /// - /// A dummy GLControl to be used inside the Visual Studio designer. + /// An IGLControl implementation to be used inside the Visual Studio designer. /// - internal class DummyGLControl : IGLControl + internal sealed class DummyGLControl : IGLControl { bool fullscreen; IGLContext glContext = new DummyGLContext(); diff --git a/Source/OpenTK/Platform/WindowInfo.cs b/Source/OpenTK/Platform/WindowInfo.cs new file mode 100644 index 00000000..230eabdc --- /dev/null +++ b/Source/OpenTK/Platform/WindowInfo.cs @@ -0,0 +1,127 @@ +using System; +using System.Collections.Generic; +using System.Text; +using System.Windows.Forms; + +namespace OpenTK.Platform +{ + /// + /// Describes a Windows.Form.Control, Windows.Forms.NativeWindow or OpenTK.GameWindow. + /// + public sealed class WindowInfo : IWindowInfo + { + IWindowInfo implementation; + + #region --- Constructors --- + + /// + /// Detects the underlying platform and constructs a new WindowInfo class. + /// + /// Raised when the underlying platform is not supported. + public WindowInfo() + { + switch (Environment.OSVersion.Platform) + { + case PlatformID.Unix: + case (PlatformID)128: + implementation = new X11.WindowInfo(); + break; + + case PlatformID.Win32NT: + case PlatformID.Win32S: + case PlatformID.Win32Windows: + case PlatformID.WinCE: + implementation = new Windows.WindowInfo(); + break; + + default: + throw new PlatformNotSupportedException("Your Operating System is not supported. Please refer to http://opentk.sourceforge.net for more information."); + } + } + + /// + /// Detects the underlying platform and constructs a new WindowInfo class describing the specified Control. + /// + /// The System.Windows.Forms.Control to get info from. + public WindowInfo(Control control) : this() + { + implementation.GetInfoFrom(control); + } + + /// + /// Detects the underlying platform and constructs a new WindowInfo class describing the specified NativeWindow. + /// + /// The System.Windows.Forms.NativeWindow to get info from. + public WindowInfo(NativeWindow window) : this() + { + implementation.GetInfoFrom(window); + } + + /// + /// Detects the underlying platform and constructs a new WindowInfo class describing the specified GameWindow. + /// + /// The OpenTK.GameWindow to get info from. + public WindowInfo(GameWindow window) : this() + { + implementation.GetInfoFrom(window); + } + + #endregion + + #region --- IWindowInfo Members --- + + /// + /// Gets the platform specific handle of the window described by the WindowInfo class. + /// + public IntPtr Handle + { + get { return implementation.Handle; } + } + + /// + /// Gets the parent of the window described by the WindowInfo class. + /// + public IWindowInfo Parent + { + get { return implementation.Parent; } + } + + /// + /// Updates the WindowInfo to describe the specified Control. + /// + /// The System.Windows.Forms.Control to describe. + public void GetInfoFrom(Control control) + { + implementation.GetInfoFrom(control); + } + + /// + /// Updates the WindowInfo to describe the specified NativeWindow. + /// + /// The System.Windows.Forms.NativeWindow to describe. + public void GetInfoFrom(NativeWindow window) + { + implementation.GetInfoFrom(window); + } + + /// + /// Updates the WindowInfo to describe the specified GameWindow. + /// + /// The OpenTK.GameWindow to describe. + public void GetInfoFrom(GameWindow window) + { + implementation.GetInfoFrom(window); + } + + /// + /// Updates the WindowInfo using the specified WindowInfo. + /// + /// The OpenTK.Platform.Window to get information from. + public void GetInfoFrom(IWindowInfo info) + { + implementation.GetInfoFrom(info); + } + + #endregion + } +}