Free cookie consent management tool by TermsFeed Policy Generator

source: branches/HeuristicLab.Problems.GrammaticalOptimization/DynamicDataDisplay/Charts/Navigation/HorizontalScrollBar.cs @ 12747

Last change on this file since 12747 was 12503, checked in by aballeit, 10 years ago

#2283 added GUI and charts; fixed MCTS

File size: 1.7 KB
Line 
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  /// <summary>
12  /// Represents a horizontal scroll bar on the borrom of <see cref="Plotter"/>.
13  /// Uses ChartPlotter.Plotter.Viewport.DataDomain property as a source of data about current position and position limits.
14  /// </summary>
15  public sealed class HorizontalScrollBar : PlotterScrollBar
16  {
17    /// <summary>
18    /// Initializes a new instance of the <see cref="HorizontalScrollBar"/> class.
19    /// </summary>
20    public HorizontalScrollBar()
21    {
22      ScrollBar.Orientation = Orientation.Horizontal;
23    }
24
25    protected override void UpdateScrollBar(Viewport2D viewport)
26    {
27      if (viewport != null && !viewport.Domain.IsEmpty)
28      {
29        var visibleRange = new Range<double>(viewport.Visible.XMin, viewport.Visible.XMax);
30
31        double size = visibleRange.Max - visibleRange.Min;
32        ScrollBar.ViewportSize = size;
33
34        var domainRange = new Range<double>(viewport.Domain.XMin, viewport.Domain.XMax);
35        ScrollBar.Minimum = domainRange.Min;
36        ScrollBar.Maximum = domainRange.Max - size;
37
38        ScrollBar.Value = visibleRange.Min;
39
40        ScrollBar.Visibility = Visibility.Visible;
41      }
42      else
43      {
44        ScrollBar.Visibility = Visibility.Collapsed;
45      }
46    }
47
48    protected override DataRect CreateVisibleRect(DataRect rect, double value)
49    {
50      rect.XMin = value;
51      return rect;
52    }
53
54    protected override Panel GetHostPanel(Plotter plotter)
55    {
56      return plotter.BottomPanel;
57    }
58  }
59}
Note: See TracBrowser for help on using the repository browser.