blob: cb9e2aa8b8b8771bd00dd849b7a84d185060c80f (
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
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
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
//using OpenTK.Graphics.OpenGL;
using Cairo;
using winColors = System.Drawing.Color;
using System.Diagnostics;
using System.Xml.Serialization;
using OpenTK.Input;
using System.ComponentModel;
namespace go
{
[DefaultTemplate("#go.Templates.Scrollbar.goml")]
public class Scrollbar : TemplatedControl, IValueChange
{
#region IValueChange implementation
public event EventHandler<ValueChangeEventArgs> ValueChanged;
#endregion
Orientation _orientation;
Slider _slider;
double _maximumScroll;
double _scroll;
public Scrollbar() : base()
{
}
protected override void loadTemplate(GraphicObject template = null)
{
base.loadTemplate (template);
_slider = this.child.FindByName ("Slider") as Slider;
}
[XmlAttributeAttribute()][DefaultValue(0.0)]
public virtual double MaximumScroll
{
get { return _maximumScroll; }
set {
if (_maximumScroll == value)
return;
_maximumScroll = value;
ValueChanged.Raise(this, new ValueChangeEventArgs ("MaximumScroll", _maximumScroll));
}
}
[XmlAttributeAttribute()][DefaultValue(0.0)]
public virtual double Scroll
{
get { return _scroll; }
set {
if (_scroll == value)
return;
_scroll = value;
if (_scroll < 0.0)
_scroll = 0.0;
else if (_scroll > _maximumScroll)
_scroll = _maximumScroll;
registerForGraphicUpdate ();
ValueChanged.Raise(this, new ValueChangeEventArgs ("Scroll", _scroll));
}
}
[XmlAttributeAttribute()][DefaultValue(Orientation.Vertical)]
public virtual Orientation Orientation
{
get { return _orientation; }
set {
if (_orientation == value)
return;
_orientation = value;
ValueChanged.Raise(this, new ValueChangeEventArgs ("Orientation", _orientation));
}
}
public void onScrollBack (object sender, MouseButtonEventArgs e)
{
Scroll -= _slider.LargeIncrement;
}
public void onScrollForth (object sender, MouseButtonEventArgs e)
{
Scroll += _slider.LargeIncrement;
}
public void onSliderValueChange(object sender, ValueChangeEventArgs e){
Scroll = Convert.ToDouble(e.NewValue);
}
}
}
|