//--------------------------------------------------------------------------------------------------

        void _ImportRectangle(SvgRectElement rectangle)
        {
            if ((rectangle.CornerRadiusX > 0) || (rectangle.CornerRadiusY > 0))
            {
                Messages.Warning("Imported SVG shape does have an rectangle with corner radius, which are not supported yet. [ " + rectangle.ID + " ]");
            }

            var leftTop = rectangle.Start;
            var left    = leftTop.X;
            var top     = leftTop.Y;
            var right   = left + rectangle.Width;
            var bottom  = top + rectangle.Height;

            var points = new[]
            {
                _AddPoint(new Pnt2d(left, top)),
                _AddPoint(new Pnt2d(right, top)),
                _AddPoint(new Pnt2d(right, bottom)),
                _AddPoint(new Pnt2d(left, bottom))
            };

            _Segments.Add(new SketchSegmentLine(points[0], points[1]));
            _Segments.Add(new SketchSegmentLine(points[1], points[2]));
            _Segments.Add(new SketchSegmentLine(points[2], points[3]));
            _Segments.Add(new SketchSegmentLine(points[3], points[0]));
        }
Exemplo n.º 2
0
        internal virtual bool Read(XmlReader reader, SvgConverter conv)
        {
            var transformString = reader.GetAttribute("transform");

            if (!transformString.IsNullOrEmpty())
            {
                Transforms.AddRange(SvgTransform.Create(transformString, conv));
            }

            conv.PushTransform(Transforms);
            var depth = reader.Depth;

            reader.Read();
            while (!reader.EOF && reader.Depth > depth)
            {
                if (reader.NodeType != XmlNodeType.Element)
                {
                    reader.Read();
                    continue;
                }

                SvgElement newElement = null;
                switch (reader.LocalName.ToLower())
                {
                case "g":
                    newElement = new SvgGroupElement();
                    break;

                case "circle":
                    newElement = new SvgCircleElement();
                    break;

                case "ellipse":
                    newElement = new SvgEllipseElement();
                    break;

                case "path":
                    newElement = new SvgPathElement();
                    break;

                case "line":
                    newElement = new SvgLineElement();
                    break;

                case "rect":
                    newElement = new SvgRectElement();
                    break;
                }

                if (newElement != null)
                {
                    if (newElement.Read(reader, conv))
                    {
                        Children.Add(newElement);
                    }
                }
                else
                {
                    reader.Skip();
                }
            }

            return(true);
        }