Commit 29a3026e authored by Tebjan Halm's avatar Tebjan Halm
Browse files

implemented insert for SvgElementCollection

parent 2bfed054
Showing with 26 additions and 16 deletions
+26 -16
......@@ -53,7 +53,14 @@ namespace Svg
/// <param name="item">The <see cref="SvgElement"/> to be added.</param>
public void Insert(int index, SvgElement item)
{
InsertAddAndFixID(index, item, false, false);
}
public void InsertAddAndFixID(int index, SvgElement item, bool autoFixID = true, bool autoFixChildrenID = true, Action<SvgElement, string, string> logElementOldIDNewID = null)
{
AddToIdManager(item, autoFixID, autoFixChildrenID, logElementOldIDNewID);
this._elements.Insert(index, item);
item._parent.OnElementAdded(item, index);
}
public void RemoveAt(int index)
......@@ -78,6 +85,13 @@ namespace Svg
}
public void AddAndFixID(SvgElement item, bool autoFixID = true, bool autoFixChildrenID = true, Action<SvgElement, string, string> logElementOldIDNewID = null)
{
AddToIdManager(item, autoFixID, autoFixChildrenID, logElementOldIDNewID);
this._elements.Add(item);
item._parent.OnElementAdded(item, this.Count - 1);
}
private void AddToIdManager(SvgElement item, bool autoFixID = true, bool autoFixChildrenID = true, Action<SvgElement, string, string> logElementOldIDNewID = null)
{
if (!this._mock)
{
......@@ -85,7 +99,7 @@ namespace Svg
{
this._owner.OwnerDocument.IdManager.AddAndFixID(item, autoFixID, logElementOldIDNewID);
if(!(item is SvgDocument)) //don't add subtree of a document to parent document
if (!(item is SvgDocument)) //don't add subtree of a document to parent document
{
foreach (var child in item.Children)
{
......@@ -96,10 +110,6 @@ namespace Svg
item._parent = this._owner;
}
item._parent.OnElementAdded(item, this.Count - 1);
this._elements.Add(item);
}
public void Clear()
......
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