Example #1
0
        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);
        }
        protected internal override void Transform_TransformChanged(object sender, EventArgs e)
        {
            base.Transform_TransformChanged(sender, e);

            // Apply transform to BaselineLocation and clear
            var transform = Transform.Clone();

            transform.Update(angle: Transform.Angle - ActualAngle);

            if (transform.IsEmpty)
            {
                return;
            }

            if (!ValidRect)
            {
                // Update size using actual transform
                var tmpTransform = Transform.Clone();
                Transform.Update(1, 1, 0, 0, ActualAngle);
                UpdateSize();
                Transform.Copy(tmpTransform);
            }

            _baselineLocation = new PointF(BaselineLocation).Transform(transform, ControlCenter).ToPointF();
            Transform.Clear(keepAngle: true);
            ActualAngle = Transform.Angle;
            ValidRect   = false;
        }
Example #3
0
            public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer)
            {
                if (reader.TokenType == JsonToken.Null)
                {
                    return(new PointF());
                }

                var point = new PointF();

                foreach (var property in (JObject)serializer.Deserialize(reader))
                {
                    switch (property.Key)
                    {
                    case "X":
                        point.X = property.Value.Value <float>();
                        break;

                    case "Y":
                        point.Y = property.Value.Value <float>();
                        break;
                    }
                }

                return(point);
            }
Example #4
0
        public SvgVObject(PointF location = null, SizeF?size = null)
        {
            IncludeBorder = true;
            BorderWidth   = 0F;
            FillColor     = RgbColor.Transparent;

            _strokeColor = RgbColor.Black;

            if (location != null)
            {
                ChangeControlPoints(location.X, location.Y);
            }

            if (size != null)
            {
                ChangeControlPoints(null, null, ControlPoints[0].X + size.Value.Width, ControlPoints[0].Y + size.Value.Height);
            }
        }
 public PlainTextVObject(string text, PointF baselineLocation, TextAlignment alignment, string postScriptFontName, float fontSize)
     : this(text, baselineLocation.ToPointF(), alignment, postScriptFontName, fontSize)
 {
 }
Example #6
0
 public void RotateAt(double angle, PointF center)
 {
     Center = Center.RotateAt(angle, center);
     Angle  = (float)angle;
 }
Example #7
0
 public SvgVObject(FileInfo file, PointF location = null, SizeF?size = null)
     : this(location)
 {
     LoadSvg(file, size);
 }
Example #8
0
 public SvgVObject(string xml, PointF location = null, SizeF?size = null)
     : this(location)
 {
     LoadSvg(xml, size);
 }
Example #9
0
 public SvgVObject(XmlDocument doc, PointF location = null, SizeF?size = null)
     : this(location)
 {
     LoadSvg(doc, size);
 }