Exemple #1
0
        public static PolylineDrawable Create(SvgPolyline svgPolyline, SKRect skViewport, DrawableBase?parent, IAssetLoader assetLoader, HashSet <Uri>?references, DrawAttributes ignoreAttributes = DrawAttributes.None)
        {
            var drawable = new PolylineDrawable(assetLoader, references)
            {
                Element          = svgPolyline,
                Parent           = parent,
                IgnoreAttributes = ignoreAttributes
            };

            drawable.IsDrawable = drawable.CanDraw(svgPolyline, drawable.IgnoreAttributes) && drawable.HasFeatures(svgPolyline, drawable.IgnoreAttributes);

            if (!drawable.IsDrawable)
            {
                return(drawable);
            }

            drawable.Path = svgPolyline.Points?.ToPath(svgPolyline.FillRule, false, skViewport);
            if (drawable.Path is null || drawable.Path.IsEmpty)
            {
                drawable.IsDrawable = false;
                return(drawable);
            }

            drawable.Initialize(skViewport, references);

            return(drawable);
        }
        private void ReadPolylineAttributes(PolylineVObject vObject, SvgPolyline svg)
        {
            ReadBaseRectangleVObjectAttributes(vObject, svg);

            var controlPoints = new PointF[svg.Points.Count];

            for (int i = 0; i < controlPoints.Length; i++)
            {
                var p = svg.Points[i];
                controlPoints[i] = new PointF(p.X, p.Y);
            }
            vObject.ControlPoints = controlPoints;

            vObject.Width = svg.StrokeWidth;

            string color = null;

            foreach (var attr in svg.CustomAttributes)
            {
                if (attr.NamespaceUri == XmlNamespace.AurigmaVectorObjects && attr.LocalName == "color")
                {
                    color = attr.GetValue();
                    break;
                }
            }
            vObject.Color = !string.IsNullOrEmpty(color) ? _serializer.Deserialize <Color>(color) : new RgbColor(svg.Stroke);
        }
        private void LoadConfigButton_Click(object sender, EventArgs e)
        {
            if (LoadFile.ShowDialog() == DialogResult.Cancel)
            {
                return;
            }

            var lines = File.ReadAllLines(LoadFile.FileName);

            var parser = new FileParser();

            Scene scene;

            try
            {
                scene = parser.Parse(lines);
            }
            catch
            {
                MessageBox.Show(@"Could not parse file", @"Error");
                return;
            }

            var pointsBuilder = new PointsBuilder();

            var svg = new SvgDocument
            {
                Height = scene.Height,
                Width  = scene.Width
            };

            foreach (var figure in scene.Figures)
            {
                var polyline = new SvgPolyline
                {
                    Points      = new SvgPointCollection(),
                    Fill        = new SvgColourServer(Color.Transparent),
                    Stroke      = new SvgColourServer(figure.LineColor),
                    StrokeWidth = new SvgUnit((float)figure.LineThickness)
                };

                var points = pointsBuilder.Build(figure.Polygon, figure.LineSpacing, figure.DrawingDirection);

                foreach (var point in points)
                {
                    polyline.Points.Add(new SvgUnit(SvgUnitType.Point, (float)point.X));
                    polyline.Points.Add(new SvgUnit(SvgUnitType.Point, (float)point.Y));
                }

                svg.Children.Add(polyline);
            }

            var svgPath = LoadFile.FileName.Substring(0, LoadFile.FileName.Length - 4) + "_image.svg";

            svg.Write(svgPath);
            MessageBox.Show(
                text: svgPath,
                caption: @"Success");
        }
