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
cf8f77dc
Commit
cf8f77dc
authored
Dec 05, 2013
by
Tebjan Halm
Browse files
added correct insert method for IdManager and SvgElementCollection
parent
29a3026e
Changes
3
Hide whitespace changes
Inline
Side-by-side
Source/SvgElement.cs
View file @
cf8f77dc
...
...
@@ -280,7 +280,7 @@ namespace Svg
if
(
this
.
OwnerDocument
!=
null
)
{
this
.
OwnerDocument
.
IdManager
.
AddAndFixID
(
this
,
autoFixID
,
logElementOldIDNewID
);
this
.
OwnerDocument
.
IdManager
.
AddAndFixID
(
this
,
null
,
autoFixID
,
logElementOldIDNewID
);
}
}
...
...
Source/SvgElementCollection.cs
View file @
cf8f77dc
...
...
@@ -58,7 +58,7 @@ namespace Svg
public
void
InsertAddAndFixID
(
int
index
,
SvgElement
item
,
bool
autoFixID
=
true
,
bool
autoFixChildrenID
=
true
,
Action
<
SvgElement
,
string
,
string
>
logElementOldIDNewID
=
null
)
{
AddToIdManager
(
item
,
autoFixID
,
autoFixChildrenID
,
logElementOldIDNewID
);
AddToIdManager
(
item
,
this
.
_elements
[
index
],
autoFixID
,
autoFixChildrenID
,
logElementOldIDNewID
);
this
.
_elements
.
Insert
(
index
,
item
);
item
.
_parent
.
OnElementAdded
(
item
,
index
);
}
...
...
@@ -86,24 +86,24 @@ namespace Svg
public
void
AddAndFixID
(
SvgElement
item
,
bool
autoFixID
=
true
,
bool
autoFixChildrenID
=
true
,
Action
<
SvgElement
,
string
,
string
>
logElementOldIDNewID
=
null
)
{
AddToIdManager
(
item
,
autoFixID
,
autoFixChildrenID
,
logElementOldIDNewID
);
AddToIdManager
(
item
,
null
,
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
)
private
void
AddToIdManager
(
SvgElement
item
,
SvgElement
sibling
,
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
);
this
.
_owner
.
OwnerDocument
.
IdManager
.
AddAndFixID
(
item
,
sibling
,
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
));
child
.
ApplyRecursive
(
e
=>
this
.
_owner
.
OwnerDocument
.
IdManager
.
AddAndFixID
(
e
,
null
,
autoFixChildrenID
,
logElementOldIDNewID
));
}
}
}
...
...
Source/SvgElementIdManager.cs
View file @
cf8f77dc
...
...
@@ -48,7 +48,7 @@ namespace Svg
/// <param name="element">The <see cref="SvgElement"/> to be managed.</param>
public
virtual
void
Add
(
SvgElement
element
)
{
AddAndFixID
(
element
,
false
);
AddAndFixID
(
element
,
null
,
false
);
}
/// <summary>
...
...
@@ -59,7 +59,7 @@ namespace Svg
/// <param name="autoFixID">Pass true here, if you want the ID to be fixed</param>
/// <param name="logElementOldIDNewID">If not null, the action is called before the id is fixed</param>
/// <returns>true, if ID was altered</returns>
public
virtual
bool
AddAndFixID
(
SvgElement
element
,
bool
autoFixID
=
true
,
Action
<
SvgElement
,
string
,
string
>
logElementOldIDNewID
=
null
)
public
virtual
bool
AddAndFixID
(
SvgElement
element
,
SvgElement
sibling
,
bool
autoFixID
=
true
,
Action
<
SvgElement
,
string
,
string
>
logElementOldIDNewID
=
null
)
{
var
result
=
false
;
if
(!
string
.
IsNullOrEmpty
(
element
.
ID
))
...
...
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