Code: Select all
public readonly struct Shape
{
public void Render (Graphics graphics)
{
// Do complex manipulation to draw the shape using the `graphics` object.
graphics.DrawLine(Pens.Red, this.Point1, this.Point2);
graphics.DrawLine(Pens.Red, this.Point2, this.Point3);
...
}
}
< /code>
und der aufrufende Code aus einer WinForms -App: < /p>
private void PictureBox_Paint (object? sender, PaintEventArgs e)
{
var shape = new Shape(...);
shape.Render(e.Graphics);
}