Commit 765f8f22 authored by Tebjan Halm's avatar Tebjan Halm
Browse files

Merge pull request #79 from erdomke/master

.Net 3.5 Support and Rendering Improvements (Markers, TSpans, Paths, etc.) + Working Build!
parents c79fac1e 2261cfdb
......@@ -4,90 +4,94 @@ using System.ComponentModel;
using System.Globalization;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Svg.DataTypes
{
//implementaton for preserve aspect ratio
public sealed class SvgPreserveAspectRatioConverter : TypeConverter
{
public override object ConvertFrom(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value)
{
if (value == null)
{
return new SvgAspectRatio();
}
//implementaton for preserve aspect ratio
public sealed class SvgPreserveAspectRatioConverter : TypeConverter
{
public override object ConvertFrom(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value)
{
if (value == null)
{
return new SvgAspectRatio();
}
if (!(value is string))
{
throw new ArgumentOutOfRangeException("value must be a string.");
}
if (!(value is string))
{
throw new ArgumentOutOfRangeException("value must be a string.");
}
SvgPreserveAspectRatio eAlign = SvgPreserveAspectRatio.none;
bool bDefer = false;
bool bSlice = false;
SvgPreserveAspectRatio eAlign = SvgPreserveAspectRatio.none;
bool bDefer = false;
bool bSlice = false;
string[] sParts = (value as string).Split(new char[] {' '}, StringSplitOptions.RemoveEmptyEntries);
int nAlignIndex = 0;
if (sParts[0].Equals("defer"))
{
bDefer = true;
nAlignIndex++;
if(sParts.Length < 2)
throw new ArgumentOutOfRangeException("value is not a member of SvgPreserveAspectRatio");
}
string[] sParts = (value as string).Split(new char[] {' '}, StringSplitOptions.RemoveEmptyEntries);
int nAlignIndex = 0;
if (sParts[0].Equals("defer"))
{
bDefer = true;
nAlignIndex++;
if(sParts.Length < 2)
throw new ArgumentOutOfRangeException("value is not a member of SvgPreserveAspectRatio");
}
if (!Enum.TryParse<SvgPreserveAspectRatio>(sParts[nAlignIndex], out eAlign))
throw new ArgumentOutOfRangeException("value is not a member of SvgPreserveAspectRatio");
nAlignIndex++;
#if Net4
if (!Enum.TryParse<SvgPreserveAspectRatio>(sParts[nAlignIndex], out eAlign))
throw new ArgumentOutOfRangeException("value is not a member of SvgPreserveAspectRatio");
#else
eAlign = (SvgPreserveAspectRatio)Enum.Parse(typeof(SvgPreserveAspectRatio), sParts[nAlignIndex]);
#endif
if (sParts.Length > nAlignIndex)
{
switch (sParts[nAlignIndex])
{
case "meet":
break;
case "slice":
bSlice = true;
break;
default:
throw new ArgumentOutOfRangeException("value is not a member of SvgPreserveAspectRatio");
}
}
nAlignIndex++;
if(sParts.Length > nAlignIndex)
throw new ArgumentOutOfRangeException("value is not a member of SvgPreserveAspectRatio");
nAlignIndex++;
SvgAspectRatio pRet = new SvgAspectRatio(eAlign);
pRet.Slice = bSlice;
pRet.Defer = bDefer;
return (pRet);
}
if (sParts.Length > nAlignIndex)
{
switch (sParts[nAlignIndex])
{
case "meet":
break;
case "slice":
bSlice = true;
break;
default:
throw new ArgumentOutOfRangeException("value is not a member of SvgPreserveAspectRatio");
}
}
nAlignIndex++;
if(sParts.Length > nAlignIndex)
throw new ArgumentOutOfRangeException("value is not a member of SvgPreserveAspectRatio");
public override bool CanConvertFrom(ITypeDescriptorContext context, Type sourceType)
{
if (sourceType == typeof(string))
{
return true;
}
SvgAspectRatio pRet = new SvgAspectRatio(eAlign);
pRet.Slice = bSlice;
pRet.Defer = bDefer;
return (pRet);
}
return base.CanConvertFrom(context, sourceType);
}
public override bool CanConvertFrom(ITypeDescriptorContext context, Type sourceType)
{
if (sourceType == typeof(string))
{
return true;
}
public override bool CanConvertTo(ITypeDescriptorContext context, Type destinationType)
{
if (destinationType == typeof(string))
{
return true;
}
return base.CanConvertFrom(context, sourceType);
}
return base.CanConvertTo(context, destinationType);
}
public override bool CanConvertTo(ITypeDescriptorContext context, Type destinationType)
{
if (destinationType == typeof(string))
{
return true;
}
public override object ConvertTo(ITypeDescriptorContext context, CultureInfo culture, object value, Type destinationType)
{
return base.ConvertTo(context, culture, value, destinationType);
}
}
return base.CanConvertTo(context, destinationType);
}
public override object ConvertTo(ITypeDescriptorContext context, CultureInfo culture, object value, Type destinationType)
{
return base.ConvertTo(context, culture, value, destinationType);
}
}
}
using Svg.DataTypes;
using System.ComponentModel;
using System;
namespace Svg
{
......
......@@ -77,13 +77,6 @@ namespace Svg
set { this.Attributes["markerHeight"] = value; }
}
[SvgAttribute("markerUnits")]
public virtual SvgMarkerUnits MarkerUnits
{
get { return this.Attributes.GetAttribute<SvgMarkerUnits>("markerUnits"); }
set { this.Attributes["markerUnits"] = value; }
}
public SvgMarker()
{
MarkerUnits = SvgMarkerUnits.strokeWidth;
......
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