From 3408523e27e2590a67b1fc7f79eae4c75fe355e0 Mon Sep 17 00:00:00 2001 From: thefiddler Date: Tue, 6 May 2014 09:00:42 +0200 Subject: [PATCH] [Examples] Added PointToClient test --- Source/Examples/OpenTK.Examples.csproj | 3 +- Source/Examples/OpenTK/Test/PointToClient.cs | 37 ++++++++++++++++++++ 2 files changed, 39 insertions(+), 1 deletion(-) create mode 100644 Source/Examples/OpenTK/Test/PointToClient.cs diff --git a/Source/Examples/OpenTK.Examples.csproj b/Source/Examples/OpenTK.Examples.csproj index d0724a0a..7928ff09 100644 --- a/Source/Examples/OpenTK.Examples.csproj +++ b/Source/Examples/OpenTK.Examples.csproj @@ -549,7 +549,7 @@ Always - + Always @@ -572,6 +572,7 @@ Dependencies\x64\libSDL2.dylib + diff --git a/Source/Examples/OpenTK/Test/PointToClient.cs b/Source/Examples/OpenTK/Test/PointToClient.cs new file mode 100644 index 00000000..78e281b6 --- /dev/null +++ b/Source/Examples/OpenTK/Test/PointToClient.cs @@ -0,0 +1,37 @@ +using System; +using System.Diagnostics; +using System.Drawing; +using OpenTK; + +namespace Examples.Tests +{ + [Example("PointToClient Test", ExampleCategory.OpenTK, "NativeWindow")] + public class PointToClientTest + { + public static void Main() + { + using (var window = new NativeWindow()) + { + Trace.WriteLine(String.Format("Window bounds: {0}", window.Bounds)); + Trace.WriteLine(String.Format("Window client: {0}", window.ClientRectangle)); + + Point pclient = new Point(100, 100); + Point pscreen = window.PointToScreen(pclient); + Point ptest = window.PointToClient(pscreen); + Trace.WriteLine(String.Format("Client: {0} -> Screen: {1} -> Client: {2}", + pclient, pscreen, ptest)); + Trace.WriteLine(String.Format("Test {0}", + ptest == pclient ? "succeeded" : "failed")); + + pscreen = new Point(100, 100); + pclient = window.PointToClient(pscreen); + ptest = window.PointToScreen(pclient); + Trace.WriteLine(String.Format("Screen: {0} -> Client: {1} -> Screen: {2}", + pscreen, pclient, ptest)); + Trace.WriteLine(String.Format("Test {0}", + ptest == pscreen ? "succeeded" : "failed")); + } + } + } +} +