using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows; using System.Windows.Controls; using System.Windows.Data; using System.Windows.Documents; using System.Windows.Input; using System.Windows.Media; using System.Windows.Media.Imaging; using System.Windows.Navigation; using System.Windows.Shapes; namespace RealTimeGraphX.WPF.Components { /// /// Represents a graph grid lines component. /// /// public class GraphGridLines : GraphSurfaceComponentBase { /// /// 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(GraphGridLines), new PropertyMetadata(8, (d, e) => (d as GraphGridLines).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(GraphGridLines), new PropertyMetadata(8, (d, e) => (d as GraphGridLines).UpdateGridLines())); /// /// Gets or sets the vertical items. /// internal IEnumerable VerticalItems { get { return (IEnumerable)GetValue(VerticalItemsProperty); } set { SetValue(VerticalItemsProperty, value); } } public static readonly DependencyProperty VerticalItemsProperty = DependencyProperty.Register("VerticalItems", typeof(IEnumerable), typeof(GraphGridLines), new PropertyMetadata(null)); /// /// Gets or sets the horizontal items. /// internal IEnumerable HorizontalItems { get { return (IEnumerable)GetValue(HorizontalItemsProperty); } set { SetValue(HorizontalItemsProperty, value); } } public static readonly DependencyProperty HorizontalItemsProperty = DependencyProperty.Register("HorizontalItems", typeof(IEnumerable), typeof(GraphGridLines), new PropertyMetadata(null)); /// /// Initializes the class. /// static GraphGridLines() { DefaultStyleKeyProperty.OverrideMetadata(typeof(GraphGridLines), new FrameworkPropertyMetadata(typeof(GraphGridLines))); } /// /// Initializes a new instance of the class. /// public GraphGridLines() { 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(); } } }