PageRenderTime 10ms CodeModel.GetById 8ms app.highlight 1ms RepoModel.GetById 0ms app.codeStats 0ms

/Main/src/DynamicDataDisplay/Charts/Navigation/VerticalScrollBar.cs

#
C# | 68 lines | 54 code | 10 blank | 4 comment | 5 complexity | 42aac33d080b4f0dd0f60091dfaf621b MD5 | raw file
Possible License(s): CC-BY-SA-3.0
 1using System;
 2using System.Collections.Generic;
 3using System.Linq;
 4using System.Text;
 5using System.Windows;
 6using System.Windows.Controls;
 7using Microsoft.Research.DynamicDataDisplay.Common;
 8
 9namespace Microsoft.Research.DynamicDataDisplay.Charts.Navigation
10{
11	[Obsolete("Working wrongly.", true)]
12	public sealed class VerticalScrollBar : PlotterScrollBar
13	{
14		/// <summary>
15		/// Initializes a new instance of the <see cref="VerticalScrollBar"/> class.
16		/// </summary>
17		public VerticalScrollBar()
18		{
19			ScrollBar.Orientation = Orientation.Vertical;
20		}
21
22		private Range<double> GetRange(Rect domain)
23		{
24			return new Range<double>(domain.Top, domain.Bottom);
25		}
26
27		protected override DataRect CreateVisibleRect(DataRect rect, double scrollValue)
28		{
29			rect.YMin = scrollValue;
30			return rect;
31		}
32
33		protected override Panel GetHostPanel(Plotter plotter)
34		{
35			return plotter.LeftPanel;
36		}
37
38		protected override void UpdateScrollBar(Viewport2D viewport)
39		{
40			if (viewport != null && !viewport.Domain.IsEmpty)
41			{
42				if (ScrollBar.Track != null)
43				{
44					//ScrollBar.Track.IsDirectionReversed = true;
45				}
46
47				visibleRange = new Range<double>(viewport.Visible.YMin, viewport.Visible.YMax);
48				domainRange = new Range<double>(viewport.Domain.YMin, viewport.Domain.YMax);
49
50				double size = visibleRange.Max - visibleRange.Min;
51				ScrollBar.ViewportSize = size;
52
53				ScrollBar.Minimum = domainRange.Min + size;
54				ScrollBar.Maximum = domainRange.Max;
55
56				ScrollBar.Value = visibleRange.Min;
57				ScrollBar.Visibility = Visibility.Visible;
58			}
59			else
60			{
61				ScrollBar.Visibility = Visibility.Collapsed;
62			}
63		}
64
65		private Range<double> visibleRange;
66		private Range<double> domainRange;
67	}
68}