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

* path tag writing works now

* added few enum converters
parent a8ae07cc
......@@ -95,5 +95,16 @@ namespace Svg
//implementaton for clip rule
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>
{
}
}
......@@ -31,6 +31,17 @@ namespace Svg
get { return this._viewBox; }
set { this._viewBox = value; }
}
/// <summary>
/// Gets or sets the aspect of the viewport.
/// </summary>
/// <value></value>
[SvgAttribute("preserveAspectRatio")]
public SvgAspectRatio AspectRatio
{
get;
set;
}
/// <summary>
/// Gets or sets the width of the pattern.
......
......@@ -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]
......
......@@ -10,5 +10,11 @@ namespace Svg.Pathing
{
graphicsPath.CloseFigure();
}
public override string ToString()
{
return "z";
}
}
}
......@@ -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();
}
}
}
......@@ -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
......@@ -17,5 +17,11 @@ namespace Svg.Pathing
{
graphicsPath.StartFigure();
}
public override string ToString()
{
return "M" + this.Start.ToSvgString();
}
}
}
......@@ -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
{
/// <summary>
......@@ -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
......@@ -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();
}
}
}
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