aboutsummaryrefslogtreecommitdiffstatsci
path: root/src/GraphicObjects/ScrollBar.cs
diff options
context:
space:
mode:
authorjpbruyere <jp.bruyere@hotmail.com>2016-01-30 09:42:37 +0100
committerjpbruyere <jp.bruyere@hotmail.com>2016-01-30 09:42:37 +0100
commit9fa17cdc9487e3ba92ef467c0c6d5d9941530de1 (patch)
tree0ac2e35c537e132bfa16adc486e7481e166a150d /src/GraphicObjects/ScrollBar.cs
parent0bf825fce6f1946034dbea6b1f7eb8d0dacdab8a (diff)
NUnit try, renaming, debugging and uniformizating
Diffstat (limited to 'src/GraphicObjects/ScrollBar.cs')
-rw-r--r--src/GraphicObjects/ScrollBar.cs101
1 files changed, 101 insertions, 0 deletions
diff --git a/src/GraphicObjects/ScrollBar.cs b/src/GraphicObjects/ScrollBar.cs
new file mode 100644
index 00000000..905efc55
--- /dev/null
+++ b/src/GraphicObjects/ScrollBar.cs
@@ -0,0 +1,101 @@
+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 Crow
+{
+ [DefaultTemplate("#Crow.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;
+ registerForGraphicUpdate ();
+ 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));
+ registerForGraphicUpdate ();
+ }
+ }
+ 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);
+ }
+
+ public override void OnLayoutChanges (LayoutingType layoutType)
+ {
+ OpenTKGameWindow.currentWindow.CursorVisible = true;
+ base.OnLayoutChanges (layoutType);
+ }
+ }
+}