|
@@ -62,6 +62,38 @@ namespace InABox.Dxf
|
|
|
|
|
|
public delegate void ProcessError(string message);
|
|
|
|
|
|
+ internal static IDxfObject? ConvertEl(EntityObject el)
|
|
|
+ {
|
|
|
+ if(el is Line line)
|
|
|
+ {
|
|
|
+ return new DxfLine { Line = line };
|
|
|
+ }
|
|
|
+ else if(el is Insert insert)
|
|
|
+ {
|
|
|
+ return new DxfInsert(insert);
|
|
|
+ }
|
|
|
+ else if(el is Ellipse ellipse)
|
|
|
+ {
|
|
|
+ return new DxfEllipse(ellipse);
|
|
|
+ }
|
|
|
+ else if(el is MText text)
|
|
|
+ {
|
|
|
+ return new DxfMText(text);
|
|
|
+ }
|
|
|
+ else if(el is Polyline2D ln2D)
|
|
|
+ {
|
|
|
+ return new DxfPolyline2D(ln2D);
|
|
|
+ }
|
|
|
+ else if(el is Dimension dim)
|
|
|
+ {
|
|
|
+ return new DxfDimension(dim);
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
public static Bitmap ProcessImage(Stream stream, string caption = null, bool dimensionmarks = true)
|
|
|
{
|
|
|
var minX = double.MaxValue;
|
|
@@ -101,17 +133,29 @@ namespace InABox.Dxf
|
|
|
var _pen = new Pen(new SolidBrush(Color.Black), 3.0F);
|
|
|
using (var _graphics = Graphics.FromImage(_result))
|
|
|
{
|
|
|
-
|
|
|
+ var data = new DrawData() { Graphics = _graphics };
|
|
|
+
|
|
|
Brush _brush = new SolidBrush(Color.White);
|
|
|
_graphics.FillRectangle(_brush, 0, 0, _result.Width, _result.Height);
|
|
|
|
|
|
+ data.Graphics.ScaleTransform(scale, scale);
|
|
|
+ data.Graphics.TranslateTransform((float)-minX, (float)-minY);
|
|
|
+
|
|
|
+ foreach(var el in document.Entities.All)
|
|
|
+ {
|
|
|
+ var item = ConvertEl(el);
|
|
|
+ item?.Draw(data);
|
|
|
+ }
|
|
|
+
|
|
|
+ /*
|
|
|
foreach (var line in objects.OfType<Line>())
|
|
|
{
|
|
|
try
|
|
|
{
|
|
|
- var _start = VectorToPointF(line.StartPoint, offset, scale, border);
|
|
|
- var _end = VectorToPointF(line.EndPoint, offset, scale, border);
|
|
|
- _graphics.DrawLine(_pen, _start, _end);
|
|
|
+ new DxfLine() { Line = line }.Draw(data);
|
|
|
+ // var _start = VectorToPointF(line.StartPoint, offset, scale, border);
|
|
|
+ // var _end = VectorToPointF(line.EndPoint, offset, scale, border);
|
|
|
+ // _graphics.DrawLine(_pen, _start, _end);
|
|
|
}
|
|
|
catch (Exception e)
|
|
|
{
|
|
@@ -119,7 +163,9 @@ namespace InABox.Dxf
|
|
|
}
|
|
|
|
|
|
}
|
|
|
+ */
|
|
|
|
|
|
+ /*
|
|
|
foreach (var text in objects.OfType<MText>().Where(x=>!string.IsNullOrWhiteSpace(x.Value)))
|
|
|
{
|
|
|
try
|
|
@@ -251,6 +297,7 @@ namespace InABox.Dxf
|
|
|
|
|
|
}
|
|
|
|
|
|
+ */
|
|
|
}
|
|
|
|
|
|
return _result;
|
|
@@ -290,7 +337,6 @@ namespace InABox.Dxf
|
|
|
|
|
|
private static void DimensionToLines(Dimension dimension, List<EntityObject> results, Vector3 offset)
|
|
|
{
|
|
|
- //dimension.
|
|
|
ProcessEntities(dimension.Block.Entities, results, offset);
|
|
|
}
|
|
|
|
|
@@ -317,7 +363,7 @@ namespace InABox.Dxf
|
|
|
|
|
|
private static void InsertToLines(Insert insert, List<EntityObject> results, Vector3 offset)
|
|
|
{
|
|
|
- ProcessEntities(insert.Block.Entities, results, insert.Position += offset);
|
|
|
+ ProcessEntities(insert.Block.Entities, results, insert.Position + offset);
|
|
|
}
|
|
|
|
|
|
private static void PolylineToLines(Polyline2D polyline, List<EntityObject> results, Vector3 offset)
|