Effekt bei der Darstellung mit GraphicsPath

  • C#

Es gibt 2 Antworten in diesem Thema. Der letzte Beitrag () ist von RodFromGermany.

    Effekt bei der Darstellung mit GraphicsPath

    Moin Leute.
    Folgender Code erzeugt eine Datenkurve:
    Spoiler anzeigen

    C#-Quellcode

    1. using System;
    2. using System.Collections.Generic;
    3. using System.Drawing;
    4. using System.Drawing.Drawing2D;
    5. using System.Windows.Forms;
    6. namespace WindowsFormsApplication1
    7. {
    8. public partial class MainForm : Form
    9. {
    10. private GraphicsPath PathPoints;
    11. private GraphicsPath PathPoints2;
    12. private List<PointF> Points;
    13. public MainForm()
    14. {
    15. this.InitializeComponent();
    16. this.PathPoints2 = new GraphicsPath();
    17. }
    18. private void button1_Click(object sender, EventArgs e)
    19. {
    20. this.Points = new List<PointF>();
    21. string path = @"C:\Temp\CRD\Test GraphicsPath.txt";
    22. int i = 0;
    23. foreach (string line in System.IO.File.ReadLines(path))
    24. {
    25. float value = float.Parse(line);
    26. // y-invers
    27. this.Points.Add(new PointF(i, -value));
    28. i++;
    29. }
    30. this.PathPoints = new GraphicsPath();
    31. this.PathPoints.AddLines(this.Points.ToArray());
    32. this.pictureBox1.Invalidate();
    33. }
    34. private void Form1_Resize(object sender, EventArgs e)
    35. {
    36. this.pictureBox1.Invalidate();
    37. }
    38. private void pictureBox1_Paint(object sender, PaintEventArgs e)
    39. {
    40. if (this.PathPoints == null || this.PathPoints.PointCount == 0)
    41. {
    42. // noch keine Daten da
    43. return;
    44. }
    45. this.PathPoints2.Reset();
    46. this.PathPoints2.AddPath(this.PathPoints, false);
    47. using (Matrix matrix = new Matrix())
    48. {
    49. RectangleF rc = this.PathPoints2.GetBounds();
    50. // Linie nicht auf den Rand malen
    51. rc.Inflate(1, 1);
    52. matrix.Scale(this.pictureBox1.ClientRectangle.Width / rc.Width, this.pictureBox1.ClientRectangle.Height / rc.Height);
    53. matrix.Translate(-rc.Left, -rc.Top);
    54. this.PathPoints2.Transform(matrix);
    55. e.Graphics.DrawPath(Pens.Black, this.PathPoints2);
    56. }
    57. }
    58. }
    59. }
    Der Output ist folgender:

    In einem anderen Programm werden dieselben Daten so dargestellt:

    Ich würde gern wissen, wie man da Spline oder BiCubic oder dies eben erzeugt.
    Kann mir jemand auf die Sprünge helfen, welcher Befehl, Parameter oder Property diese abgerundeten Kurven erzeugt?

    Freundlichen Dank
    und
    Allzeit beste Gesundheit.
    Falls Du diesen Code kopierst, achte auf die C&P-Bremse.
    Jede einzelne Zeile Deines Programms, die Du nicht explizit getestet hast, ist falsch :!:
    Ein guter .NET-Snippetkonverter (der ist verfügbar).
    Programmierfragen über PN / Konversation werden ignoriert!
    @Bluespide Jou, hab ich auch gerade gefunden.
    Falls Du diesen Code kopierst, achte auf die C&P-Bremse.
    Jede einzelne Zeile Deines Programms, die Du nicht explizit getestet hast, ist falsch :!:
    Ein guter .NET-Snippetkonverter (der ist verfügbar).
    Programmierfragen über PN / Konversation werden ignoriert!