This commit is contained in:
Tebjan Halm 2013-07-31 05:45:31 +02:00
Родитель 28b654f015
Коммит ca782d2f9e
6 изменённых файлов: 101 добавлений и 9 удалений

Просмотреть файл

@ -50,6 +50,7 @@ namespace Svg
set
{
_x = value;
OnAttributeChanged(new AttributeEventArgs{ Attribute = "x", Value = value });
IsPathDirty = true;
}
}
@ -64,6 +65,7 @@ namespace Svg
set
{
_y = value;
OnAttributeChanged(new AttributeEventArgs{ Attribute = "y", Value = value });
IsPathDirty = true;
}
}
@ -78,6 +80,7 @@ namespace Svg
set
{
_width = value;
OnAttributeChanged(new AttributeEventArgs{ Attribute = "width", Value = value });
IsPathDirty = true;
}
}
@ -92,6 +95,7 @@ namespace Svg
set
{
_height = value;
OnAttributeChanged(new AttributeEventArgs{ Attribute = "height", Value = value });
IsPathDirty = true;
}
}

Просмотреть файл

@ -94,6 +94,7 @@ namespace Svg
internal void OnPathUpdated()
{
this.IsPathDirty = true;
OnAttributeChanged(new AttributeEventArgs{ Attribute = "d", Value = this.PathData });
}
/// <summary>

Просмотреть файл

@ -30,6 +30,7 @@ namespace Svg
public SvgAttributeAttribute Attribute;
}
//reflection cache
protected IEnumerable<PropertyAttributeTuple> _svgPropertyAttributes;
protected IEnumerable<EventAttributeTuple> _svgEventAttributes;
@ -68,10 +69,28 @@ namespace Svg
/// <summary>
/// Gets or sets the content of the element.
/// </summary>
private string _content;
public virtual string Content
{
get;
set;
get
{
return _content;
}
set
{
if(_content != null)
{
var oldVal = _content;
_content = value;
if(_content != oldVal)
OnAttributeChanged(new AttributeEventArgs{ Attribute = "", Value = value });
}
else
{
_content = value;
OnAttributeChanged(new AttributeEventArgs{ Attribute = "", Value = value });
}
}
}
/// <summary>
@ -220,8 +239,15 @@ namespace Svg
[SvgAttribute("transform")]
public SvgTransformCollection Transforms
{
get { return (this.Attributes.GetAttribute<SvgTransformCollection>("Transforms") ?? new SvgTransformCollection()); }
set { this.Attributes["Transforms"] = value; }
get { return (this.Attributes.GetAttribute<SvgTransformCollection>("Transforms")); }
set
{
var old = this.Transforms;
if(old != null)
old.TransformChanged -= Attributes_AttributeChanged;
value.TransformChanged += Attributes_AttributeChanged;
this.Attributes["Transforms"] = value;
}
}
/// <summary>
@ -302,6 +328,8 @@ namespace Svg
this._elementName = string.Empty;
this._customAttributes = new SvgCustomAttributeCollection(this);
Transforms = new SvgTransformCollection();
//subscribe to attribute events
Attributes.AttributeChanged += Attributes_AttributeChanged;
CustomAttributes.AttributeChanged += Attributes_AttributeChanged;

Просмотреть файл

@ -83,7 +83,12 @@ namespace Svg
public virtual SvgUnit X
{
get { return this._x; }
set { this._x = value; this.IsPathDirty = true; }
set
{
this._x = value;
this.IsPathDirty = true;
OnAttributeChanged(new AttributeEventArgs{ Attribute = "x", Value = value });
}
}
/// <summary>
@ -94,7 +99,12 @@ namespace Svg
public virtual SvgUnit Y
{
get { return this._y; }
set { this._y = value; this.IsPathDirty = true; }
set
{
this._y = value;
this.IsPathDirty = true;
OnAttributeChanged(new AttributeEventArgs{ Attribute = "y", Value = value });
}
}
/// <summary>

Просмотреть файл

@ -46,7 +46,6 @@ namespace Svg.Transforms
this.scaleFactorY = y;
}
public override object Clone()
{
return new SvgScale(this.X, this.Y);

Просмотреть файл

@ -10,6 +10,31 @@ namespace Svg.Transforms
[TypeConverter(typeof(SvgTransformConverter))]
public class SvgTransformCollection : List<SvgTransform>
{
public new void Add(SvgTransform item)
{
base.Add(item);
OnTransformChanged();
}
public new void AddRange(IEnumerable<SvgTransform> collection)
{
base.AddRange(collection);
OnTransformChanged();
}
public new void Remove(SvgTransform item)
{
base.Remove(item);
OnTransformChanged();
}
public new void RemoveAt(int index)
{
base.RemoveAt(index);
OnTransformChanged();
}
/// <summary>
/// Multiplies all matrices
/// </summary>
@ -32,13 +57,38 @@ namespace Svg.Transforms
return transformMatrix;
}
public override bool Equals(object obj)
{
if (this.Count == 0 && this.Count == this.Count) //default will be an empty list
if (this.Count == 0 && this.Count == base.Count) //default will be an empty list
return true;
return base.Equals(obj);
}
public new SvgTransform this[int i]
{
get { return base[i]; }
set
{
var oldVal = base[i];
base[i] = value;
if(oldVal != value)
OnTransformChanged();
}
}
/// <summary>
/// Fired when an SvgTransform has changed
/// </summary>
public event EventHandler<AttributeEventArgs> TransformChanged;
protected void OnTransformChanged()
{
var handler = TransformChanged;
if(handler != null)
{
handler(this, new AttributeEventArgs { Attribute = "transform", Value = this });
}
}
}
}