using System.Collections.Generic;
using System.Linq;
using System.Windows;
namespace RealTimeGraphX.WPF
{
///
/// Represents a graph grid lines component.
///
///
public class WpfGraphGridLines : WpfGraphComponentBase
{
///
/// Gets or sets the number of grid rows.
///
public int Rows
{
get { return (int)GetValue(RowsProperty); }
set { SetValue(RowsProperty, value); }
}
public static readonly DependencyProperty RowsProperty =
DependencyProperty.Register("Rows", typeof(int), typeof(WpfGraphGridLines), new PropertyMetadata(8, (d, e) => (d as WpfGraphGridLines).UpdateGridLines()));
///
/// Gets or sets the number of grid columns.
///
public int Columns
{
get { return (int)GetValue(ColumnsProperty); }
set { SetValue(ColumnsProperty, value); }
}
public static readonly DependencyProperty ColumnsProperty =
DependencyProperty.Register("Columns", typeof(int), typeof(WpfGraphGridLines), new PropertyMetadata(8, (d, e) => (d as WpfGraphGridLines).UpdateGridLines()));
///
/// Gets or sets the vertical items.
///
internal IEnumerable VerticalItems
{
get { return (IEnumerable)GetValue(VerticalItemsProperty); }
set { SetValue(VerticalItemsProperty, value); }
}
internal static readonly DependencyProperty VerticalItemsProperty =
DependencyProperty.Register("VerticalItems", typeof(IEnumerable), typeof(WpfGraphGridLines), new PropertyMetadata(null));
///
/// Gets or sets the horizontal items.
///
internal IEnumerable HorizontalItems
{
get { return (IEnumerable)GetValue(HorizontalItemsProperty); }
set { SetValue(HorizontalItemsProperty, value); }
}
internal static readonly DependencyProperty HorizontalItemsProperty =
DependencyProperty.Register("HorizontalItems", typeof(IEnumerable), typeof(WpfGraphGridLines), new PropertyMetadata(null));
///
/// Initializes the class.
///
static WpfGraphGridLines()
{
DefaultStyleKeyProperty.OverrideMetadata(typeof(WpfGraphGridLines), new FrameworkPropertyMetadata(typeof(WpfGraphGridLines)));
}
///
/// Initializes a new instance of the class.
///
public WpfGraphGridLines()
{
Loaded += GridLines_Loaded;
}
///
/// Handles the Loaded event of the GridLines control.
///
/// The source of the event.
/// The instance containing the event data.
private void GridLines_Loaded(object sender, RoutedEventArgs e)
{
UpdateGridLines();
}
///
/// Updates the grid lines.
///
private void UpdateGridLines()
{
VerticalItems = Enumerable.Range(0, Rows).ToList();
HorizontalItems = Enumerable.Range(0, Columns).ToList();
}
}
}