Commit d773cc48 authored by tebjan's avatar tebjan
Browse files

added insertbefore sibling to child added event

parent b667a15a
...@@ -316,10 +316,15 @@ namespace Svg ...@@ -316,10 +316,15 @@ namespace Svg
internal void OnElementAdded(SvgElement child, int index) internal void OnElementAdded(SvgElement child, int index)
{ {
this.AddElement(child, index); this.AddElement(child, index);
SvgElement sibling = null;
if(index < (Children.Count - 1))
{
sibling = Children[index + 1];
}
var handler = ChildAdded; var handler = ChildAdded;
if(handler != null) if(handler != null)
{ {
handler(this, new ChildAddedEventArgs { NewChild = child }); handler(this, new ChildAddedEventArgs { NewChild = child, BeforeSibling = sibling });
} }
} }
...@@ -980,6 +985,7 @@ namespace Svg ...@@ -980,6 +985,7 @@ namespace Svg
public class ChildAddedEventArgs : SVGArg public class ChildAddedEventArgs : SVGArg
{ {
public SvgElement NewChild; public SvgElement NewChild;
public SvgElement BeforeSibling;
} }
//deriving class registers event actions and calls the actions if the event occurs //deriving class registers event actions and calls the actions if the event occurs
......
...@@ -53,10 +53,10 @@ namespace Svg ...@@ -53,10 +53,10 @@ namespace Svg
/// <param name="item">The <see cref="SvgElement"/> to be added.</param> /// <param name="item">The <see cref="SvgElement"/> to be added.</param>
public void Insert(int index, SvgElement item) public void Insert(int index, SvgElement item)
{ {
InsertAddAndFixID(index, item, false, false); InsertAndFixID(index, item, false, false);
} }
public void InsertAddAndFixID(int index, SvgElement item, bool autoFixID = true, bool autoFixChildrenID = true, Action<SvgElement, string, string> logElementOldIDNewID = null) public void InsertAndFixID(int index, SvgElement item, bool autoFixID = true, bool autoFixChildrenID = true, Action<SvgElement, string, string> logElementOldIDNewID = null)
{ {
AddToIdManager(item, this._elements[index], autoFixID, autoFixChildrenID, logElementOldIDNewID); AddToIdManager(item, this._elements[index], autoFixID, autoFixChildrenID, logElementOldIDNewID);
this._elements.Insert(index, item); this._elements.Insert(index, item);
......
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