KlassenDLL im Main integriert
This commit is contained in:
121
SanSystem/BerichtGen/makeGraphic.cs
Normal file
121
SanSystem/BerichtGen/makeGraphic.cs
Normal file
@@ -0,0 +1,121 @@
|
||||
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
|
||||
{
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public static class makeGraphic
|
||||
{
|
||||
private static ChartControl getGraph(List<UVcsvStrukture> 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 = "[mbar]";
|
||||
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;
|
||||
}
|
||||
/// <summary>
|
||||
/// Erstellt die Drucksverlauf kurve
|
||||
/// </summary>
|
||||
/// <param name="struktures"></param>
|
||||
/// <param name="destinationPath"></param>
|
||||
/// <returns></returns>
|
||||
public static bool GetGraphics(List<UVcsvStrukture> struktures,string destinationPath)
|
||||
{
|
||||
Dongle dongle = new Dongle(60);
|
||||
Syncfusion.Licensing.SyncfusionLicenseProvider.RegisterLicense(dongle.SyncfusionKey);
|
||||
dongle.CleanDongle();
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user