aboutsummaryrefslogtreecommitdiffstatsci
path: root/src/GraphicObjects/Window.cs
blob: 7eb910cc95749b50acc20a555e15c13bbe037967 (plain)
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
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)
		{
			if (!e.Mouse.IsButtonDown (MouseButton.Left))
				return;
			this.TopContainer.redrawClip.AddRectangle (this.ScreenCoordinates(this.Slot));
			this.Left += e.XDelta;
			this.Top += e.YDelta;
			this.registerForGraphicUpdate ();			
		}

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


	}
}