Commit 9d37b566 authored by Tebjan Halm's avatar Tebjan Halm
Browse files

* added preserverAspectRatio attribute

parent 23143bb7
......@@ -14,5 +14,6 @@ namespace Svg
/// Gets or sets the viewport of the element.
/// </summary>
SvgViewBox ViewBox { get; set; }
SvgAspectRatio AspectRatio { get; set; }
}
}
using System;
using System.ComponentModel;
namespace Svg
{
/// <summary>
/// Description of SvgAspectRatio.
/// </summary>
public class SvgAspectRatio
{
public SvgAspectRatio()
{
}
public SvgAspectRatio(SvgPreserveAspectRatio align)
: this(align, false)
{
}
public SvgAspectRatio(SvgPreserveAspectRatio align, bool slice)
{
this.Align = align;
this.Slice = slice;
}
public SvgPreserveAspectRatio Align
{
get;
set;
}
public bool Slice
{
get;
set;
}
public override string ToString()
{
return TypeDescriptor.GetConverter(typeof(SvgPreserveAspectRatio)).ConvertToString(this.Align) + (Slice ? " slice" : "");
}
}
[TypeConverter(typeof(SvgPreserverAspectRatioConverter))]
public enum SvgPreserveAspectRatio
{
XMidYMid, //default
None,
XMinYMin,
XMidYMin,
XMaxYMin,
XMinYMid,
XMaxYMid,
XMinYMax,
XMidYMax,
XMaxYMax
}
}
......@@ -17,6 +17,7 @@ namespace Svg
private SvgUnit _width;
private SvgUnit _height;
private SvgViewBox _viewBox;
private SvgAspectRatio _aspect;
/// <summary>
/// Gets the SVG namespace string.
......@@ -55,6 +56,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 { return this._aspect; }
set { this._aspect = value; }
}
/// <summary>
/// Applies the required transforms to <see cref="SvgRenderer"/>.
......@@ -109,6 +121,7 @@ namespace Svg
this._height = new SvgUnit(SvgUnitType.Percentage, 100.0f);
this._width = new SvgUnit(SvgUnitType.Percentage, 100.0f);
this.ViewBox = SvgViewBox.Empty;
this.AspectRatio = new SvgAspectRatio(SvgPreserveAspectRatio.None);
}
}
}
\ No newline at end of file
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