using SanShared;
using Syncfusion.Windows.Forms.Chart;
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Drawing;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace BerichtGen
{
///
///
///
public static class makeGraphic
{
private static ChartControl getGraph(List input, string type)
{
Size size = new Size(400, 300);
ChartControl chartControl = new ChartControl();
chartControl.Size = size;
ChartAxis axis = chartControl.PrimaryYAxis;
ChartAxisLayout layout1 = new ChartAxisLayout();
layout1.Spacing = 12;
layout1.Axes.Add(axis);
chartControl.ChartArea.YLayouts.Add(layout1);
ChartSeries mychart = new ChartSeries(type, ChartSeriesType.Line);
int counter = 0;
foreach (UVcsvStrukture pars in input)
{
if (type.Equals("Temperatur"))
mychart.Points.Add(counter, pars.Temperatur);
else if (type.Equals("Druck"))
mychart.Points.Add(counter, pars.Druck);
else if (type.Equals("Geschwindigkeit"))
mychart.Points.Add(counter, pars.Geschwindigkeit);
else
throw new Exception("Kein gültiger Aufruf");
counter++;
}
mychart.YAxis = axis;
switch (type)
{
case "Temperatur":
axis.Title = "°C";
break;
case "Druck":
axis.Title = "[bar]";
break;
case "Geschwindigkeit":
axis.Title = "[cm]";
break;
}
axis.TitleFont = new Font("Segeo UI", 14F);
chartControl.LegendsPlacement = ChartPlacement.Outside;
chartControl.LegendPosition = ChartDock.Bottom;
chartControl.LegendAlignment = ChartAlignment.Center;
chartControl.Title.Visible = false;
chartControl.Series.Add(mychart);
chartControl.Skins = Skins.Metro;
axis.EdgeLabelsDrawingMode = ChartAxisEdgeLabelsDrawingMode.Shift;
return chartControl;
}
///
/// Erstellt die Drucksverlauf kurve
///
///
///
///
public static bool GetGraphics(List struktures,string destinationPath)
{
Syncfusion.Licensing.SyncfusionLicenseProvider.RegisterLicense("MTU0ODAyQDMxMzcyZTMzMmUzMFNsK0VsVStJUHA5NzFMQUphWTRBNmcvWU5xdGpsUmpkN0h4UGVMM083RFE9");
ChartControl tempChart = getGraph(struktures, "Temperatur");
if (tempChart == null) return false;
else
tempChart.SaveImage(Path.Combine(destinationPath, "linerGraph_temp.jpg"));
ChartControl druckChart = getGraph(struktures, "Druck");
if (druckChart == null) return false;
else
druckChart.SaveImage(Path.Combine(destinationPath, "linerGraph_druck.jpg"));
ChartControl speedChart = getGraph(struktures, "Geschwindigkeit");
if (speedChart == null) return false;
else
speedChart.SaveImage(Path.Combine(destinationPath, "linerGraph_speed.jpg"));
return true;
}
}
}