protected override IVObject CreateObject() { EllipseVObject result = null; System.Drawing.RectangleF rectangle = GetWorkspaceRectangle(); if (rectangle.Width > 1 && rectangle.Height > 1) { result = new EllipseVObject(rectangle); if (base.Brush != null) { result.Brush = (System.Drawing.Brush)base.Brush.Clone(); } else { result.Brush = null; } if (base.Pen != null) { result.Pen = (System.Drawing.Pen)base.Pen.Clone(); } else { result.Pen = null; } } return(result); }
private void WriteEllipseAttributes(SvgEllipse svg, EllipseVObject vObject) { WriteBaseRectangleVObjectAttributes(svg, vObject); var rect = vObject.Rectangle; svg.Cx = rect.CenterX; svg.Cy = rect.CenterY; svg.Rx = rect.Width / 2; svg.Ry = rect.Height / 2; var m = new Matrix(); m.RotateAt(rect.Angle, new System.Drawing.PointF(rect.CenterX, rect.CenterY)); svg.Transform = m; svg.StrokeWidth = vObject.BorderWidth; var cm = vObject.GetColorManagement(true); svg.Stroke = ColorManagement.GetPreviewColor(cm, vObject.BorderColor); svg.CustomAttributes.Add(new SvgVoAttribute("border-color", _serializer.Serialize(vObject.BorderColor))); svg.Fill = ColorManagement.GetPreviewColor(cm, vObject.FillColor); svg.CustomAttributes.Add(new SvgVoAttribute("fill-color", _serializer.Serialize(vObject.FillColor))); if (vObject.FixedBorderWidth) { svg.CustomAttributes.Add(new SvgVoAttribute("fixed-border-width", vObject.FixedBorderWidth)); } }
private void ReadEllipseAttributes(EllipseVObject vObject, SvgEllipse svg) { ReadBaseRectangleVObjectAttributes(vObject, svg); using (var advPath = new AdvancedDrawing.Path()) { advPath.DrawEllipse(svg.Cx - svg.Rx, svg.Cy - svg.Ry, svg.Rx * 2, svg.Ry * 2); vObject.Path = Path.FromAdvancedPath(advPath); } vObject.Angle = svg.Transform != null?Utils.GetAngle(svg.Transform.Elements[0], svg.Transform.Elements[1]) : 0; vObject.BorderWidth = svg.StrokeWidth; string borderColor = null; string fillColor = null; foreach (var attr in svg.CustomAttributes) { if (attr.NamespaceUri == XmlNamespace.AurigmaVectorObjects && attr.LocalName == "fixed-border-width") { vObject.FixedBorderWidth = attr.GetValue() == "true"; } else if (attr.NamespaceUri == XmlNamespace.AurigmaVectorObjects && attr.LocalName == "border-color") { borderColor = attr.GetValue(); } else if (attr.NamespaceUri == XmlNamespace.AurigmaVectorObjects && attr.LocalName == "fill-color") { fillColor = attr.GetValue(); } } vObject.BorderColor = !string.IsNullOrEmpty(borderColor) ? _serializer.Deserialize <Color>(borderColor) : new RgbColor(svg.Stroke); vObject.FillColor = !string.IsNullOrEmpty(fillColor) ? _serializer.Deserialize <Color>(fillColor) : new RgbColor(svg.Fill); }
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); } }