From b90acacb7dbef7d088d57a200cc4d71148bffd1e Mon Sep 17 00:00:00 2001 From: Roy Ben-Shabat Date: Sun, 15 Jul 2018 15:10:08 +0300 Subject: Implemented custom min max on single and multiple graphs on tech board. --- .../RealTimeGraphEx/Components/ComponentBase.cs | 11 +++++++++++ .../RealTimeGraphEx/Components/YAxisScroll.cs | 5 +++++ .../SideChains/RealTimeGraphEx/RealTimeGraphExBase.cs | 19 +++++++++++++++++-- 3 files changed, 33 insertions(+), 2 deletions(-) (limited to 'Software/Visual_Studio/SideChains') diff --git a/Software/Visual_Studio/SideChains/RealTimeGraphEx/Components/ComponentBase.cs b/Software/Visual_Studio/SideChains/RealTimeGraphEx/Components/ComponentBase.cs index 3e2294068..5bdef111c 100644 --- a/Software/Visual_Studio/SideChains/RealTimeGraphEx/Components/ComponentBase.cs +++ b/Software/Visual_Studio/SideChains/RealTimeGraphEx/Components/ComponentBase.cs @@ -37,10 +37,16 @@ namespace RealTimeGraphEx.Components { Graph.ZoomComplete += OnGraphZoomComplete; Graph.PanningComplete += OnGraphPanningComplete; + Graph.MinMaxChanged += Graph_MinMaxChanged; Render(Graph); } } + private void Graph_MinMaxChanged(object sender, EventArgs e) + { + OnGraphMinMaxChanged(); + } + public abstract void Render(RealTimeGraphExBase graph, bool animate = false); public void RemoveFromParent() @@ -97,5 +103,10 @@ namespace RealTimeGraphEx.Components { } + + protected virtual void OnGraphMinMaxChanged() + { + + } } } diff --git a/Software/Visual_Studio/SideChains/RealTimeGraphEx/Components/YAxisScroll.cs b/Software/Visual_Studio/SideChains/RealTimeGraphEx/Components/YAxisScroll.cs index 40a6ca5cb..618cdc27e 100644 --- a/Software/Visual_Studio/SideChains/RealTimeGraphEx/Components/YAxisScroll.cs +++ b/Software/Visual_Studio/SideChains/RealTimeGraphEx/Components/YAxisScroll.cs @@ -192,6 +192,11 @@ namespace RealTimeGraphEx.Components Render(Graph, true); } + protected override void OnGraphMinMaxChanged() + { + Render(Graph); + } + protected override void OnGraphPanningComplete(Point translate) { if (innerGrid != null) diff --git a/Software/Visual_Studio/SideChains/RealTimeGraphEx/RealTimeGraphExBase.cs b/Software/Visual_Studio/SideChains/RealTimeGraphEx/RealTimeGraphExBase.cs index f0c612608..a2060d10e 100644 --- a/Software/Visual_Studio/SideChains/RealTimeGraphEx/RealTimeGraphExBase.cs +++ b/Software/Visual_Studio/SideChains/RealTimeGraphEx/RealTimeGraphExBase.cs @@ -71,6 +71,11 @@ namespace RealTimeGraphEx /// public new event MouseEventHandler MouseLeave; + /// + /// Occurs when [minimum maximum changed]. + /// + public event EventHandler MinMaxChanged; + #endregion #region Protected Fields @@ -141,7 +146,12 @@ namespace RealTimeGraphEx set { SetValue(MaximumProperty, value); } } public static readonly DependencyProperty MaximumProperty = - DependencyProperty.Register("Maximum", typeof(double), typeof(RealTimeGraphExBase), new PropertyMetadata(255.0, new PropertyChangedCallback(CrossModelChanged))); + DependencyProperty.Register("Maximum", typeof(double), typeof(RealTimeGraphExBase), new PropertyMetadata(255.0, (d, e) => + { + var control = d as RealTimeGraphExBase; + CrossModelChanged(d, e); + control.MinMaxChanged?.Invoke(control, new EventArgs()); + })); /// /// Gets or sets the minimum expected value to be plotted on the graph (default 0). @@ -152,7 +162,12 @@ namespace RealTimeGraphEx set { SetValue(MinimumProperty, value); } } public static readonly DependencyProperty MinimumProperty = - DependencyProperty.Register("Minimum", typeof(double), typeof(RealTimeGraphExBase), new PropertyMetadata(0.0, new PropertyChangedCallback(CrossModelChanged))); + DependencyProperty.Register("Minimum", typeof(double), typeof(RealTimeGraphExBase), new PropertyMetadata(0.0, (d, e) => + { + var control = d as RealTimeGraphExBase; + CrossModelChanged(d, e); + control.MinMaxChanged?.Invoke(control, new EventArgs()); + })); /// /// Gets or sets the graph refresh rate in milliseconds (default 30, affects performance). -- cgit v1.3.1