aboutsummaryrefslogtreecommitdiffstats
path: root/Software/Visual_Studio/SideChains/RealTimeGraphEx/DirectXGraphs
diff options
context:
space:
mode:
authorRoy Ben-Shabat <Roy@Twine-s.com>2018-01-16 12:17:10 +0200
committerRoy Ben-Shabat <Roy@Twine-s.com>2018-01-16 12:17:10 +0200
commit0fda2ba3ff49bdc1ffc6833f658e2164af187008 (patch)
tree6f3a24d0671ebda50debb8511ab40e0bda0a0df0 /Software/Visual_Studio/SideChains/RealTimeGraphEx/DirectXGraphs
parent28103646681686bf1b58275d5dbccb92d2b26f9f (diff)
downloadTango-0fda2ba3ff49bdc1ffc6833f658e2164af187008.tar.gz
Tango-0fda2ba3ff49bdc1ffc6833f658e2164af187008.zip
Embedded RealTimeGraphEx library to solution.
Added graphs to technician view. Implemented simple sensors data test using Machine Emulator.
Diffstat (limited to 'Software/Visual_Studio/SideChains/RealTimeGraphEx/DirectXGraphs')
-rw-r--r--Software/Visual_Studio/SideChains/RealTimeGraphEx/DirectXGraphs/RealTimeGraphExDirectXLineErase.cs186
-rw-r--r--Software/Visual_Studio/SideChains/RealTimeGraphEx/DirectXGraphs/RealTimeGraphExDirectXLineScroll.cs276
-rw-r--r--Software/Visual_Studio/SideChains/RealTimeGraphEx/DirectXGraphs/RealTimeGraphExDirectXMultiLineErase.cs225
-rw-r--r--Software/Visual_Studio/SideChains/RealTimeGraphEx/DirectXGraphs/RealTimeGraphExDirectXMultiLineScroll.cs266
4 files changed, 953 insertions, 0 deletions
diff --git a/Software/Visual_Studio/SideChains/RealTimeGraphEx/DirectXGraphs/RealTimeGraphExDirectXLineErase.cs b/Software/Visual_Studio/SideChains/RealTimeGraphEx/DirectXGraphs/RealTimeGraphExDirectXLineErase.cs
new file mode 100644
index 000000000..ef744107a
--- /dev/null
+++ b/Software/Visual_Studio/SideChains/RealTimeGraphEx/DirectXGraphs/RealTimeGraphExDirectXLineErase.cs
@@ -0,0 +1,186 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Windows;
+using System.Windows.Media;
+using System.Windows.Media.Imaging;
+using System.Windows.Threading;
+using RealTimeGraphEx.Models;
+using RealTimeGraphEx.DataSeries;
+using RealTimeGraphEx.Controllers;
+using System.Runtime.ExceptionServices;
+using RealTimeGraphEx.DX2D;
+using RealTimeGraphEx.FastGraphs;
+using System.Windows.Controls;
+
+namespace RealTimeGraphEx.DirectXGraphs
+{
+ /// <summary>
+ /// Represents a real-time graph with a single scrollable line.
+ /// </summary>
+ public class RealTimeGraphExDirectXLineErase : RealTimeGraphExDirectXLineScroll
+ {
+ #region Cross Thread Fields
+
+ protected Brush _markerBrush;
+ protected bool _showMarker;
+ protected double _markerStrokeWidth;
+ protected int _currentReplaceIndex;
+
+ #endregion
+
+ #region Properties
+
+ public Brush MarkerBrush
+ {
+ get { return (Brush)GetValue(MarkerBrushProperty); }
+ set { SetValue(MarkerBrushProperty, value); }
+ }
+ public static readonly DependencyProperty MarkerBrushProperty =
+ DependencyProperty.Register("MarkerBrush", typeof(Brush), typeof(RealTimeGraphExDirectXLineErase), new PropertyMetadata(Brushes.Red, new PropertyChangedCallback(CrossModelChanged)));
+
+ public bool ShowMarker
+ {
+ get { return (bool)GetValue(ShowMarkerProperty); }
+ set { SetValue(ShowMarkerProperty, value); }
+ }
+ public static readonly DependencyProperty ShowMarkerProperty =
+ DependencyProperty.Register("ShowMarker", typeof(bool), typeof(RealTimeGraphExDirectXLineErase), new PropertyMetadata(true, new PropertyChangedCallback(CrossModelChanged)));
+
+ public double MarkerStrokeWidth
+ {
+ get { return (double)GetValue(MarkerStrokeWidthProperty); }
+ set { SetValue(MarkerStrokeWidthProperty, value); }
+ }
+ public static readonly DependencyProperty MarkerStrokeWidthProperty =
+ DependencyProperty.Register("MarkerStrokeWidth", typeof(double), typeof(RealTimeGraphExDirectXLineErase), new PropertyMetadata(1.0, new PropertyChangedCallback(CrossModelChanged)));
+
+ #endregion
+
+ #region Constructor
+
+ public RealTimeGraphExDirectXLineErase()
+ : base()
+ {
+
+ }
+
+ #endregion
+
+ #region Override Methods
+
+ protected override void Initialize()
+ {
+ base.Initialize();
+ dxGraph = new DXGraphSurfaceSingleErase() { HorizontalAlignment = System.Windows.HorizontalAlignment.Left, VerticalAlignment = System.Windows.VerticalAlignment.Stretch };
+
+ gridMain.Children.Remove(img);
+
+ if (!gridMain.Children.Contains(dxGraph))
+ {
+ gridMain.Children.Add(dxGraph);
+ }
+
+ dxGraph.IsHitTestVisible = false;
+ Grid.SetColumnSpan(dxGraph, 3);
+ }
+
+ protected override void OnSetCrossThreadFields()
+ {
+ base.OnSetCrossThreadFields();
+
+ this.Dispatcher.Invoke(() =>
+ {
+ _markerBrush = MarkerBrush;
+ _markerStrokeWidth = MarkerStrokeWidth;
+ _showMarker = ShowMarker;
+
+ }, DispatcherPriority.Send);
+ }
+
+ protected override void OnClearGraph()
+ {
+ base.OnClearGraph();
+ _currentReplaceIndex = 0;
+ }
+
+ protected internal override void OnRenderGraph()
+ {
+ if (_graphController.dataSeries != null && _graphController.dataSeries.Points != null && _graphController.dataSeries.Points.Count > 0 && _width > 1 && _height > 1)
+ {
+ var points = _graphController.dataSeries.Points.GetAndClearAllPoints();
+
+ if (!_isPaused)
+ {
+
+ for (int i = 0; i < points.Count; i++)
+ {
+ double value = points[i];
+ NormalizeValue(ref value);
+
+ if (graphPolygon.Count > _maxPoints)
+ {
+ graphPolygon.Replace(value, _currentReplaceIndex++);
+ }
+ else
+ {
+ graphPolygon.Add(value);
+ }
+
+ if (_currentReplaceIndex > graphPolygon.Count - 1)
+ {
+ _currentReplaceIndex = 0;
+ }
+ }
+ }
+ }
+
+ updateCounter++;
+
+ if (updateCounter >= 1)
+ {
+ updateCounter = 0;
+
+ if (!_disableRendering)
+ {
+ OnDrawVisuals();
+ }
+ }
+ }
+
+ protected override void OnDrawVisuals()
+ {
+ if (graphPolygon.Count > 0)
+ {
+ double markerPosition = 0;
+ if (_currentReplaceIndex > 0)
+ {
+ markerPosition = (((_currentReplaceIndex - 1) * GetPolygonScaleFactor()) + _offSetX);
+ }
+
+ Brush stroke = _graphController.dataSeries.stroke != null ? _graphController.dataSeries.stroke : _stroke;
+ Brush fill = _graphController.dataSeries.fill != null ? _graphController.dataSeries.fill : _fill;
+ (dxGraph as DXGraphSurfaceSingleErase).SetProperties(
+ graphPolygon.ToDXPolygonPoints(_offSetX, _offSetY, GetPolygonScaleFactor(), ConvertYToImageYFliped),
+ _fillGraph ? graphPolygon.ToDXPolygonPointsFill(_offSetX, _offSetY, _mainWidth, _mainHeight, GetPolygonScaleFactor(),
+ ConvertYToImageYFliped) : null,
+ stroke,
+ _strokeWidth,
+ _fillGraph,
+ fill,
+ _antialiased,
+ _markerBrush,
+ markerPosition,
+ _showMarker,
+ _markerStrokeWidth);
+
+ dxGraph.EnableRendering();
+ }
+ }
+
+ #endregion
+
+ }
+}
diff --git a/Software/Visual_Studio/SideChains/RealTimeGraphEx/DirectXGraphs/RealTimeGraphExDirectXLineScroll.cs b/Software/Visual_Studio/SideChains/RealTimeGraphEx/DirectXGraphs/RealTimeGraphExDirectXLineScroll.cs
new file mode 100644
index 000000000..e85d56a4d
--- /dev/null
+++ b/Software/Visual_Studio/SideChains/RealTimeGraphEx/DirectXGraphs/RealTimeGraphExDirectXLineScroll.cs
@@ -0,0 +1,276 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Windows;
+using System.Windows.Media;
+using System.Windows.Media.Imaging;
+using System.Windows.Threading;
+using RealTimeGraphEx.Models;
+using RealTimeGraphEx.DataSeries;
+using RealTimeGraphEx.Controllers;
+using System.Runtime.ExceptionServices;
+using RealTimeGraphEx.DX2D;
+using RealTimeGraphEx.FastGraphs;
+using System.Windows.Controls;
+
+namespace RealTimeGraphEx.DirectXGraphs
+{
+ /// <summary>
+ /// Represents a real-time graph with a single scrollable line.
+ /// </summary>
+ public class RealTimeGraphExDirectXLineScroll : RealTimeGraphExBase
+ {
+
+ #region Protected Fields
+
+ protected Direct2DControl dxGraph;
+ protected ConcurrentpointsList graphPolygon;
+ protected int updateCounter;
+
+ #endregion
+
+ #region Cross Thread Fields
+
+ protected GraphController _graphController;
+ protected int _maxPoints;
+ protected double _scaleFactor;
+ protected Brush _stroke;
+ protected Brush _fill;
+ protected bool _fillGraph;
+ protected double _strokeWidth;
+
+ #endregion
+
+ #region Properties
+
+ /// <summary>
+ /// Gets or sets the maximum vectorsCollection to display on the graph (default 1000, affects performance).
+ /// </summary>
+ public int MaxPoints
+ {
+ get { return (int)GetValue(MaxPointsProperty); }
+ set { SetValue(MaxPointsProperty, value); }
+ }
+ public static readonly DependencyProperty MaxPointsProperty =
+ DependencyProperty.Register("MaxPoints", typeof(int), typeof(RealTimeGraphExDirectXLineScroll), new PropertyMetadata(1000, new PropertyChangedCallback(CrossModelChanged)));
+
+
+ /// <summary>
+ /// Gets or sets the graph fill color.
+ /// </summary>
+ public Brush Stroke
+ {
+ get { return (Brush)GetValue(StrokeProperty); }
+ set { SetValue(StrokeProperty, value); }
+ }
+ public static readonly DependencyProperty StrokeProperty =
+ DependencyProperty.Register("Stroke", typeof(Brush), typeof(RealTimeGraphExDirectXLineScroll), new PropertyMetadata(Brushes.Black, new PropertyChangedCallback(CrossModelChanged)));
+
+
+
+ public double StrokeWidth
+ {
+ get { return (double)GetValue(StrokeWidthProperty); }
+ set { SetValue(StrokeWidthProperty, value); }
+ }
+ public static readonly DependencyProperty StrokeWidthProperty =
+ DependencyProperty.Register("StrokeWidth", typeof(double), typeof(RealTimeGraphExDirectXLineScroll), new PropertyMetadata(1.0, new PropertyChangedCallback(CrossModelChanged)));
+
+
+
+ /// <summary>
+ /// Gets or sets the graph fill color.
+ /// </summary>
+ public Brush Fill
+ {
+ get { return (Brush)GetValue(FillProperty); }
+ set { SetValue(FillProperty, value); }
+ }
+ public static readonly DependencyProperty FillProperty =
+ DependencyProperty.Register("Fill", typeof(Brush), typeof(RealTimeGraphExDirectXLineScroll), new PropertyMetadata(Brushes.Gray, new PropertyChangedCallback(CrossModelChanged)));
+
+ /// <summary>
+ /// Gets or sets whether the graph will be rendered using the Fill color property.
+ /// </summary>
+ public bool FillGraph
+ {
+ get { return (bool)GetValue(FillGraphProperty); }
+ set { SetValue(FillGraphProperty, value); }
+ }
+ public static readonly DependencyProperty FillGraphProperty =
+ DependencyProperty.Register("FillGraph", typeof(bool), typeof(RealTimeGraphExDirectXLineScroll), new PropertyMetadata(false, new PropertyChangedCallback(CrossModelChanged)));
+
+
+ /// <summary>
+ /// Gets or sets the IDataSeries used to push data vectorsCollection to the graph.
+ /// </summary>
+ public GraphController Controller
+ {
+ get { return (GraphController)GetValue(ControllerProperty); }
+ set { SetValue(ControllerProperty, value); }
+ }
+ public static readonly DependencyProperty ControllerProperty =
+ DependencyProperty.Register("Controller", typeof(GraphController), typeof(RealTimeGraphExDirectXLineScroll), new PropertyMetadata(null, new PropertyChangedCallback(GraphControllerChanged)));
+ private static void GraphControllerChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
+ {
+ var control = d as RealTimeGraphExDirectXLineScroll;
+
+ if (control.Controller != null)
+ {
+ control.Controller.RegisterMethods(control.ClearGraph, control.StartPushThread, control.SetPaused, control.ChangeRenderMode,null);
+ control._graphController = control.Controller;
+ }
+ }
+
+ #endregion
+
+ #region Constructor
+
+ public RealTimeGraphExDirectXLineScroll()
+ : base()
+ {
+ graphPolygon = new ConcurrentpointsList();
+ }
+
+ #endregion
+
+ #region Override Methods
+
+ protected override void Initialize()
+ {
+ base.Initialize();
+
+ dxGraph = new DXGraphSurfaceSingleScroll() { HorizontalAlignment = System.Windows.HorizontalAlignment.Left, VerticalAlignment = System.Windows.VerticalAlignment.Stretch };
+
+ gridMain.Children.Remove(img);
+
+ if (!gridMain.Children.Contains(dxGraph))
+ {
+ gridMain.Children.Add(dxGraph);
+ }
+
+ dxGraph.IsHitTestVisible = false;
+ Grid.SetColumnSpan(dxGraph, 3);
+ }
+
+ protected override void OnSizeChanged(object sender, SizeChangedEventArgs e)
+ {
+ OnSetCrossThreadFields();
+ }
+
+ protected override void OnSetCrossThreadFields()
+ {
+ base.OnSetCrossThreadFields();
+
+ this.Dispatcher.Invoke(() =>
+ {
+ _maxPoints = MaxPoints;
+ _scaleFactor = _width / _maxPoints;
+ _graphController = Controller;
+ _stroke = Stroke;
+ _fillGraph = FillGraph;
+ _fill = Fill;
+ _strokeWidth = StrokeWidth;
+
+ }, DispatcherPriority.Send);
+ }
+
+ protected override void OnClearGraph()
+ {
+ base.OnClearGraph();
+ _graphController.dataSeries.ClearPoints();
+ graphPolygon.Clear();
+ }
+
+ protected override void OnZoomingComplete(Point transformOrigin, double scaleX, double scaleY)
+ {
+ base.OnZoomingComplete(transformOrigin, scaleX, scaleY);
+ }
+
+ protected override double ConvertYToImageY(double value)
+ {
+ double valuePrecentage = ((((value - (_minimum - (_strokeWidth / 2))) * 100) / (_maximum - (_minimum - (_strokeWidth / 2)))) * ((_height) - (_strokeWidth / 2))) / 100;
+ return valuePrecentage;
+ }
+
+ protected override double ConvertYToImageYFliped(double value)
+ {
+ double valuePrecentage = ConvertYToImageY(value);
+ valuePrecentage = (_height - (_strokeWidth / 2)) - valuePrecentage; //Flip
+ return valuePrecentage;
+ }
+
+ protected internal override void OnRenderGraph()
+ {
+ if (_graphController != null && _graphController.dataSeries.Points != null && _graphController.dataSeries.Points.Count > 0 && _width > 1 && _height > 1)
+ {
+ var points = _graphController.dataSeries.Points.GetAndClearAllPoints();
+
+ if (!_isPaused)
+ {
+
+ for (int i = 0; i < points.Count; i++)
+ {
+ double value = points[i];
+ NormalizeValue(ref value);
+ graphPolygon.Add(value);
+ }
+
+ if (graphPolygon.Count > _maxPoints + 1)
+ {
+ graphPolygon.RemoveFromStart(graphPolygon.Count - (_maxPoints + 1));
+ }
+ }
+ }
+
+ updateCounter++;
+
+ if (updateCounter >= 1)
+ {
+ updateCounter = 0;
+
+ if (!_disableRendering)
+ {
+ OnDrawVisuals();
+ }
+ }
+ }
+
+ #endregion
+
+ #region Virtual Methods
+
+ /// <summary>
+ /// Calculate the scaling factor for the current graph width.
+ /// </summary>
+ /// <returns></returns>
+ protected virtual double GetPolygonScaleFactor()
+ {
+ return _width / (graphPolygon.Count - 1);
+ }
+
+ protected virtual void OnDrawVisuals()
+ {
+ if (graphPolygon.Count > 0)
+ {
+ Brush stroke = _graphController.dataSeries.stroke != null ? _graphController.dataSeries.stroke : _stroke;
+ Brush fill = _graphController.dataSeries.fill != null ? _graphController.dataSeries.fill : _fill;
+ (dxGraph as DXGraphSurfaceSingleScroll).SetProperties(
+ graphPolygon.ToDXPolygonPoints(_offSetX, _offSetY, GetPolygonScaleFactor(), ConvertYToImageYFliped),
+ _fillGraph ? graphPolygon.ToDXPolygonPointsFill(_offSetX, _offSetY, _mainWidth, _mainHeight, GetPolygonScaleFactor(),
+ ConvertYToImageYFliped) : null,
+ stroke,
+ _strokeWidth,
+ _fillGraph,
+ fill,
+ _antialiased);
+
+ dxGraph.EnableRendering();
+ }
+ }
+
+ #endregion
+ }
+}
diff --git a/Software/Visual_Studio/SideChains/RealTimeGraphEx/DirectXGraphs/RealTimeGraphExDirectXMultiLineErase.cs b/Software/Visual_Studio/SideChains/RealTimeGraphEx/DirectXGraphs/RealTimeGraphExDirectXMultiLineErase.cs
new file mode 100644
index 000000000..2a467610f
--- /dev/null
+++ b/Software/Visual_Studio/SideChains/RealTimeGraphEx/DirectXGraphs/RealTimeGraphExDirectXMultiLineErase.cs
@@ -0,0 +1,225 @@
+using RealTimeGraphEx.DX2D;
+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.Media;
+using System.Windows.Threading;
+
+namespace RealTimeGraphEx.DirectXGraphs
+{
+ public class RealTimeGraphExDirectXMultiLineErase : RealTimeGraphExDirectXMultiLineScroll
+ {
+ #region Cross Thread Fields
+
+ protected Brush _markerBrush;
+ protected bool _showMarker;
+ protected double _markerStrokeWidth;
+ protected int _currentReplaceIndex;
+ protected bool _endReached;
+
+ #endregion
+
+ #region Properties
+
+ public Brush MarkerBrush
+ {
+ get { return (Brush)GetValue(MarkerBrushProperty); }
+ set { SetValue(MarkerBrushProperty, value); }
+ }
+ public static readonly DependencyProperty MarkerBrushProperty =
+ DependencyProperty.Register("MarkerBrush", typeof(Brush), typeof(RealTimeGraphExDirectXMultiLineErase), new PropertyMetadata(Brushes.Red, new PropertyChangedCallback(CrossModelChanged)));
+
+ public bool ShowMarker
+ {
+ get { return (bool)GetValue(ShowMarkerProperty); }
+ set { SetValue(ShowMarkerProperty, value); }
+ }
+ public static readonly DependencyProperty ShowMarkerProperty =
+ DependencyProperty.Register("ShowMarker", typeof(bool), typeof(RealTimeGraphExDirectXMultiLineErase), new PropertyMetadata(true, new PropertyChangedCallback(CrossModelChanged)));
+
+ public double MarkerStrokeWidth
+ {
+ get { return (double)GetValue(MarkerStrokeWidthProperty); }
+ set { SetValue(MarkerStrokeWidthProperty, value); }
+ }
+ public static readonly DependencyProperty MarkerStrokeWidthProperty =
+ DependencyProperty.Register("MarkerStrokeWidth", typeof(double), typeof(RealTimeGraphExDirectXMultiLineErase), new PropertyMetadata(1.0, new PropertyChangedCallback(CrossModelChanged)));
+
+ #endregion
+
+ #region Constructor
+
+ public RealTimeGraphExDirectXMultiLineErase()
+ : base()
+ {
+
+ }
+
+ #endregion
+
+ #region Override Methods
+
+ protected override void Initialize()
+ {
+ base.Initialize();
+
+ dxGraph = new DXGraphSurfaceMultiErase() { HorizontalAlignment = System.Windows.HorizontalAlignment.Left, VerticalAlignment = System.Windows.VerticalAlignment.Stretch };
+
+ gridMain.Children.Remove(img);
+
+ if (!gridMain.Children.Contains(dxGraph))
+ {
+ gridMain.Children.Add(dxGraph);
+ }
+
+ dxGraph.IsHitTestVisible = false;
+ Grid.SetColumnSpan(dxGraph, 3);
+ }
+
+ protected override void OnSetCrossThreadFields()
+ {
+ base.OnSetCrossThreadFields();
+
+ this.Dispatcher.Invoke(() =>
+ {
+ _markerBrush = MarkerBrush;
+ _markerStrokeWidth = MarkerStrokeWidth;
+ _showMarker = ShowMarker;
+
+ }, DispatcherPriority.Send);
+ }
+
+ protected override void OnClearGraph()
+ {
+ base.OnClearGraph();
+ _currentReplaceIndex = 0;
+ _endReached = false;
+ }
+
+ protected internal override void OnRenderGraph()
+ {
+ if (_graphController != null && _graphController.dataSeriesCollection.Count > 0 && _graphController.TotalPoints > 0 && _width > 1 && _height > 1)
+ {
+ var pointsCollection = _graphController.GetAndClearAllPoints();
+ int toIncrease = pointsCollection[0].Count;
+
+ if (!_isPaused)
+ {
+ for (int i = 0; i < pointsCollection.Count; i++)
+ {
+ var points = pointsCollection[i];
+
+ int polyReplaceIndex = _currentReplaceIndex;
+
+ for (int j = 0; j < points.Count; j++)
+ {
+ double value = points[j];
+ NormalizeValue(ref value);
+
+ if (_graphPolygons[i].Count > _maxPoints)
+ {
+ _graphPolygons[i].Replace(value, polyReplaceIndex++);
+ }
+ else
+ {
+ _graphPolygons[i].Add(value);
+ }
+
+ if (polyReplaceIndex > _graphPolygons[i].Count - 1)
+ {
+ polyReplaceIndex = 0;
+ }
+ }
+ }
+
+ if (_graphPolygons[0].Count > _maxPoints)
+ {
+ if (_endReached)
+ {
+ _currentReplaceIndex += toIncrease;
+ }
+ else
+ {
+ _currentReplaceIndex = 0;
+ _endReached = true;
+ }
+ }
+
+ if (_currentReplaceIndex > _graphPolygons[0].Count - 1)
+ {
+ _currentReplaceIndex = 0;
+ }
+ }
+ }
+
+ updateCounter++;
+
+ if (updateCounter >= 1)
+ {
+ updateCounter = 0;
+
+ if (!_disableRendering)
+ {
+ OnDrawVisuals();
+ }
+ }
+ }
+
+ protected override void OnDrawVisuals()
+ {
+ if (_graphPolygons[0].Count > 0)
+ {
+
+ double markerPosition = 0;
+ if (_currentReplaceIndex > 0)
+ {
+ markerPosition = (((_currentReplaceIndex - 1) * (_width / (_graphPolygons[0].Count - 1)) + _offSetX));
+ }
+
+ List<SharpDX.Vector2[]> polygonPoints = new List<SharpDX.Vector2[]>();
+ List<SharpDX.Vector2[]> polygonPointsFill = new List<SharpDX.Vector2[]>();
+ List<Brush> strokes = new List<Brush>();
+ List<Brush> fills = new List<Brush>();
+
+ for (int i = 0; i < _graphPolygons.Count; i++)
+ {
+ var polygon = _graphPolygons[i];
+ double scale = _width / (polygon.Count - 1);
+
+ if (polygon.Count > 0 && _graphController.dataSeriesCollection[i].isVisible)
+ {
+ Brush stroke = _graphController.dataSeriesCollection[i].stroke != null ? _graphController.dataSeriesCollection[i].stroke : _stroke;
+ Brush fill = _graphController.dataSeriesCollection[i].fill != null ? _graphController.dataSeriesCollection[i].fill : _fill;
+
+ strokes.Add(stroke);
+ fills.Add(fill);
+
+ polygonPoints.Add(polygon.ToDXPolygonPoints(_offSetX, _offSetY, scale, ConvertYToImageYFliped));
+ polygonPointsFill.Add(polygon.ToDXPolygonPointsFill(_offSetX, _offSetY, _mainWidth, _mainHeight, scale, ConvertYToImageYFliped));
+ }
+ }
+
+ (dxGraph as DXGraphSurfaceMultiErase).SetProperties(
+ polygonPoints,
+ _fillGraph ? polygonPointsFill : null,
+ strokes,
+ _strokeWidth,
+ _fillGraph,
+ fills,
+ _antialiased,
+ _markerBrush,
+ markerPosition,
+ _showMarker,
+ _markerStrokeWidth);
+
+ dxGraph.EnableRendering();
+ }
+ }
+
+ #endregion
+ }
+}
diff --git a/Software/Visual_Studio/SideChains/RealTimeGraphEx/DirectXGraphs/RealTimeGraphExDirectXMultiLineScroll.cs b/Software/Visual_Studio/SideChains/RealTimeGraphEx/DirectXGraphs/RealTimeGraphExDirectXMultiLineScroll.cs
new file mode 100644
index 000000000..7671272f0
--- /dev/null
+++ b/Software/Visual_Studio/SideChains/RealTimeGraphEx/DirectXGraphs/RealTimeGraphExDirectXMultiLineScroll.cs
@@ -0,0 +1,266 @@
+using System;
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+using System.Diagnostics;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Windows;
+using System.Windows.Media;
+using System.Windows.Media.Imaging;
+using RealTimeGraphEx.Models;
+using RealTimeGraphEx.DataSeries;
+using RealTimeGraphEx.Controllers;
+using System.Runtime.ExceptionServices;
+using RealTimeGraphEx.DX2D;
+using System.Windows.Controls;
+using System.Windows.Threading;
+
+namespace RealTimeGraphEx.DirectXGraphs
+{
+ public class RealTimeGraphExDirectXMultiLineScroll : RealTimeGraphExMultiBase
+ {
+ #region Cross Thread Fields
+
+ protected Direct2DControl dxGraph;
+ protected List<ConcurrentpointsList> _graphPolygons;
+ protected Brush _stroke;
+ protected Brush _fill;
+ protected bool _fillGraph;
+ protected double _strokeWidth;
+
+ #endregion
+
+ #region Constructors
+
+ public RealTimeGraphExDirectXMultiLineScroll()
+ : base()
+ {
+ _graphPolygons = new List<ConcurrentpointsList>();
+ _graphController = new GraphMultiController();
+ }
+
+ #endregion
+
+ #region Properties
+
+ /// <summary>
+ /// Gets or sets the graph strokes color.
+ /// </summary>
+ public Brush Stroke
+ {
+ get { return (Brush)GetValue(StrokeProperty); }
+ set { SetValue(StrokeProperty, value); }
+ }
+ public static readonly DependencyProperty StrokeProperty =
+ DependencyProperty.Register("Stroke", typeof(Brush), typeof(RealTimeGraphExDirectXMultiLineScroll), new PropertyMetadata(Brushes.Red, new PropertyChangedCallback(CrossModelChanged)));
+
+ /// <summary>
+ /// Gets or sets the graph fill color.
+ /// </summary>
+ public Brush Fill
+ {
+ get { return (Brush)GetValue(FillProperty); }
+ set { SetValue(FillProperty, value); }
+ }
+ public static readonly DependencyProperty FillProperty =
+ DependencyProperty.Register("Fill", typeof(Brush), typeof(RealTimeGraphExDirectXMultiLineScroll), new PropertyMetadata(Brushes.Transparent, new PropertyChangedCallback(CrossModelChanged)));
+
+ /// <summary>
+ /// Gets or sets whether the graph will be rendered using the Fill color property.
+ /// </summary>
+ public bool FillGraph
+ {
+ get { return (bool)GetValue(FillGraphProperty); }
+ set { SetValue(FillGraphProperty, value); }
+ }
+ public static readonly DependencyProperty FillGraphProperty =
+ DependencyProperty.Register("FillGraph", typeof(bool), typeof(RealTimeGraphExDirectXMultiLineScroll), new PropertyMetadata(false, new PropertyChangedCallback(CrossModelChanged)));
+
+ public double StrokeWidth
+ {
+ get { return (double)GetValue(StrokeWidthProperty); }
+ set { SetValue(StrokeWidthProperty, value); }
+ }
+ public static readonly DependencyProperty StrokeWidthProperty =
+ DependencyProperty.Register("StrokeWidth", typeof(double), typeof(RealTimeGraphExDirectXMultiLineScroll), new PropertyMetadata(1.0, new PropertyChangedCallback(CrossModelChanged)));
+
+
+ #endregion
+
+ #region Override Methods
+
+ protected override void Initialize()
+ {
+ base.Initialize();
+
+ dxGraph = new DXGraphSurfaceMultiScroll() { HorizontalAlignment = System.Windows.HorizontalAlignment.Left, VerticalAlignment = System.Windows.VerticalAlignment.Stretch };
+
+ gridMain.Children.Remove(img);
+
+ if (!gridMain.Children.Contains(dxGraph))
+ {
+ gridMain.Children.Add(dxGraph);
+ }
+
+ dxGraph.IsHitTestVisible = false;
+ Grid.SetColumnSpan(dxGraph, 3);
+ }
+
+ protected override void OnControllerChanged()
+ {
+ if (_graphController != null)
+ {
+ _graphController.RegisterMethods(ClearGraph, StartPushThread, SetPaused, ChangeRenderMode, null);
+
+ foreach (var dataSeries in _graphController.DataSeriesCollection)
+ {
+ _graphPolygons.Add(new ConcurrentpointsList());
+ }
+ }
+ }
+
+ protected override void OnSizeChanged(object sender, SizeChangedEventArgs e)
+ {
+ OnSetCrossThreadFields();
+ }
+
+ protected override void OnSetCrossThreadFields()
+ {
+ base.OnSetCrossThreadFields();
+
+ this.Dispatcher.Invoke(() =>
+ {
+ _maxPoints = MaxPoints;
+ _scaleFactor = _width / _maxPoints;
+ _strokeWidth = StrokeWidth;
+ _fill = Fill;
+ _stroke = Stroke;
+ _fillGraph = FillGraph;
+
+ }, System.Windows.Threading.DispatcherPriority.Send);
+ }
+
+ protected override void OnClearGraph()
+ {
+ _graphPolygons.ForEach(x => x.Clear());
+ _graphController.ClearPoints();
+
+ base.OnClearGraph();
+ }
+
+ protected override double ConvertYToImageY(double value)
+ {
+ double valuePrecentage = ((((value - (_minimum - (_strokeWidth / 2))) * 100) / (_maximum - (_minimum - (_strokeWidth / 2)))) * ((_height) - (_strokeWidth / 2))) / 100;
+ return valuePrecentage;
+ }
+
+ protected override double ConvertYToImageYFliped(double value)
+ {
+ double valuePrecentage = ConvertYToImageY(value);
+ valuePrecentage = (_height - (_strokeWidth / 2)) - valuePrecentage; //Flip
+ return valuePrecentage;
+ }
+
+ protected internal override void OnRenderGraph()
+ {
+ if (_graphController != null && _graphController.dataSeriesCollection.Count > 0 && _graphController.TotalPoints > 0 && _width > 1 && _height > 1)
+ {
+ var pointsCollection = _graphController.GetAndClearAllPoints();
+
+ if (!_isPaused)
+ {
+
+ Parallel.For(0, pointsCollection.Count, (i) =>
+ {
+
+ for (int j = 0; j < pointsCollection[(int)i].Count; j++)
+ {
+ double value = pointsCollection[(int)i][j];
+ NormalizeValue(ref value);
+
+ _graphPolygons[i].Add(value);
+ }
+ });
+
+ if (_graphPolygons[0].Count > _maxPoints + _graphController.dataSeriesCollection[0].Points.Count)
+ {
+ Parallel.ForEach(_graphPolygons, (polygon) =>
+ {
+ polygon.RemoveFromStart(polygon.Count - (_maxPoints + _graphController.dataSeriesCollection[0].Points.Count));
+ });
+ }
+ }
+ }
+
+ updateCounter++;
+
+ if (updateCounter >= 1)
+ {
+ updateCounter = 0;
+
+ if (!_disableRendering)
+ {
+ OnDrawVisuals();
+ }
+ }
+ }
+
+ protected override void OnDragging(System.Windows.Controls.Primitives.DragDeltaEventArgs e)
+ {
+ base.OnDragging(e);
+ }
+
+ #endregion
+
+ #region Virtual Methods
+
+ protected virtual void OnDrawVisuals()
+ {
+ if (_graphPolygons[0].Count > 0)
+ {
+ List<SharpDX.Vector2[]> polygonPoints = new List<SharpDX.Vector2[]>();
+ List<SharpDX.Vector2[]> polygonPointsFill = new List<SharpDX.Vector2[]>();
+ List<Brush> strokes = new List<Brush>();
+ List<Brush> fills = new List<Brush>();
+
+ for (int i = 0; i < _graphPolygons.Count; i++)
+ {
+ var polygon = _graphPolygons[i];
+ double scale = _width / (polygon.Count - 1);
+
+ if (polygon.Count > 0 && _graphController.dataSeriesCollection[i].isVisible)
+ {
+ Brush stroke = _graphController.dataSeriesCollection[i].stroke != null ? _graphController.dataSeriesCollection[i].stroke : _stroke;
+ Brush fill = _graphController.dataSeriesCollection[i].fill != null ? _graphController.dataSeriesCollection[i].fill : _fill;
+
+ strokes.Add(stroke);
+ fills.Add(fill);
+
+ polygonPoints.Add(polygon.ToDXPolygonPoints(_offSetX, _offSetY, scale, ConvertYToImageYFliped));
+ polygonPointsFill.Add(polygon.ToDXPolygonPointsFill(_offSetX, _offSetY, _mainWidth, _mainHeight, scale, ConvertYToImageYFliped));
+ }
+ }
+
+ (dxGraph as DXGraphSurfaceMultiScroll).SetProperties(
+ polygonPoints,
+ _fillGraph ? polygonPointsFill : null,
+ strokes,
+ _strokeWidth,
+ _fillGraph,
+ fills,
+ _antialiased);
+
+ dxGraph.EnableRendering();
+ }
+ }
+
+ public virtual List<double> GetCurrentPointsOnGraph(int seriesIndex)
+ {
+ return _graphPolygons[seriesIndex].GetPoints();
+ }
+
+ #endregion
+
+ }
+}