[Examples] Added PointToClient test

This commit is contained in:
thefiddler 2014-05-06 09:00:42 +02:00
parent 41276361fb
commit 3408523e27
2 changed files with 39 additions and 1 deletions

View file

@ -549,7 +549,7 @@
<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" />
@ -572,6 +572,7 @@
<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">

View file

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