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
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
|
using System;
using System.Xml.Serialization;
using System.ComponentModel;
using System.Diagnostics;
using OpenTK.Input;
namespace go
{
[DefaultTemplate("#go.Templates.Window.goml")]
public class Window : TemplatedContainer
{
Label _title;
Image _icon;
Container _contentContainer;
public override GraphicObject Content {
get {
return _contentContainer == null ? null : _contentContainer.Child;
}
set {
_contentContainer.SetChild(value);
}
}
[XmlAttributeAttribute()][DefaultValue("Window")]
public string Title {
get { return _title.Text; }
set {
if (_title == null)
return;
_title.Text = value;
}
}
public Window () : base()
{
}
void Window_MouseMove (object sender, OpenTK.Input.MouseMoveEventArgs e)
{
}
enum Direction
{
None,
N,
S,
E,
W,
NW,
NE,
SW,
SE
}
Direction currentDirection = Direction.None;
public override void onMouseMove (object sender, MouseMoveEventArgs e)
{
base.onMouseMove (sender, e);
OpenTKGameWindow otkgw = TopContainer as OpenTKGameWindow;
int borderLim = 5;
if (TopContainer.activeWidget == null) {
Direction lastDir = currentDirection;
if ((e.Position - this.Slot.TopLeft).Length < borderLim)
currentDirection = Direction.NW;
else if ((e.Position - this.Slot.TopRight).Length < borderLim)
currentDirection = Direction.NE;
else if ((e.Position - this.Slot.BottomLeft).Length < borderLim)
currentDirection = Direction.SW;
else if ((e.Position - this.Slot.BottomRight).Length < borderLim)
currentDirection = Direction.SE;
else
currentDirection = Direction.None;
if (currentDirection != lastDir) {
switch (currentDirection) {
case Direction.None:
otkgw.Cursor = XCursor.Default;
break;
case Direction.N:
otkgw.Cursor = XCursor.Cross;
break;
case Direction.S:
otkgw.Cursor = XCursor.Cross;
break;
case Direction.E:
otkgw.Cursor = XCursor.Cross;
break;
case Direction.W:
otkgw.Cursor = XCursor.Cross;
break;
case Direction.NW:
otkgw.Cursor = XCursor.NW;
break;
case Direction.NE:
otkgw.Cursor = XCursor.NE;
break;
case Direction.SW:
otkgw.Cursor = XCursor.SW;
break;
case Direction.SE:
otkgw.Cursor = XCursor.SE;
break;
}
}
return;
}
if (TopContainer.activeWidget != this)
return;
this.TopContainer.redrawClip.AddRectangle (this.ScreenCoordinates(this.Slot));
switch (currentDirection) {
case Direction.None:
this.Left += e.XDelta;
this.Top += e.YDelta;
break;
case Direction.N:
break;
case Direction.S:
break;
case Direction.E:
break;
case Direction.W:
break;
case Direction.NW:
this.Left += e.XDelta;
this.Top += e.YDelta;
this.Width -= e.XDelta;
this.Height -= e.YDelta;
break;
case Direction.NE:
this.Width += e.XDelta;
this.Top += e.YDelta;
this.Height -= e.YDelta;
break;
case Direction.SW:
this.Left += e.XDelta;
this.Width -= e.XDelta;
this.Height += e.YDelta;
break;
case Direction.SE:
this.Width += e.XDelta;
this.Height += e.YDelta;
break;
}
}
public override void onMouseLeave (object sender, MouseMoveEventArgs e)
{
base.onMouseLeave (sender, e);
currentDirection = Direction.None;
OpenTKGameWindow otkgw = TopContainer as OpenTKGameWindow;
otkgw.Cursor = XCursor.Default;
}
protected override void loadTemplate(GraphicObject template = null)
{
base.loadTemplate (template);
_contentContainer = this.child.FindByName ("Content") as Container;
_title = this.child.FindByName ("Title") as Label;
_icon = this.child.FindByName ("Icon") as Image;
}
void butQuitPress (object sender, MouseButtonEventArgs e)
{
TopContainer.DeleteWidget (this);
}
}
}
|