using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using Microsoft.Research.DynamicDataDisplay.Common;
namespace Microsoft.Research.DynamicDataDisplay.Charts.Navigation
{
///
/// Represents a horizontal scroll bar on the borrom of .
/// Uses ChartPlotter.Plotter.Viewport.DataDomain property as a source of data about current position and position limits.
///
public sealed class HorizontalScrollBar : PlotterScrollBar
{
///
/// Initializes a new instance of the class.
///
public HorizontalScrollBar()
{
ScrollBar.Orientation = Orientation.Horizontal;
}
protected override void UpdateScrollBar(Viewport2D viewport)
{
if (viewport != null && !viewport.Domain.IsEmpty)
{
var visibleRange = new Range(viewport.Visible.XMin, viewport.Visible.XMax);
double size = visibleRange.Max - visibleRange.Min;
ScrollBar.ViewportSize = size;
var domainRange = new Range(viewport.Domain.XMin, viewport.Domain.XMax);
ScrollBar.Minimum = domainRange.Min;
ScrollBar.Maximum = domainRange.Max - size;
ScrollBar.Value = visibleRange.Min;
ScrollBar.Visibility = Visibility.Visible;
}
else
{
ScrollBar.Visibility = Visibility.Collapsed;
}
}
protected override DataRect CreateVisibleRect(DataRect rect, double value)
{
rect.XMin = value;
return rect;
}
protected override Panel GetHostPanel(Plotter plotter)
{
return plotter.BottomPanel;
}
}
}