This commit is contained in:
79
PROMS/Volian.Svg.Library/SvgViewBox.cs
Normal file
79
PROMS/Volian.Svg.Library/SvgViewBox.cs
Normal file
@@ -0,0 +1,79 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using System.Drawing;
|
||||
using System.ComponentModel;
|
||||
|
||||
namespace Volian.Svg.Library
|
||||
{
|
||||
[TypeConverter(typeof(ViewBoxTypeConverter))]
|
||||
public class SvgViewBox
|
||||
{
|
||||
#region ctor
|
||||
public SvgViewBox() { ;}
|
||||
public SvgViewBox(float x, float y, float width, float height)
|
||||
{
|
||||
_MyRectangleF = new RectangleF(x, y, width, height);
|
||||
}
|
||||
public SvgViewBox(string val)
|
||||
{
|
||||
string[] parms = ((string)val).Split(' ');
|
||||
_MyRectangleF = new RectangleF(Convert.ToSingle(parms[0]), Convert.ToSingle(parms[1]), Convert.ToSingle(parms[2]), Convert.ToSingle(parms[3]));
|
||||
}
|
||||
#endregion
|
||||
#region Public Properties
|
||||
private RectangleF _MyRectangleF = new RectangleF();
|
||||
public float X
|
||||
{
|
||||
get { return _MyRectangleF.X; }
|
||||
set { _MyRectangleF.X = value; }
|
||||
}
|
||||
public float Y
|
||||
{
|
||||
get { return _MyRectangleF.Y; }
|
||||
set { _MyRectangleF.Y = value; }
|
||||
}
|
||||
public float Width
|
||||
{
|
||||
get { return _MyRectangleF.Width; }
|
||||
set { _MyRectangleF.Width = value; }
|
||||
}
|
||||
public float Height
|
||||
{
|
||||
get { return _MyRectangleF.Height; }
|
||||
set { _MyRectangleF.Height = value; }
|
||||
}
|
||||
#endregion
|
||||
#region ToString
|
||||
public override string ToString()
|
||||
{
|
||||
return string.Format("{0} {1} {2} {3}", X, Y, Width, Height);
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
public class ViewBoxTypeConverter : ExpandableObjectConverter
|
||||
{
|
||||
public override bool CanConvertTo(ITypeDescriptorContext context, Type t)
|
||||
{
|
||||
return t == typeof(String);
|
||||
}
|
||||
public override object ConvertTo(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, Type destType)
|
||||
{
|
||||
if (destType == typeof(string) && value is SvgViewBox)
|
||||
{
|
||||
return value.ToString();
|
||||
}
|
||||
return base.ConvertTo(context, culture, value, destType);
|
||||
}
|
||||
public override bool CanConvertFrom(ITypeDescriptorContext context, Type t)
|
||||
{
|
||||
return t == typeof(String);
|
||||
}
|
||||
public override object ConvertFrom(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object val)
|
||||
{
|
||||
string[] parms = ((string)val).Split(' ');
|
||||
SvgViewBox viewBox = new SvgViewBox(Convert.ToSingle(parms[0]), Convert.ToSingle(parms[1]), Convert.ToSingle(parms[2]), Convert.ToSingle(parms[3]));
|
||||
return viewBox;
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user