From b49b7f16546503f18ecdd4473df9219f57f6c87a Mon Sep 17 00:00:00 2001 From: Husky Date: Sun, 8 Jul 2018 18:46:53 +0200 Subject: [PATCH] Chart wird generiert aus CSV Datei --- SanSystem/FrmLinerChart.Designer.cs | 76 ++++++++++++++++++ SanSystem/FrmLinerChart.cs | 94 ++++++++++++++++++++++ SanSystem/FrmLinerChart.resx | 120 ++++++++++++++++++++++++++++ SanSystem/SanSystem.csproj | 13 +++ SanSystem/UCInliner.Designer.cs | 31 ++++--- SanSystem/UCInliner.cs | 6 ++ 6 files changed, 331 insertions(+), 9 deletions(-) create mode 100644 SanSystem/FrmLinerChart.Designer.cs create mode 100644 SanSystem/FrmLinerChart.cs create mode 100644 SanSystem/FrmLinerChart.resx diff --git a/SanSystem/FrmLinerChart.Designer.cs b/SanSystem/FrmLinerChart.Designer.cs new file mode 100644 index 0000000..9b5a6f3 --- /dev/null +++ b/SanSystem/FrmLinerChart.Designer.cs @@ -0,0 +1,76 @@ +namespace SanSystem +{ + partial class FrmLinerChart + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + this.chartControl1 = new Syncfusion.Windows.Forms.Chart.ChartControl(); + this.SuspendLayout(); + // + // chartControl1 + // + this.chartControl1.ChartArea.CursorLocation = new System.Drawing.Point(0, 0); + this.chartControl1.ChartArea.CursorReDraw = false; + this.chartControl1.EnableYZooming = true; + this.chartControl1.IsWindowLess = false; + // + // + // + this.chartControl1.Legend.Location = new System.Drawing.Point(485, 75); + this.chartControl1.Localize = null; + this.chartControl1.Location = new System.Drawing.Point(12, 12); + this.chartControl1.MinZoomFactorX = 0.5D; + this.chartControl1.MinZoomFactorY = 0.5D; + this.chartControl1.Name = "chartControl1"; + this.chartControl1.PrimaryXAxis.LogLabelsDisplayMode = Syncfusion.Windows.Forms.Chart.LogLabelsDisplayMode.Default; + this.chartControl1.PrimaryXAxis.Margin = true; + this.chartControl1.PrimaryYAxis.LogLabelsDisplayMode = Syncfusion.Windows.Forms.Chart.LogLabelsDisplayMode.Default; + this.chartControl1.PrimaryYAxis.Margin = true; + this.chartControl1.Size = new System.Drawing.Size(776, 357); + this.chartControl1.TabIndex = 0; + // + // + // + this.chartControl1.Title.Name = "Default"; + // + // FrmLinerChart + // + this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(800, 450); + this.Controls.Add(this.chartControl1); + this.Name = "FrmLinerChart"; + this.Text = "FrmLinerChart"; + this.ResumeLayout(false); + + } + + #endregion + + private Syncfusion.Windows.Forms.Chart.ChartControl chartControl1; + } +} \ No newline at end of file diff --git a/SanSystem/FrmLinerChart.cs b/SanSystem/FrmLinerChart.cs new file mode 100644 index 0000000..ab54039 --- /dev/null +++ b/SanSystem/FrmLinerChart.cs @@ -0,0 +1,94 @@ +using Syncfusion.Windows.Forms.Chart; +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Data; +using System.Drawing; +using System.IO; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Forms; + +namespace SanSystem +{ + public partial class FrmLinerChart : Form + { + public FrmLinerChart() + { + InitializeComponent(); + ChartAxis axis = chartControl1.PrimaryYAxis; + ChartAxis axis0 = new ChartAxis(ChartOrientation.Vertical); + ChartAxis axis1 = new ChartAxis(ChartOrientation.Vertical); + + ChartAxisLayout layout1 = new ChartAxisLayout(); + ChartAxisLayout layout2 = new ChartAxisLayout(); + + chartControl1.Axes.Add(axis0); + chartControl1.Axes.Add(axis1); + + + + + layout1.Spacing = 12; + layout2.Spacing = 12; + layout1.Axes.Add(axis); + layout2.Axes.Add(axis0); + layout2.Axes.Add(axis1); + + chartControl1.ChartArea.YLayouts.Add(layout1); + chartControl1.ChartArea.YLayouts.Add(layout2); + + ChartSeries temperaturChart = new ChartSeries("Temperatur", ChartSeriesType.Line); + ChartSeries druckChart = new ChartSeries("Druck", ChartSeriesType.Line); + + string[] input = File.ReadAllLines(@"C:\Users\Damian\Desktop\SanVerwaltung\SanSystem\bin\Debug\projekte\18-850\SW01-SW02\UVAnlage\Trend\Trend022.csv"); + int counter = 0; + foreach (string pars in input) + { + string[] parts = pars.Split(','); + if (parts[0].Equals("Group1") || parts[1].Equals("(END)")) continue; + double temperatur = double.Parse(parts[1].Replace('.',',')); + double druck = double.Parse(parts[2].Replace('.', ',')); + + temperaturChart.Points.Add(counter, temperatur); + druckChart.Points.Add(counter, druck); + counter++; + + } + temperaturChart.YAxis = axis; + druckChart.YAxis = axis0; + + axis.Title = "°C"; + axis.TitleFont = new Font("Segeo UI", 14F); + + axis0.Title = "[bar]"; + axis0.TitleFont = new Font("Segeo UI", 14F); + + chartControl1.LegendsPlacement = ChartPlacement.Outside; + chartControl1.LegendPosition = ChartDock.Bottom; + chartControl1.LegendAlignment = ChartAlignment.Center; + chartControl1.Title.Visible = false; + + ChartAxis chartAxis = new ChartAxis(); + chartAxis.Orientation = ChartOrientation.Horizontal; + chartAxis.Range = new MinMaxInfo(0, 6, 1); + chartAxis.DrawGrid = false; + chartAxis.LineType.Width = 1F; + chartAxis.LineType.ForeColor = Color.Black; + chartControl1.Axes.Add(chartAxis); + + chartControl1.Series.Add(temperaturChart); + chartControl1.Series.Add(druckChart); + chartControl1.Skins = Skins.Metro; + + + axis1.OpposedPosition = true; + axis.EdgeLabelsDrawingMode = ChartAxisEdgeLabelsDrawingMode.Shift; + axis0.EdgeLabelsDrawingMode = ChartAxisEdgeLabelsDrawingMode.Shift; + axis1.EdgeLabelsDrawingMode = ChartAxisEdgeLabelsDrawingMode.Shift; + + chartControl1.SaveImage("./temp.jpg"); + } + } +} diff --git a/SanSystem/FrmLinerChart.resx b/SanSystem/FrmLinerChart.resx new file mode 100644 index 0000000..1af7de1 --- /dev/null +++ b/SanSystem/FrmLinerChart.resx @@ -0,0 +1,120 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/SanSystem/SanSystem.csproj b/SanSystem/SanSystem.csproj index c59cb54..4e225ff 100644 --- a/SanSystem/SanSystem.csproj +++ b/SanSystem/SanSystem.csproj @@ -38,8 +38,12 @@ ..\packages\Ionic.Zip.1.9.1.8\lib\Ionic.Zip.dll + + + + @@ -52,6 +56,12 @@ + + Form + + + FrmLinerChart.cs + Form @@ -97,6 +107,9 @@ UCSchachtanbindung.cs + + FrmLinerChart.cs + frmObjektEdit.cs diff --git a/SanSystem/UCInliner.Designer.cs b/SanSystem/UCInliner.Designer.cs index 3be2f1d..3d2ee80 100644 --- a/SanSystem/UCInliner.Designer.cs +++ b/SanSystem/UCInliner.Designer.cs @@ -30,6 +30,7 @@ { this.tabControl1 = new System.Windows.Forms.TabControl(); this.tabPage2 = new System.Windows.Forms.TabPage(); + this.button1 = new System.Windows.Forms.Button(); this.ftpProgress = new System.Windows.Forms.ProgressBar(); this.btn_transfer_ftp = new System.Windows.Forms.Button(); this.label1 = new System.Windows.Forms.Label(); @@ -69,7 +70,7 @@ this.label11 = new System.Windows.Forms.Label(); this.label10 = new System.Windows.Forms.Label(); this.label9 = new System.Windows.Forms.Label(); - this.button1 = new System.Windows.Forms.Button(); + this.button2 = new System.Windows.Forms.Button(); this.tabControl1.SuspendLayout(); this.tabPage2.SuspendLayout(); this.groupBox3.SuspendLayout(); @@ -91,6 +92,7 @@ // // tabPage2 // + this.tabPage2.Controls.Add(this.button2); this.tabPage2.Controls.Add(this.button1); this.tabPage2.Controls.Add(this.ftpProgress); this.tabPage2.Controls.Add(this.btn_transfer_ftp); @@ -115,6 +117,16 @@ this.tabPage2.Text = "Vorraussetzungen"; this.tabPage2.UseVisualStyleBackColor = true; // + // button1 + // + this.button1.Location = new System.Drawing.Point(829, 197); + this.button1.Name = "button1"; + this.button1.Size = new System.Drawing.Size(199, 66); + this.button1.TabIndex = 30; + this.button1.Text = "button1"; + this.button1.UseVisualStyleBackColor = true; + this.button1.Click += new System.EventHandler(this.button1_Click); + // // ftpProgress // this.ftpProgress.Location = new System.Drawing.Point(782, 487); @@ -534,15 +546,15 @@ this.label9.TabIndex = 0; this.label9.Text = "Harz"; // - // button1 + // button2 // - this.button1.Location = new System.Drawing.Point(829, 197); - this.button1.Name = "button1"; - this.button1.Size = new System.Drawing.Size(199, 66); - this.button1.TabIndex = 30; - this.button1.Text = "button1"; - this.button1.UseVisualStyleBackColor = true; - this.button1.Click += new System.EventHandler(this.button1_Click); + this.button2.Location = new System.Drawing.Point(595, 426); + this.button2.Name = "button2"; + this.button2.Size = new System.Drawing.Size(95, 61); + this.button2.TabIndex = 31; + this.button2.Text = "button2"; + this.button2.UseVisualStyleBackColor = true; + this.button2.Click += new System.EventHandler(this.button2_Click); // // UCInliner // @@ -611,5 +623,6 @@ private System.Windows.Forms.Button btn_transfer_ftp; private System.Windows.Forms.ProgressBar ftpProgress; private System.Windows.Forms.Button button1; + private System.Windows.Forms.Button button2; } } diff --git a/SanSystem/UCInliner.cs b/SanSystem/UCInliner.cs index 2b8e763..a3e8deb 100644 --- a/SanSystem/UCInliner.cs +++ b/SanSystem/UCInliner.cs @@ -199,5 +199,11 @@ namespace SanSystem BerichtGen.Options options = new BerichtGen.Options("", "", "", grunddaten,bilderO); options.ShowDialog(); } + + private void button2_Click(object sender, EventArgs e) + { + FrmLinerChart frmLinerChart = new FrmLinerChart(); + frmLinerChart.ShowDialog(); + } } }