зеркало из https://github.com/wieslawsoltes/SVG.git
made svg transform collection a proper ICloneable
This commit is contained in:
Родитель
cecce65479
Коммит
4d631e7f1a
|
@ -676,9 +676,7 @@ namespace Svg
|
|||
|
||||
if (this.Transforms != null)
|
||||
{
|
||||
newObj.Transforms = new SvgTransformCollection();
|
||||
foreach (var transform in this.Transforms)
|
||||
newObj.Transforms.Add(transform.Clone() as SvgTransform);
|
||||
newObj.Transforms = this.Transforms.Clone() as SvgTransformCollection;
|
||||
}
|
||||
|
||||
foreach (var child in this.Children)
|
||||
|
|
|
@ -8,12 +8,16 @@ using System.Text;
|
|||
namespace Svg.Transforms
|
||||
{
|
||||
[TypeConverter(typeof(SvgTransformConverter))]
|
||||
public class SvgTransformCollection : List<SvgTransform>
|
||||
public class SvgTransformCollection : List<SvgTransform>, ICloneable
|
||||
{
|
||||
|
||||
public new void Add(SvgTransform item)
|
||||
private void AddItem(SvgTransform item)
|
||||
{
|
||||
base.Add(item);
|
||||
}
|
||||
|
||||
public new void Add(SvgTransform item)
|
||||
{
|
||||
AddItem(item);
|
||||
OnTransformChanged();
|
||||
}
|
||||
|
||||
|
@ -91,9 +95,19 @@ namespace Svg.Transforms
|
|||
var handler = TransformChanged;
|
||||
if(handler != null)
|
||||
{
|
||||
handler(this, new AttributeEventArgs { Attribute = "transform", Value = this });
|
||||
//make a copy of the current value to avoid collection changed exceptions
|
||||
handler(this, new AttributeEventArgs { Attribute = "transform", Value = this.Clone() });
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public object Clone()
|
||||
{
|
||||
var result = new SvgTransformCollection();
|
||||
foreach (var trans in this)
|
||||
{
|
||||
result.AddItem(trans.Clone() as SvgTransform);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче