Commit bc1d94f4 authored by Tebjan Halm's avatar Tebjan Halm
Browse files

* path tag writing works now

* added few enum converters
parent a8ae07cc
...@@ -96,4 +96,15 @@ namespace Svg ...@@ -96,4 +96,15 @@ namespace Svg
public sealed class SvgClipRuleConverter : EnumBaseConverter<SvgClipRule> public sealed class SvgClipRuleConverter : EnumBaseConverter<SvgClipRule>
{ {
} }
//implementaton for clip rule
public sealed class SvgTextAnchorConverter : EnumBaseConverter<SvgTextAnchor>
{
}
//implementaton for preserve aspect ratio
public sealed class SvgPreserverAspectRatioConverter : EnumBaseConverter<SvgPreserveAspectRatio>
{
}
} }
...@@ -32,6 +32,17 @@ namespace Svg ...@@ -32,6 +32,17 @@ namespace Svg
set { this._viewBox = value; } set { this._viewBox = value; }
} }
/// <summary>
/// Gets or sets the aspect of the viewport.
/// </summary>
/// <value></value>
[SvgAttribute("preserveAspectRatio")]
public SvgAspectRatio AspectRatio
{
get;
set;
}
/// <summary> /// <summary>
/// Gets or sets the width of the pattern. /// Gets or sets the width of the pattern.
/// </summary> /// </summary>
......
...@@ -152,6 +152,13 @@ namespace Svg.Pathing ...@@ -152,6 +152,13 @@ namespace Svg.Pathing
startY = (float)endpointY; 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] [Flags]
......
...@@ -10,5 +10,11 @@ namespace Svg.Pathing ...@@ -10,5 +10,11 @@ namespace Svg.Pathing
{ {
graphicsPath.CloseFigure(); graphicsPath.CloseFigure();
} }
public override string ToString()
{
return "z";
}
} }
} }
...@@ -37,7 +37,7 @@ namespace Svg.Pathing ...@@ -37,7 +37,7 @@ namespace Svg.Pathing
public override string ToString() 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();
} }
} }
} }
...@@ -17,5 +17,11 @@ namespace Svg.Pathing ...@@ -17,5 +17,11 @@ namespace Svg.Pathing
{ {
graphicsPath.AddLine(this.Start, this.End); graphicsPath.AddLine(this.Start, this.End);
} }
public override string ToString()
{
return "L" + this.End.ToSvgString();
}
} }
} }
\ No newline at end of file
...@@ -17,5 +17,11 @@ namespace Svg.Pathing ...@@ -17,5 +17,11 @@ namespace Svg.Pathing
{ {
graphicsPath.StartFigure(); graphicsPath.StartFigure();
} }
public override string ToString()
{
return "M" + this.Start.ToSvgString();
}
} }
} }
...@@ -4,11 +4,19 @@ using System.ComponentModel; ...@@ -4,11 +4,19 @@ using System.ComponentModel;
using System.Diagnostics; using System.Diagnostics;
using System.Drawing; using System.Drawing;
using System.Globalization; using System.Globalization;
using System.Linq;
using Svg.Pathing; using Svg.Pathing;
namespace Svg namespace Svg
{ {
public static class PointFExtensions
{
public static string ToSvgString(this PointF p)
{
return p.X.ToString() + " " + p.Y.ToString();
}
}
internal class SvgPathBuilder : TypeConverter internal class SvgPathBuilder : TypeConverter
{ {
/// <summary> /// <summary>
...@@ -256,6 +264,31 @@ namespace Svg ...@@ -256,6 +264,31 @@ namespace Svg
} }
return base.ConvertFrom(context, culture, value); 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
...@@ -48,5 +48,11 @@ namespace Svg.Pathing ...@@ -48,5 +48,11 @@ namespace Svg.Pathing
{ {
graphicsPath.AddBezier(this.Start, this.FirstControlPoint, this.SecondControlPoint, this.End); graphicsPath.AddBezier(this.Start, this.FirstControlPoint, this.SecondControlPoint, this.End);
} }
public override string ToString()
{
return "Q" + this.ControlPoint.ToSvgString() + " " + this.End.ToSvgString();
}
} }
} }
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment