From 10939fcaec86ab82766e9f5754bde350ef29bc3e Mon Sep 17 00:00:00 2001 From: thefiddler Date: Sun, 27 Apr 2014 09:39:18 +0200 Subject: [PATCH] [OpenTK] Add On* methods to raise events --- Source/OpenTK/Platform/NativeWindowBase.cs | 98 +++++++++++++++++++++- 1 file changed, 95 insertions(+), 3 deletions(-) diff --git a/Source/OpenTK/Platform/NativeWindowBase.cs b/Source/OpenTK/Platform/NativeWindowBase.cs index 66252fe1..ee974391 100644 --- a/Source/OpenTK/Platform/NativeWindowBase.cs +++ b/Source/OpenTK/Platform/NativeWindowBase.cs @@ -28,6 +28,7 @@ #endregion using System; +using System.ComponentModel; using System.Diagnostics; using System.Drawing; using OpenTK.Input; @@ -40,6 +41,92 @@ namespace OpenTK.Platform readonly LegacyInputDriver LegacyInputDriver = new LegacyInputDriver(); + #region Protected Members + + protected void OnMove(EventArgs e) + { + Move(this, e); + } + + protected void OnResize(EventArgs e) + { + Resize(this, e); + } + + protected void OnClosing(CancelEventArgs e) + { + Closing(this, e); + } + + protected void OnClosed(EventArgs e) + { + Closed(this, e); + } + + protected void OnDisposed(EventArgs e) + { + Disposed(this, e); + } + + protected void OnIconChanged(EventArgs e) + { + IconChanged(this, e); + } + + protected void OnTitleChanged(EventArgs e) + { + TitleChanged(this, e); + } + + protected void OnVisibleChanged(EventArgs e) + { + VisibleChanged(this, e); + } + + protected void OnFocusedChanged(EventArgs e) + { + FocusedChanged(this, e); + } + + protected void OnWindowBorderChanged(EventArgs e) + { + WindowBorderChanged(this, e); + } + + protected void OnWindowStateChanged(EventArgs e) + { + WindowStateChanged(this, e); + } + + protected void OnKeyDown(KeyboardKeyEventArgs e) + { + KeyDown(this, e); + } + + protected void OnKeyPress(KeyPressEventArgs e) + { + KeyPress(this, e); + } + + protected void OnKeyUp(KeyboardKeyEventArgs e) + { + KeyUp(this, e); + } + + protected void OnMouseLeave(EventArgs e) + { + MouseLeave(this, e); + } + + protected void OnMouseEnter(EventArgs e) + { + MouseEnter(this, e); + } + + #endregion + + #region INativeWindow Members + public event EventHandler Move = delegate { }; public event EventHandler Resize = delegate { }; public event EventHandler Closing = delegate { }; @@ -73,7 +160,7 @@ namespace OpenTK.Platform public abstract bool Visible { get; set; } - public abstract bool Exists { get; set; } + public abstract bool Exists { get; } public abstract IWindowInfo WindowInfo { get; } @@ -183,20 +270,25 @@ namespace OpenTK.Platform public abstract bool CursorVisible { get; set; } + #endregion + + #region IDisposable Members + public void Dispose() { Dispose(true); - GC.SuppressFinalize(); + GC.SuppressFinalize(this); } protected abstract void Dispose(bool disposing); - [Conditional("DEBUG")] ~NativeWindowBase() { Debug.Print("NativeWindowBase leaked, did you forget to call Dispose()?"); Dispose(false); } + + #endregion } }