-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathProgram.cs
123 lines (106 loc) · 4.22 KB
/
Program.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
using System;
using System.IO;
using System.Drawing;
using System.Windows.Forms;
using Microsoft.Surface;
using Microsoft.Surface.Core;
using Microsoft.Xna.Framework;
namespace SUR_TUIO
{
/// <summary>
/// SUR TUIO 0.1
///
/// A simple TUIO server for SUR40
///
/// It sends all touches as TUIO pointers at the moment.
/// Finger's directions and objects will follow.
///
/// Based on Dominik Schmidt's .NET/C# TUIO server.
/// http://www.dominikschmidt.net/2010/11/net-c-tuio-server/
///
/// Copyright (c) 2012 Michael Zoellner
/// http://i.document.m05.de
///
/// Licensed under GPLv3 license.
/// http://www.gnu.org/licenses/gpl.html
/// </summary>
static class Program
{
static GameWindow Window;
[STAThread]
static void Main(string[] args)
{
Application.SetUnhandledExceptionMode(UnhandledExceptionMode.ThrowException);
GlobalizationSettings.ApplyToCurrentThread();
using (App1 app = new App1())
{
app.Run();
}
}
internal static Size WindowSize
{
get
{
return ((Form)Form.FromHandle(Window.Handle)).DesktopBounds.Size;
}
}
internal static void InitializeWindow(GameWindow window)
{
if (window == null)
{
throw new ArgumentNullException("window");
}
Window = window;
Form form = (Form)Form.FromHandle(Window.Handle);
form.LocationChanged += OnFormLocationChanged;
SetWindowStyle();
SetWindowSize();
}
private static void OnFormLocationChanged(object sender, EventArgs e)
{
if (SurfaceEnvironment.IsSurfaceEnvironmentAvailable)
{
Form form = (Form)Form.FromHandle(Window.Handle);
form.LocationChanged -= OnFormLocationChanged;
PositionWindow();
form.LocationChanged += OnFormLocationChanged;
}
}
internal static void PositionWindow()
{
int left = (InteractiveSurface.PrimarySurfaceDevice != null)
? InteractiveSurface.PrimarySurfaceDevice.WorkingAreaLeft
: Screen.PrimaryScreen.WorkingArea.Left;
int top = (InteractiveSurface.PrimarySurfaceDevice != null)
? InteractiveSurface.PrimarySurfaceDevice.WorkingAreaTop
: Screen.PrimaryScreen.WorkingArea.Top;
Form form = (Form)Form.FromHandle(Window.Handle);
FormWindowState windowState = form.WindowState;
form.WindowState = FormWindowState.Normal;
form.Location = new System.Drawing.Point(left, top);
form.WindowState = windowState;
}
private static void SetWindowStyle()
{
Window.AllowUserResizing = true;
Form form = (Form)Form.FromHandle(Window.Handle);
form.FormBorderStyle = (SurfaceEnvironment.IsSurfaceEnvironmentAvailable)
? FormBorderStyle.None
: FormBorderStyle.Sizable;
}
private static void SetWindowSize()
{
int width = 200; /* (InteractiveSurface.PrimarySurfaceDevice != null)
? InteractiveSurface.PrimarySurfaceDevice.WorkingAreaWidth
: Screen.PrimaryScreen.WorkingArea.Width;*/
int height = 200; /* (InteractiveSurface.PrimarySurfaceDevice != null)
? InteractiveSurface.PrimarySurfaceDevice.WorkingAreaHeight
: Screen.PrimaryScreen.WorkingArea.Height;*/
Form form = (Form)Form.FromHandle(Window.Handle);
form.ClientSize = new Size(width, height);
form.WindowState = (SurfaceEnvironment.IsSurfaceEnvironmentAvailable)
? FormWindowState.Normal
: FormWindowState.Normal;
}
}
}