aboutsummaryrefslogtreecommitdiffstatsci
path: root/src/GraphicObjects/GraduatedSlider.cs
blob: b7a181e02f080da8e5f0b6e887cf2b8b7e0adb21 (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
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Cairo;
using System.Xml.Serialization;

namespace Crow
{
	public class GraduatedSlider : Slider
    {     
		#region CTOR
		public GraduatedSlider() : base()
		{}
		public GraduatedSlider(double minimum, double maximum, double step)
            : base()
        {
			Minimum = minimum;
			Maximum = maximum;
			SmallIncrement = step;
			LargeIncrement = step * 5;
        }
		#endregion

		protected override void DrawGraduations(Context gr, PointD pStart, PointD pEnd)
		{
			Rectangle r = ClientRectangle;
			Foreground.SetAsSource (gr);

			gr.LineWidth = 2;
			gr.MoveTo(pStart);
			gr.LineTo(pEnd);

			gr.Stroke();
			gr.LineWidth = 1;

			double sst = unity * SmallIncrement;
			double bst = unity * LargeIncrement;


			PointD vBar = new PointD(0, sst);
			for (double x = Minimum; x <= Maximum - Minimum; x += SmallIncrement)
			{
				double lineLength = r.Height / 3;
				if (x % LargeIncrement != 0)
					lineLength /= 3;
				PointD p = new PointD(pStart.X + x * unity, pStart.Y);
				gr.MoveTo(p);
				gr.LineTo(new PointD(p.X, p.Y + lineLength));
			}
			gr.Stroke();
		}
    }
}