[12503] | 1 | using System;
|
---|
| 2 | using System.Collections.Generic;
|
---|
| 3 | using System.Linq;
|
---|
| 4 | using System.Text;
|
---|
| 5 | using System.Windows;
|
---|
| 6 | using System.Windows.Controls;
|
---|
| 7 | using Microsoft.Research.DynamicDataDisplay.Common;
|
---|
| 8 |
|
---|
| 9 | namespace 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 | }
|
---|