Example #1
0
        private void ReadLineAttributes(LineVObject vObject, SvgLine svg)
        {
            ReadBaseRectangleVObjectAttributes(vObject, svg);

            vObject.Width         = svg.StrokeWidth;
            vObject.ControlPoints = new[]
            {
                new PointF(svg.X1, svg.Y1),
                new PointF(svg.X2, svg.Y2)
            };

            string color = null;

            foreach (var attr in svg.CustomAttributes)
            {
                if (attr.NamespaceUri == XmlNamespace.AurigmaVectorObjects && attr.LocalName == "fixed-width")
                {
                    vObject.FixedWidth = attr.GetValue() == "true";
                }
                else if (attr.NamespaceUri == XmlNamespace.AurigmaVectorObjects && attr.LocalName == "color")
                {
                    color = attr.GetValue();
                }
            }
            vObject.Color = !string.IsNullOrEmpty(color) ? _serializer.Deserialize <Color>(color) : new RgbColor(svg.Stroke);
        }
 public LineVObjectData(LineVObject obj)
     : base(obj)
 {
     C  = obj.Color;
     W  = obj.Width;
     FW = obj.FixedWidth;
 }
        protected override IVObject CreateObject()
        {
            LineVObject result = null;

            if ((_point0.X - _point1.X) * (_point0.X - _point1.X) + (_point0.Y - _point1.Y) * (_point0.Y - _point1.Y) > 1)
            {
                result       = new LineVObject(_point0, _point1);
                result.Brush = null;
                result.Pen   = (System.Drawing.Pen)base.Pen.Clone();
            }

            return(result);
        }
Example #4
0
        private void WriteLineAttributes(SvgLine svg, LineVObject vObject)
        {
            WriteBaseRectangleVObjectAttributes(svg, vObject);

            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.X1          = vObject.Point0.X;
            svg.Y1          = vObject.Point0.Y;
            svg.X2          = vObject.Point1.X;
            svg.Y2          = vObject.Point1.Y;

            if (vObject.FixedWidth)
            {
                svg.CustomAttributes.Add(new SvgVoAttribute("fixed-width", vObject.FixedWidth));
            }
        }
Example #5
0
 internal VObject FromSvg(SvgElement svg)
 {
     if (svg is SvgVoGrid)
     {
         var vObject = new GridVObject();
         ReadGridAttributes(vObject, svg as SvgVoGrid);
         return(vObject);
     }
     else if (svg is SvgPolyline)
     {
         var vObject = new PolylineVObject();
         ReadPolylineAttributes(vObject, svg as SvgPolyline);
         return(vObject);
     }
     else if (svg is SvgVoDashLine)
     {
         var vObject = new DashedLineVObject();
         ReadDashLineAttributes(vObject, svg as SvgVoDashLine);
         return(vObject);
     }
     else if (svg is SvgLine)
     {
         var vObject = new LineVObject();
         ReadLineAttributes(vObject, svg as SvgLine);
         return(vObject);
     }
     else if (svg is SvgEllipse)
     {
         var vObject = new EllipseVObject();
         ReadEllipseAttributes(vObject, svg as SvgEllipse);
         return(vObject);
     }
     else if (svg is SvgVoSvg)
     {
         var vObject = new SvgVObject();
         ReadSvgAttributes(vObject, svg as SvgVoSvg);
         return(vObject);
     }
     else if (svg is SvgVoImage)
     {
         var vObject = new ImageVObject();
         ReadImageAttributes(vObject, svg as SvgVoImage);
         return(vObject);
     }
     else if (svg is SvgVoPlainText)
     {
         var vObject = new PlainTextVObject();
         ReadPlainTextAttributes(vObject, svg as SvgVoPlainText);
         return(vObject);
     }
     else if (svg is SvgVoCurvedText)
     {
         var vObject = new CurvedTextVObject();
         ReadCurvedTextAttributes(vObject, svg as SvgVoCurvedText);
         return(vObject);
     }
     else if (svg is SvgVoAutoScaledText)
     {
         var vObject = new AutoScaledTextVObject();
         ReadAutoScaledTextAttributes(vObject, svg as SvgVoAutoScaledText);
         return(vObject);
     }
     else if (svg is SvgVoPathBoundedText)
     {
         var vObject = new PathBoundedTextVObject();
         ReadPathBoundedTextAttributes(vObject, svg as SvgVoPathBoundedText);
         return(vObject);
     }
     else if (svg is SvgVoBoundedText)
     {
         var vObject = new BoundedTextVObject();
         ReadBoundedTextAttributes(vObject, svg as SvgVoBoundedText);
         return(vObject);
     }
     else if (svg is SvgVoPlaceholder)
     {
         var vObject = new PlaceholderVObject();
         ReadPlaceholderAttributes(vObject, (SvgVoPlaceholder)svg);
         return(vObject);
     }
     else if (svg is SvgVoRectangle)
     {
         var vObject = new RectangleVObject();
         ReadRectangleAttributes(vObject, (SvgVoRectangle)svg);
         return(vObject);
     }
     else if (svg is SvgVoShape)
     {
         var vObject = new ShapeVObject();
         ReadShapeAttributes(vObject, (SvgVoShape)svg);
         return(vObject);
     }
     else
     {
         return(null);
     }
 }