From 2ce6afb909f34af7d78c20cfeb9f2d8311e91336 Mon Sep 17 00:00:00 2001 From: Roy Ben Shabat Date: Fri, 3 Oct 2025 01:55:11 +0300 Subject: Changed RealTimeGraphX to .NET 4.6.1 --- .../RealTimeGraphX/GraphRenderer.cs | 76 ++++++++++++++++++++++ 1 file changed, 76 insertions(+) create mode 100644 Software/Visual_Studio/SideChains/RealTimeGraphXNet/RealTimeGraphX/GraphRenderer.cs (limited to 'Software/Visual_Studio/SideChains/RealTimeGraphXNet/RealTimeGraphX/GraphRenderer.cs') diff --git a/Software/Visual_Studio/SideChains/RealTimeGraphXNet/RealTimeGraphX/GraphRenderer.cs b/Software/Visual_Studio/SideChains/RealTimeGraphXNet/RealTimeGraphX/GraphRenderer.cs new file mode 100644 index 000000000..c42fcb4ab --- /dev/null +++ b/Software/Visual_Studio/SideChains/RealTimeGraphXNet/RealTimeGraphX/GraphRenderer.cs @@ -0,0 +1,76 @@ +using System.Collections.Generic; +using System.Linq; +using System.Drawing; + +namespace RealTimeGraphX +{ + /// + /// Represents an base class. + /// + /// The type of the data series. + /// + /// + public abstract class GraphRenderer : GraphObject, IGraphRenderer where TDataSeries : IGraphDataSeries + { + /// + /// Converts the specified relative x position to a graph surface absolute position. + /// + /// The target surface. + /// The relative x position. + /// + protected virtual float ConvertXValueToRendererValue(IGraphSurface surface, double x) + { + return (float)(x * surface.GetSize().Width / 100); + } + + /// + /// Converts the specified relative y position to a graph surface absolute position. + /// + /// The surface. + /// The relative y position. + /// + protected virtual float ConvertYValueToRendererValue(IGraphSurface surface, double y) + { + return (float)(surface.GetSize().Height - (y * surface.GetSize().Height / 100)); + } + + /// + /// Arranges the series of data points and returns a series of drawing points. + /// + /// The target graph surface. + /// The instance of the current rendered data series. + /// Instance of graph range. + /// Collection of x coordinates. + /// Collection of y coordinates. + /// The minimum x coordinates value. + /// The maximum x coordinates value. + /// The minimum y coordinates value. + /// The maximum y coordinates value. + /// + public abstract IEnumerable Render(IGraphSurface surface, TDataSeries series, IGraphRange range, List xx, List yy, GraphDataPoint minimumX, GraphDataPoint maximumX, GraphDataPoint minimumY, GraphDataPoint maximumY); + + /// + /// Draws the specified data series points on the target surface. + /// + /// The target graph surface. + /// The instance of the current rendered data series. + /// The collection of the current data series drawing points. + /// The index of the current data series within the collection of data series. + /// The length of the data series collection. + public abstract void Draw(IGraphSurface surface, TDataSeries series, IEnumerable points, int index, int count); + + /// + /// Gets a closed polygon version of the specified drawing points. + /// + /// The target surface. + /// The drawing points. + /// + protected virtual IEnumerable GetFillPoints(IGraphSurface surface, IEnumerable points) + { + List closed = points.ToList(); + closed.Add(new PointF(points.Last().X, surface.GetSize().Width)); + closed.Add(new PointF(0, surface.GetSize().Height)); + return closed.ToArray(); + } + } +} -- cgit v1.3.1