Exemple #4
0
        public PolylineDrawable(SvgPolyline svgPolyline, SKRect skOwnerBounds, Drawable?root, Drawable?parent, Attributes ignoreAttributes = Attributes.None)
            : base(svgPolyline, root, parent)
        {
            IgnoreAttributes = ignoreAttributes;
            IsDrawable       = CanDraw(svgPolyline, IgnoreAttributes) && HasFeatures(svgPolyline, IgnoreAttributes);

            if (!IsDrawable)
            {
                return;
            }

            Path = svgPolyline.Points?.ToSKPath(svgPolyline.FillRule, false, skOwnerBounds, _disposable);
            if (Path == null || Path.IsEmpty)
            {
                IsDrawable = false;
                return;
            }

            IsAntialias = SvgPaintingExtensions.IsAntialias(svgPolyline);

            TransformedBounds = Path.Bounds;

            Transform = SvgTransformsExtensions.ToSKMatrix(svgPolyline.Transforms);

            bool canDrawFill   = true;
            bool canDrawStroke = true;

            if (SvgPaintingExtensions.IsValidFill(svgPolyline))
            {
                Fill = SvgPaintingExtensions.GetFillSKPaint(svgPolyline, TransformedBounds, ignoreAttributes, _disposable);
                if (Fill == null)
                {
                    canDrawFill = false;
                }
            }

            if (SvgPaintingExtensions.IsValidStroke(svgPolyline, TransformedBounds))
            {
                Stroke = SvgPaintingExtensions.GetStrokeSKPaint(svgPolyline, TransformedBounds, ignoreAttributes, _disposable);
                if (Stroke == null)
                {
                    canDrawStroke = false;
                }
            }

            if (canDrawFill && !canDrawStroke)
            {
                IsDrawable = false;
                return;
            }

            SvgMarkerExtensions.CreateMarkers(svgPolyline, Path, skOwnerBounds, ref MarkerDrawables, _disposable);

            // TODO: Transform _skBounds using _skMatrix.
            TransformedBounds = Transform.MapRect(TransformedBounds);
        }
Exemple #5
0
        public void DrawPolyline(SvgPolyline svgPolyline, bool ignoreDisplay)
        {
            if (!CanDraw(svgPolyline, ignoreDisplay))
            {
                return;
            }

            _skCanvas.Save();

            var skMatrix = SkiaUtil.GetSKMatrix(svgPolyline.Transforms);

            SetTransform(skMatrix);
            SetClipPath(svgPolyline, _disposable);

            var skPaintOpacity = SetOpacity(svgPolyline, _disposable);

            var skPaintFilter = SetFilter(svgPolyline, _disposable);

            var skPath = SkiaUtil.ToSKPath(svgPolyline.Points, svgPolyline.FillRule, false, _disposable);

            if (skPath != null && !skPath.IsEmpty)
            {
                var skBounds = skPath.Bounds;

                if (SkiaUtil.IsValidFill(svgPolyline))
                {
                    var skPaint = SkiaUtil.GetFillSKPaint(svgPolyline, _skSize, skBounds, _disposable);
                    _skCanvas.DrawPath(skPath, skPaint);
                }

                if (SkiaUtil.IsValidStroke(svgPolyline))
                {
                    var skPaint = SkiaUtil.GetStrokeSKPaint(svgPolyline, _skSize, skBounds, _disposable);
                    _skCanvas.DrawPath(skPath, skPaint);
                }

                DrawMarkers(svgPolyline, skPath);
            }

            if (skPaintFilter != null)
            {
                _skCanvas.Restore();
            }

            if (skPaintOpacity != null)
            {
                _skCanvas.Restore();
            }

            _skCanvas.Restore();
        }
        private void WritePolylineAttributes(SvgPolyline svg, PolylineVObject vObject)
        {
            WriteBaseRectangleVObjectAttributes(svg, vObject);

            var points = svg.Points;

            foreach (var p in vObject.GetPoints())
            {
                points.Add(p.ToPoint());
            }

            var cm = vObject.GetColorManagement(true);

            svg.Stroke = ColorManagement.GetPreviewColor(cm, vObject.Color);
            svg.CustomAttributes.Add(new SvgVoAttribute("color", _serializer.Serialize(vObject.Color)));

            svg.StrokeWidth = vObject.Width;
            svg.Fill        = RgbColor.Transparent;
        }
        private void SaveAsSvgButton_Click(object sender, EventArgs e)
        {
            var bitmap = BuildBitmap();

            PictureBox.Image = bitmap;

            if (bitmap == null)
            {
                return;
            }

            if (SaveSvgFileDialog.ShowDialog() == DialogResult.Cancel)
            {
                return;
            }

            var svg = new SvgDocument
            {
                Height = PictureBox.Height,
                Width  = PictureBox.Height
            };

            var polyline = new SvgPolyline
            {
                Points      = new SvgPointCollection(),
                Fill        = new SvgColourServer(Color.Transparent),
                Stroke      = new SvgColourServer(Color.Black),
                StrokeWidth = new SvgUnit(1),
            };

            var points = GetTrianglePoints();

            foreach (var point in points)
            {
                polyline.Points.Add(new SvgUnit(SvgUnitType.Point, (float)point.X));
                polyline.Points.Add(new SvgUnit(SvgUnitType.Point, (float)point.Y));
            }

            svg.Children.Add(polyline);

            svg.Write(SaveSvgFileDialog.FileName);
        }
