Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
ImportedProjects
SVG
Commits
29a3026e
Commit
29a3026e
authored
Dec 05, 2013
by
Tebjan Halm
Browse files
implemented insert for SvgElementCollection
parent
2bfed054
Changes
1
Hide whitespace changes
Inline
Side-by-side
Source/SvgElementCollection.cs
View file @
29a3026e
...
...
@@ -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,28 +85,31 @@ 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
)
{
if
(
this
.
_owner
.
OwnerDocument
!=
null
)
{
this
.
_owner
.
OwnerDocument
.
IdManager
.
AddAndFixID
(
item
,
autoFixID
,
logElementOldIDNewID
);
if
(!(
item
is
SvgDocument
))
//don't add subtree of a document to parent document
{
foreach
(
var
child
in
item
.
Children
)
{
child
.
ApplyRecursive
(
e
=>
this
.
_owner
.
OwnerDocument
.
IdManager
.
AddAndFixID
(
e
,
autoFixChildrenID
,
logElementOldIDNewID
));
}
}
}
if
(
this
.
_owner
.
OwnerDocument
!=
null
)
{
this
.
_owner
.
OwnerDocument
.
IdManager
.
AddAndFixID
(
item
,
autoFixID
,
logElementOldIDNewID
);
if
(!(
item
is
SvgDocument
))
//don't add subtree of a document to parent document
{
foreach
(
var
child
in
item
.
Children
)
{
child
.
ApplyRecursive
(
e
=>
this
.
_owner
.
OwnerDocument
.
IdManager
.
AddAndFixID
(
e
,
autoFixChildrenID
,
logElementOldIDNewID
));
}
}
}
item
.
_parent
=
this
.
_owner
;
}
item
.
_parent
.
OnElementAdded
(
item
,
this
.
Count
-
1
);
this
.
_elements
.
Add
(
item
);
}
public
void
Clear
()
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment