diff --git a/Source/Painting/EnumConverters.cs b/Source/Painting/EnumConverters.cs index 6dfc1b059e2db38c6307590ed3546e06c903133b..3e4ab87f6f8c7852d43c94ad7680faadc424dc46 100644 --- a/Source/Painting/EnumConverters.cs +++ b/Source/Painting/EnumConverters.cs @@ -95,5 +95,16 @@ namespace Svg //implementaton for clip rule public sealed class SvgClipRuleConverter : EnumBaseConverter { - } + } + + //implementaton for clip rule + public sealed class SvgTextAnchorConverter : EnumBaseConverter + { + } + + //implementaton for preserve aspect ratio + public sealed class SvgPreserverAspectRatioConverter : EnumBaseConverter + { + } + } diff --git a/Source/Painting/SvgPatternServer.cs b/Source/Painting/SvgPatternServer.cs index 95764e86d702671d8e4522c40295191895d95537..1bd345400d0e922bab14cac53482486a4d78b90d 100644 --- a/Source/Painting/SvgPatternServer.cs +++ b/Source/Painting/SvgPatternServer.cs @@ -31,6 +31,17 @@ namespace Svg get { return this._viewBox; } set { this._viewBox = value; } } + + /// + /// Gets or sets the aspect of the viewport. + /// + /// + [SvgAttribute("preserveAspectRatio")] + public SvgAspectRatio AspectRatio + { + get; + set; + } /// /// Gets or sets the width of the pattern. diff --git a/Source/Paths/SvgArcSegment.cs b/Source/Paths/SvgArcSegment.cs index 011d3e7cb7ebed3cea4081cb791dec31f59f1d76..f0e2488c5c7c05d33cdf4ae4c48ed3a669838595 100644 --- a/Source/Paths/SvgArcSegment.cs +++ b/Source/Paths/SvgArcSegment.cs @@ -152,6 +152,13 @@ namespace Svg.Pathing startY = (float)endpointY; } } + + public override string ToString() + { + var arcFlag = this.Size == SvgArcSize.Large ? "1" : "0"; + var sweepFlag = this.Sweep == SvgArcSweep.Positive ? "1" : "0"; + return "A" + this.RadiusX.ToString() + " " + this.RadiusY.ToString() + " " + this.Angle.ToString() + " " + arcFlag + " " + sweepFlag + " " + this.End.ToSvgString(); + } } [Flags] diff --git a/Source/Paths/SvgClosePathSegment.cs b/Source/Paths/SvgClosePathSegment.cs index 43b567b124cb698dbe647e3140826e84356e57bc..3f028d041d6c25f8940d857d2dc60d0ab323f0df 100644 --- a/Source/Paths/SvgClosePathSegment.cs +++ b/Source/Paths/SvgClosePathSegment.cs @@ -10,5 +10,11 @@ namespace Svg.Pathing { graphicsPath.CloseFigure(); } + + public override string ToString() + { + return "z"; + } + } } diff --git a/Source/Paths/SvgCubicCurveSegment.cs b/Source/Paths/SvgCubicCurveSegment.cs index b9950a46aa048b506b9c58cee378155a19e9366c..b977949870b235c4d9404959a6fbf0bd235c1816 100644 --- a/Source/Paths/SvgCubicCurveSegment.cs +++ b/Source/Paths/SvgCubicCurveSegment.cs @@ -37,7 +37,7 @@ namespace Svg.Pathing public override string ToString() { - return String.Format("C {0} {1} {2}", this.FirstControlPoint, this.SecondControlPoint, this.End); + return "C" + this.FirstControlPoint.ToSvgString() + " " + this.SecondControlPoint.ToSvgString() + " " + this.End.ToSvgString(); } } } diff --git a/Source/Paths/SvgLineSegment.cs b/Source/Paths/SvgLineSegment.cs index 9a04fdb3c2a10e6839072ecc99092b57937cd570..61ed7083cb96b194feb5466a098bcb915f9d1937 100644 --- a/Source/Paths/SvgLineSegment.cs +++ b/Source/Paths/SvgLineSegment.cs @@ -17,5 +17,11 @@ namespace Svg.Pathing { graphicsPath.AddLine(this.Start, this.End); } + + public override string ToString() + { + return "L" + this.End.ToSvgString(); + } + } } \ No newline at end of file diff --git a/Source/Paths/SvgMoveToSegment.cs b/Source/Paths/SvgMoveToSegment.cs index 6d44fc55a222e887f50b997fcb0621bb86806465..e9e1e3ceca528ec9ce70d7ebd29186323f9b30c0 100644 --- a/Source/Paths/SvgMoveToSegment.cs +++ b/Source/Paths/SvgMoveToSegment.cs @@ -17,5 +17,11 @@ namespace Svg.Pathing { graphicsPath.StartFigure(); } + + public override string ToString() + { + return "M" + this.Start.ToSvgString(); + } + } } diff --git a/Source/Paths/SvgPathBuilder.cs b/Source/Paths/SvgPathBuilder.cs index 1a0b46bd68da231a2e7d6030d1edf7fd0a782ff6..5e86d03f0607cc50406eb791ca5e76b9c15df093 100644 --- a/Source/Paths/SvgPathBuilder.cs +++ b/Source/Paths/SvgPathBuilder.cs @@ -4,11 +4,19 @@ using System.ComponentModel; using System.Diagnostics; using System.Drawing; using System.Globalization; - +using System.Linq; using Svg.Pathing; namespace Svg { + public static class PointFExtensions + { + public static string ToSvgString(this PointF p) + { + return p.X.ToString() + " " + p.Y.ToString(); + } + } + internal class SvgPathBuilder : TypeConverter { /// @@ -256,6 +264,31 @@ namespace Svg } return base.ConvertFrom(context, culture, value); + } + + public override object ConvertTo(ITypeDescriptorContext context, CultureInfo culture, object value, Type destinationType) + { + if (destinationType == typeof(string)) + { + var paths = value as SvgPathSegmentList; + + if (paths != null) + { + return string.Join(" ", paths.Select(p => p.ToString()).ToArray()); + } + } + + return base.ConvertTo(context, culture, value, destinationType); + } + + public override bool CanConvertTo(ITypeDescriptorContext context, Type destinationType) + { + if (destinationType == typeof(string)) + { + return true; + } + + return base.CanConvertTo(context, destinationType); } } } \ No newline at end of file diff --git a/Source/Paths/SvgQuadraticCurveSegment.cs b/Source/Paths/SvgQuadraticCurveSegment.cs index d7c88f5f6bc0ae3754fec56f9f1bad515dba33fd..4ed7f5bf2d71ded0b5fd58c089691ae131af6005 100644 --- a/Source/Paths/SvgQuadraticCurveSegment.cs +++ b/Source/Paths/SvgQuadraticCurveSegment.cs @@ -48,5 +48,11 @@ namespace Svg.Pathing { graphicsPath.AddBezier(this.Start, this.FirstControlPoint, this.SecondControlPoint, this.End); } + + public override string ToString() + { + return "Q" + this.ControlPoint.ToSvgString() + " " + this.End.ToSvgString(); + } + } }