Exemple #8
0
 public static DrawableBase?Create(SvgElement svgElement, Rect skOwnerBounds, DrawableBase?parent, IAssetLoader assetLoader, Attributes ignoreAttributes = Attributes.None)
 {
     return(svgElement switch
     {
         SvgAnchor svgAnchor => AnchorDrawable.Create(svgAnchor, skOwnerBounds, parent, assetLoader, ignoreAttributes),
         SvgFragment svgFragment => FragmentDrawable.Create(svgFragment, skOwnerBounds, parent, assetLoader, ignoreAttributes),
         SvgImage svgImage => ImageDrawable.Create(svgImage, skOwnerBounds, parent, assetLoader, ignoreAttributes),
         SvgSwitch svgSwitch => SwitchDrawable.Create(svgSwitch, skOwnerBounds, parent, assetLoader, ignoreAttributes),
         SvgUse svgUse => UseDrawable.Create(svgUse, skOwnerBounds, parent, assetLoader, ignoreAttributes),
         SvgCircle svgCircle => CircleDrawable.Create(svgCircle, skOwnerBounds, parent, assetLoader, ignoreAttributes),
         SvgEllipse svgEllipse => EllipseDrawable.Create(svgEllipse, skOwnerBounds, parent, assetLoader, ignoreAttributes),
         SvgRectangle svgRectangle => RectangleDrawable.Create(svgRectangle, skOwnerBounds, parent, assetLoader, ignoreAttributes),
         SvgGroup svgGroup => GroupDrawable.Create(svgGroup, skOwnerBounds, parent, assetLoader, ignoreAttributes),
         SvgLine svgLine => LineDrawable.Create(svgLine, skOwnerBounds, parent, assetLoader, ignoreAttributes),
         SvgPath svgPath => PathDrawable.Create(svgPath, skOwnerBounds, parent, assetLoader, ignoreAttributes),
         SvgPolyline svgPolyline => PolylineDrawable.Create(svgPolyline, skOwnerBounds, parent, assetLoader, ignoreAttributes),
         SvgPolygon svgPolygon => PolygonDrawable.Create(svgPolygon, skOwnerBounds, parent, assetLoader, ignoreAttributes),
         SvgText svgText => TextDrawable.Create(svgText, skOwnerBounds, parent, assetLoader, ignoreAttributes),
         _ => null,
     });
Exemple #9
0
 public static Drawable?Create(SvgElement svgElement, SKRect skOwnerBounds, Drawable?root, Drawable?parent, Attributes ignoreAttributes = Attributes.None)
 {
     return(svgElement switch
     {
         SvgAnchor svgAnchor => new AnchorDrawable(svgAnchor, skOwnerBounds, root, parent, ignoreAttributes),
         SvgFragment svgFragment => new FragmentDrawable(svgFragment, skOwnerBounds, root, parent, ignoreAttributes),
         SvgImage svgImage => new ImageDrawable(svgImage, skOwnerBounds, root, parent, ignoreAttributes),
         SvgSwitch svgSwitch => new SwitchDrawable(svgSwitch, skOwnerBounds, root, parent, ignoreAttributes),
         SvgUse svgUse => new UseDrawable(svgUse, skOwnerBounds, root, parent, ignoreAttributes),
         SvgCircle svgCircle => new CircleDrawable(svgCircle, skOwnerBounds, root, parent, ignoreAttributes),
         SvgEllipse svgEllipse => new EllipseDrawable(svgEllipse, skOwnerBounds, root, parent, ignoreAttributes),
         SvgRectangle svgRectangle => new RectangleDrawable(svgRectangle, skOwnerBounds, root, parent, ignoreAttributes),
         SvgGroup svgGroup => new GroupDrawable(svgGroup, skOwnerBounds, root, parent, ignoreAttributes),
         SvgLine svgLine => new LineDrawable(svgLine, skOwnerBounds, root, parent, ignoreAttributes),
         SvgPath svgPath => new PathDrawable(svgPath, skOwnerBounds, root, parent, ignoreAttributes),
         SvgPolyline svgPolyline => new PolylineDrawable(svgPolyline, skOwnerBounds, root, parent, ignoreAttributes),
         SvgPolygon svgPolygon => new PolygonDrawable(svgPolygon, skOwnerBounds, root, parent, ignoreAttributes),
         SvgText svgText => new TextDrawable(svgText, skOwnerBounds, root, parent, ignoreAttributes),
         _ => null,
     });
Exemple #10
0
 public static XnaDrawPolygon Create(SvgPolyline svg)
 {
     try
     {
         string   s      = svg.Points.Trim();
         string[] arr    = s.Split(' ');
         var      points = new Point[arr.Length];
         for (int i = 0; i < arr.Length; i++)
         {
             var arrp = arr[i].Split(',');
             points[i] = new Point((int)ParseSize(arrp[0], Dpi.X),
                                   (int)ParseSize(arrp[1], Dpi.Y));
         }
         var dobj = new XnaDrawPolygon(points);
         dobj.SetStyleFromSvg(svg);
         return(dobj);
     }
     catch (Exception ex)
     {
         ErrH.Log("DrawPolygon", "Create", ex.ToString(), ErrH._LogPriority.Info);
         return(null);
     }
 }
Exemple #11
0
 public Polyline(SvgPolyline svgPolyline)
 {
     matrix = SvgHelper.GetSKMatrix(svgPolyline.Transforms);
 }
        public override RenderedSvg RenderColumn()
        {
            var result = base.RenderColumn();


            SvgGroup group = new SvgGroup();

            VisualLayerPresentingVM[] layers = vm.Layers.ToArray();



            for (int i = 0; i < layers.Length; i++)
            {
                VisualLayerPresentingVM lvm = layers[i];
                SvgGroup levelGroup         = new SvgGroup();
                if (lvm.BackgroundClass.CurrentClass != null)
                {
                    ISideCurveGenerator rightSideCurveGenerator = null;
                    if ((lvm.RightSideClass != null) && (lvm.RightSideClass.CurrentClass != null))
                    {
                        rightSideCurveGenerator = SideCurveGeneratorFactory.GetGeneratorFor(lvm.RightSideClass.CurrentClass.RightSideForm);
                    }
                    else
                    {
                        rightSideCurveGenerator = SideCurveGeneratorFactory.GetGeneratorFor(AnnotationPlane.Template.RightSideFormEnum.NotDefined);
                    }

                    SvgPolyline rightEdge = new SvgPolyline
                    {
                        Stroke      = new SvgColourServer(System.Drawing.Color.Black),
                        StrokeWidth = 1f
                    };

                    var rightPoints = Drawing.GetRightPolyline(lvm.Width, lvm.Height, rightSideCurveGenerator).ToArray();

                    SvgPointCollection svgPoints = new SvgPointCollection();
                    for (int j = 0; j < rightPoints.Length; j++)
                    {
                        var point = rightPoints[j];
                        point.Y += lvm.Y;
                        AddPointToCollection(svgPoints, point);
                    }

                    rightEdge.Points = svgPoints;

                    levelGroup.Children.Add(rightEdge);


                    ISideCurveGenerator bottomSideCurveGenerator = null;
                    if ((lvm.BottomSideClass != null) && (lvm.BottomSideClass.CurrentClass != null))
                    {
                        bottomSideCurveGenerator = SideCurveGeneratorFactory.GetGeneratorFor(lvm.BottomSideClass.CurrentClass.BottomSideForm);
                    }
                    else
                    {
                        bottomSideCurveGenerator = SideCurveGeneratorFactory.GetGeneratorFor(AnnotationPlane.Template.BottomSideFormEnum.NotDefined);
                    }

                    SvgPolyline bottomEdge = new SvgPolyline
                    {
                        Stroke        = new SvgColourServer(System.Drawing.Color.Black),
                        StrokeLineCap = SvgStrokeLineCap.Round,
                        StrokeWidth   = 1f
                    };
                    if (lvm.BottomSideClass.CurrentClass != null)
                    {
                        if (lvm.BottomSideClass.CurrentClass.BottomSideForm == AnnotationPlane.Template.BottomSideFormEnum.Dotted)
                        {
                            bottomEdge.StrokeDashArray = new List <float>()
                            {
                                3, 3
                            }.
                            Select(p => new SvgUnit(p)) as SvgUnitCollection;
                        }
                    }

                    var bottomPoints = Drawing.GetBottomPolyline(lvm.Width, lvm.Height, bottomSideCurveGenerator).ToArray();

                    SvgPointCollection svgBottomPoints = new SvgPointCollection();
                    for (int j = 0; j < bottomPoints.Length; j++)
                    {
                        var point = bottomPoints[j];
                        point.Y += lvm.Y;
                        AddPointToCollection(svgBottomPoints, point);
                    }

                    bottomEdge.Points = svgBottomPoints;

                    levelGroup.Children.Add(bottomEdge);


                    SvgPolygon bckgrPolygon = new SvgPolygon
                    {
                        StrokeWidth = 0f
                    };

                    SvgPatternServer sps = lvm.BackgroundClass.CurrentClass.BackgroundPattern;
                    sps.PatternContentUnits = SvgCoordinateUnits.ObjectBoundingBox;
                    sps.PatternUnits        = SvgCoordinateUnits.UserSpaceOnUse;
                    float ratio = sps.Width.Value / 64f;
                    sps.Width  /= ratio;
                    sps.Height /= ratio;

                    bckgrPolygon.Fill = sps;

                    var bckgrPoints = Drawing.GetBackgroundPolyline(lvm.Width, lvm.Height, rightSideCurveGenerator).ToArray();

                    SvgPointCollection svgBckgrPoints = new SvgPointCollection();
                    for (int j = 0; j < bckgrPoints.Length; j++)
                    {
                        var point = bckgrPoints[j];
                        point.Y += lvm.Y;
                        AddPointToCollection(svgBckgrPoints, point);
                    }

                    bckgrPolygon.Points = svgBckgrPoints;

                    levelGroup.Children.Add(bckgrPolygon);


                    group.Children.Add(levelGroup);
                }
            }

            result.SVG = group;

            return(result);
        }
        public static PolylineDrawable Create(SvgPolyline svgPolyline, Rect skOwnerBounds, DrawableBase?parent, IAssetLoader assetLoader, Attributes ignoreAttributes = Attributes.None)
        {
            var drawable = new PolylineDrawable(assetLoader)
            {
                Element          = svgPolyline,
                Parent           = parent,
                IgnoreAttributes = ignoreAttributes
            };

            drawable.IsDrawable = drawable.CanDraw(svgPolyline, drawable.IgnoreAttributes) && drawable.HasFeatures(svgPolyline, drawable.IgnoreAttributes);

            if (!drawable.IsDrawable)
            {
                return(drawable);
            }

            drawable.Path = svgPolyline.Points?.ToPath(svgPolyline.FillRule, false, skOwnerBounds);
            if (drawable.Path is null || drawable.Path.IsEmpty)
            {
                drawable.IsDrawable = false;
                return(drawable);
            }

            drawable.IsAntialias = SvgModelExtensions.IsAntialias(svgPolyline);

            drawable.TransformedBounds = drawable.Path.Bounds;

            drawable.Transform = SvgModelExtensions.ToMatrix(svgPolyline.Transforms);

            var canDrawFill   = true;
            var canDrawStroke = true;

            if (SvgModelExtensions.IsValidFill(svgPolyline))
            {
                drawable.Fill = SvgModelExtensions.GetFillPaint(svgPolyline, drawable.TransformedBounds, assetLoader, ignoreAttributes);
                if (drawable.Fill is null)
                {
                    canDrawFill = false;
                }
            }

            if (SvgModelExtensions.IsValidStroke(svgPolyline, drawable.TransformedBounds))
            {
                drawable.Stroke = SvgModelExtensions.GetStrokePaint(svgPolyline, drawable.TransformedBounds, assetLoader, ignoreAttributes);
                if (drawable.Stroke is null)
                {
                    canDrawStroke = false;
                }
            }

            if (canDrawFill && !canDrawStroke)
            {
                drawable.IsDrawable = false;
                return(drawable);
            }

            SvgModelExtensions.CreateMarkers(svgPolyline, drawable.Path, skOwnerBounds, drawable, assetLoader);

            // TODO: Transform _skBounds using _skMatrix.
            drawable.TransformedBounds = drawable.Transform.MapRect(drawable.TransformedBounds);

            return(drawable);
        }
 internal SvgElement ToSvg(VObject vObject)
 {
     if (vObject is GridVObject)
     {
         var svg = new SvgVoGrid();
         WriteGridAttributes(svg, vObject as GridVObject);
         return(svg);
     }
     else if (vObject is PolylineVObject)
     {
         var svg = new SvgPolyline();
         WritePolylineAttributes(svg, vObject as PolylineVObject);
         return(svg);
     }
     else if (vObject is DashedLineVObject)
     {
         var svg = new SvgVoDashLine();
         WriteDashLineAttributes(svg, vObject as DashedLineVObject);
         return(svg);
     }
     else if (vObject is LineVObject)
     {
         var svg = new SvgLine();
         WriteLineAttributes(svg, vObject as LineVObject);
         return(svg);
     }
     else if (vObject is EllipseVObject)
     {
         var svg = new SvgEllipse();
         WriteEllipseAttributes(svg, vObject as EllipseVObject);
         return(svg);
     }
     else if (vObject is SvgVObject)
     {
         var svg = new SvgVoSvg();
         WriteSvgAttributes(svg, vObject as SvgVObject);
         return(svg);
     }
     else if (vObject is ImageVObject)
     {
         var svg = new SvgVoImage();
         WriteImageAttributes(svg, vObject as ImageVObject);
         return(svg);
     }
     else if (vObject is PlainTextVObject)
     {
         var svg = new SvgVoPlainText();
         WritePlainTextAttributes(svg, vObject as PlainTextVObject);
         return(svg);
     }
     else if (vObject is CurvedTextVObject)
     {
         var svg = new SvgVoCurvedText();
         WriteCurvedTextAttributes(svg, vObject as CurvedTextVObject);
         return(svg);
     }
     else if (vObject is PathBoundedTextVObject)
     {
         var svg = new SvgVoPathBoundedText();
         WritePathBoundedTextAttributes(svg, vObject as PathBoundedTextVObject);
         return(svg);
     }
     else if (vObject is BoundedTextVObject)
     {
         var svg = new SvgVoBoundedText();
         WriteBoundedTextAttributes(svg, vObject as BoundedTextVObject);
         return(svg);
     }
     else if (vObject is AutoScaledTextVObject)
     {
         var svg = new SvgVoAutoScaledText();
         WriteAutoScaledTextAttributes(svg, vObject as AutoScaledTextVObject);
         return(svg);
     }
     else if (vObject is PlaceholderVObject)
     {
         var svg = new SvgVoPlaceholder();
         WritePlaceholderAttributes(svg, vObject as PlaceholderVObject);
         return(svg);
     }
     else if (vObject is RectangleVObject)
     {
         var svg = new SvgVoRectangle();
         WriteRectangleAttributes(svg, vObject as RectangleVObject);
         return(svg);
     }
     else if (vObject is ShapeVObject)
     {
         var svg = new SvgVoShape();
         WriteShapeAttributes(svg, vObject as ShapeVObject);
         return(svg);
     }
     else
     {
         return(null);
     }
 }
        public static void DrawOrDiscardEntity(BlockTableRecord btr, Transaction tx,
                                               Matrix3d transform, Svg.SvgGroup group)//, int upscale)
        {
            foreach (oid oid in btr)
            {
                switch (oid.ObjectClass.Name)
                {
                case "AcDbLine":
                    //prdDbg(oid.ObjectClass.Name);
                    Line line = oid.Go <Line>(tx);
                    using (Line newLine = new Line(line.StartPoint, line.EndPoint))
                    {
                        newLine.TransformBy(transform);
                        SvgLine sline = new Svg.SvgLine
                        {
                            StartX      = ts(newLine.StartPoint.X),
                            StartY      = ts(-newLine.StartPoint.Y),
                            EndX        = ts(newLine.EndPoint.X),
                            EndY        = ts(-newLine.EndPoint.Y),
                            StrokeWidth = ts(0.1),
                            Stroke      = new Svg.SvgColourServer(System.Drawing.Color.Black)
                        };
                        //if (flip != Flip.PP)
                        //{
                        //    sline.Transforms = AddTransforms(flip,
                        //        sline.StartX + sline.EndX,
                        //        sline.StartY + sline.EndY);
                        //}
                        group.Children.Add(sline);
                        //mSpc.AppendEntity(newLine);
                        //tx.AddNewlyCreatedDBObject(newLine, true);
                    }
                    break;

                case "AcDbPolyline":
                    //prdDbg(oid.ObjectClass.Name);
                    Polyline pline = oid.Go <Polyline>(tx);
                    using (Polyline newPline = new Polyline(pline.NumberOfVertices))
                    {
                        for (int i = 0; i < pline.NumberOfVertices; i++)
                        {
                            newPline.AddVertexAt(i, pline.GetPoint2dAt(i), 0, 0, 0);
                        }
                        newPline.TransformBy(transform);
                        Extents3d          bbox = newPline.GeometricExtents; //Prepare for Svg.Transforms
                        SvgPointCollection pcol = new SvgPointCollection();
                        for (int i = 0; i < newPline.NumberOfVertices; i++)
                        {
                            Point2d p2d = newPline.GetPoint2dAt(i);
                            pcol.Add(ts(p2d.X));
                            pcol.Add(ts(-p2d.Y));
                        }
                        SvgPolyline sPline = new SvgPolyline();
                        sPline.Points = pcol;
                        if (pline.NumberOfVertices == 2)
                        {
                            sPline.StrokeWidth = ts(0.1);
                            sPline.Stroke      = new SvgColourServer(System.Drawing.Color.Black);
                        }
                        else
                        {
                            sPline.Fill = new SvgColourServer(System.Drawing.Color.Black);
                        }
                        //if (flip != Flip.PP)
                        //{
                        //    sPline.Transforms = AddTransforms(flip,
                        //    ts(bbox.MinPoint.X + bbox.MaxPoint.X),
                        //    ts(bbox.MinPoint.Y + bbox.MaxPoint.Y));
                        //}
                        group.Children.Add(sPline);
                    }
                    break;

                case "AcDbCircle":
                    //prdDbg(oid.ObjectClass.Name);
                    Circle circle = oid.Go <Circle>(tx);
                    using (Circle newCircle = new Circle())
                    {
                        newCircle.SetDatabaseDefaults();
                        newCircle.Center = circle.Center;
                        newCircle.Radius = circle.Radius;
                        newCircle.TransformBy(transform);
                        SvgCircle sCircle = new Svg.SvgCircle
                        {
                            CenterX = ts(newCircle.Center.X),
                            CenterY = ts(-newCircle.Center.Y),
                            Radius  = ts(newCircle.Radius),
                            Fill    = new Svg.SvgColourServer(System.Drawing.Color.Black),
                        };
                        //if (flip != Flip.PP)
                        //{
                        //    sCircle.Transforms = AddTransforms(flip,
                        //    2 * sCircle.CenterX,
                        //    2 * sCircle.CenterY);
                        //}
                        group.Children.Add(sCircle);
                        //mSpc.AppendEntity(newCircle);
                        //tx.AddNewlyCreatedDBObject(newCircle, true);
                    }
                    break;

                case "AcDbMText":
                    prdDbg(oid.ObjectClass.Name);
                    MText  mText = oid.Go <MText>(tx);
                    string text  = mText.Contents;
                    using (DBText newText = new DBText())
                    {
                        newText.SetDatabaseDefaults();
                        newText.TextString = text;
                        newText.Position   = mText.Location;
                        newText.Rotation   = mText.Rotation;
                        //newText.TransformBy(transform);
                        SvgText sText = new SvgText(newText.TextString);
                        prdDbg(ts(newText.Position.X).ToString());
                        prdDbg(ts(newText.Position.Y).ToString());
                        sText.X.Add(ts(newText.Position.X));
                        sText.Y.Add(ts(newText.Position.Y + 0.1));
                        sText.FontFamily = "Arial";
                        sText.FontSize   = ts(0.50);
                        prdDbg(ts(newText.Rotation * (180 / Math.PI)).ToString());
                        sText.Rotate = ts(newText.Rotation * (180 / Math.PI)).ToString();
                        sText.Fill   = new SvgColourServer(System.Drawing.Color.Black);
                        group.Children.Add(sText);
                    }
                    break;

                case "AcDbBlockReference":
                    DrawOrDiscardEntity(tx.GetObject(oid, OpenMode.ForRead) as BlockReference, tx, group);    //, upscale);
                    break;

                default:
                    //prdDbg("Not implemented: " + oid.ObjectClass.Name);
                    break;
                }
            }
        }