[Examples] Added PointToClient test
authorthefiddler <stapostol@gmail.com>
Tue, 6 May 2014 07:00:42 +0000 (09:00 +0200)
committerthefiddler <stapostol@gmail.com>
Tue, 6 May 2014 07:00:42 +0000 (09:00 +0200)
Source/Examples/OpenTK.Examples.csproj
Source/Examples/OpenTK/Test/PointToClient.cs [new file with mode: 0644]

index d0724a0..7928ff0 100644 (file)
     <None Include="Data\Audio\the_ring_that_fell.wav">
       <CopyToOutputDirectory>Always</CopyToOutputDirectory>
     </None>
-       <None Include="Data\Textures\cursor.png">
+    <None Include="Data\Textures\cursor.png">
       <CopyToOutputDirectory>Always</CopyToOutputDirectory>
     </None>
     <EmbeddedResource Include="OpenGL\1.x\OpenGLDiagnostics.rtf" />
       <Link>Dependencies\x64\libSDL2.dylib</Link>
     </None>
     <Compile Include="OpenTK\Test\ExternalContext.cs" />
+    <Compile Include="OpenTK\Test\PointToClient.cs" />
   </ItemGroup>
   <ItemGroup>
     <BootstrapperPackage Include="Microsoft.Net.Client.3.5">
diff --git a/Source/Examples/OpenTK/Test/PointToClient.cs b/Source/Examples/OpenTK/Test/PointToClient.cs
new file mode 100644 (file)
index 0000000..78e281b
--- /dev/null
@@ -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"));
+            }
+        }
+    }
+}
+