|
@@ -1,5 +1,7 @@
|
|
|
using netDxf;
|
|
|
using netDxf.Tables;
|
|
|
+using Svg;
|
|
|
+using Svg.Transforms;
|
|
|
using System;
|
|
|
using System.Collections.Generic;
|
|
|
using System.Drawing;
|
|
@@ -186,6 +188,8 @@ public interface IGraphics
|
|
|
void SetFont(string fontName, float fontSize, FontStyle fontStyle = FontStyle.Regular);
|
|
|
|
|
|
void DrawText(string text, Color color, PointF position);
|
|
|
+
|
|
|
+ void Clear(Color color);
|
|
|
}
|
|
|
|
|
|
public class GdiGraphics : IGraphics
|
|
@@ -239,4 +243,88 @@ public class GdiGraphics : IGraphics
|
|
|
{
|
|
|
Graphics.Transform = transform;
|
|
|
}
|
|
|
+
|
|
|
+ public void Clear(Color color)
|
|
|
+ {
|
|
|
+ Graphics.Clear(color);
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+public class SvgGraphics : IGraphics
|
|
|
+{
|
|
|
+ public SvgDocument Document { get; set; }
|
|
|
+
|
|
|
+ private SvgMatrix _transform;
|
|
|
+
|
|
|
+ private SvgGroup _group;
|
|
|
+
|
|
|
+ public SvgGraphics(SvgDocument document)
|
|
|
+ {
|
|
|
+ Document = document;
|
|
|
+ _group = new SvgGroup();
|
|
|
+ }
|
|
|
+
|
|
|
+ public void SetTransform(Matrix transform)
|
|
|
+ {
|
|
|
+ _transform = new(transform.Elements.ToList());
|
|
|
+ }
|
|
|
+
|
|
|
+ public void DrawLine(Color color, float thickness, params PointF[] points)
|
|
|
+ {
|
|
|
+ if(points.Length == 2)
|
|
|
+ {
|
|
|
+ Document.Children.Add(new SvgLine
|
|
|
+ {
|
|
|
+ StartX = points[0].X,
|
|
|
+ StartY = points[0].Y,
|
|
|
+ EndX = points[1].X,
|
|
|
+ EndY = points[1].Y,
|
|
|
+ Transforms = new()
|
|
|
+ {
|
|
|
+ _transform
|
|
|
+ },
|
|
|
+ Stroke = new SvgColourServer(color),
|
|
|
+ StrokeWidth = thickness
|
|
|
+ });
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ var line = new SvgPolyline
|
|
|
+ {
|
|
|
+ Transforms = new()
|
|
|
+ {
|
|
|
+ _transform
|
|
|
+ },
|
|
|
+ Stroke = new SvgColourServer(color),
|
|
|
+ StrokeWidth = thickness
|
|
|
+ };
|
|
|
+ foreach(var point in points)
|
|
|
+ {
|
|
|
+ line.Points.Add(point.X);
|
|
|
+ line.Points.Add(point.Y);
|
|
|
+ }
|
|
|
+
|
|
|
+ Document.Children.Add(line);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ public void FillPolygon(Color color, params PointF[] points)
|
|
|
+ {
|
|
|
+ }
|
|
|
+
|
|
|
+ public void SetFont(float fontSize, FontStyle fontStyle = FontStyle.Regular)
|
|
|
+ {
|
|
|
+ }
|
|
|
+
|
|
|
+ public void SetFont(string fontName, float fontSize, FontStyle fontStyle = FontStyle.Regular)
|
|
|
+ {
|
|
|
+ }
|
|
|
+
|
|
|
+ public void DrawText(string text, Color color, PointF position)
|
|
|
+ {
|
|
|
+ }
|
|
|
+
|
|
|
+ public void Clear(Color color)
|
|
|
+ {
|
|
|
+ }
|
|
|
}
|