Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
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
12818509
Commit
12818509
authored
11 years ago
by
Ralf Kornelius
Browse files
Options
Download
Email Patches
Plain Diff
Support "none" in Fill value if inherited from parent
Support "none" in Fill value if inherited from parent
parent
69c4a7ed
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
Source/Document Structure/SvgGroup.cs
+1
-1
Source/Document Structure/SvgGroup.cs
Source/Painting/SvgColourServer.cs
+6
-1
Source/Painting/SvgColourServer.cs
Source/SvgElement.cs
+14
-11
Source/SvgElement.cs
with
21 additions
and
13 deletions
+21
-13
Source/Document Structure/SvgGroup.cs
+
1
-
1
View file @
12818509
...
...
@@ -26,7 +26,7 @@ namespace Svg
[
SvgAttribute
(
"fill"
)]
public
override
SvgPaintServer
Fill
{
get
{
return
(
this
.
Attributes
[
"Fill"
]
==
null
)
?
n
ew
SvgColourServer
(
Color
.
Transparent
)
:
(
SvgPaintServer
)
this
.
Attributes
[
"Fill"
];
}
get
{
return
(
this
.
Attributes
[
"Fill"
]
==
null
)
?
n
ull
:
(
SvgPaintServer
)
this
.
Attributes
[
"Fill"
];
}
set
{
this
.
Attributes
[
"Fill"
]
=
value
;
}
}
...
...
This diff is collapsed.
Click to expand it.
Source/Painting/SvgColourServer.cs
+
6
-
1
View file @
12818509
...
...
@@ -67,7 +67,12 @@ namespace Svg
if
(
objColor
==
null
)
return
false
;
return
this
.
Colour
.
ToArgb
()
==
objColor
.
Colour
.
ToArgb
();
return
this
.
GetHashCode
()
==
objColor
.
GetHashCode
();
}
public
override
int
GetHashCode
()
{
return
_colour
.
GetHashCode
();
}
}
}
This diff is collapsed.
Click to expand it.
Source/SvgElement.cs
+
14
-
11
View file @
12818509
...
...
@@ -350,12 +350,13 @@ namespace Svg
var
forceWrite
=
false
;
if
((
attr
.
Attribute
.
Name
==
"fill"
)
&&
(
Parent
!=
null
))
{
var
parentValue
=
ResolveParentAttributeValue
(
attr
.
Attribute
.
Name
)
;
if
(
parentValue
!=
null
)
object
parentValue
;
if
(
TryResolveParentAttributeValue
(
attr
.
Attribute
.
Name
,
out
parentValue
)
)
{
if
(
parentValue
.
Equals
(
propertyValue
))
if
((
parentValue
==
propertyValue
)
||
((
parentValue
!=
null
)
&&
parentValue
.
Equals
(
propertyValue
)))
continue
;
forceWrite
=
true
;
}
}
...
...
@@ -370,7 +371,7 @@ namespace Svg
writer
.
WriteAttributeString
(
attr
.
Attribute
.
NamespaceAndName
,
value
);
}
}
else
if
(
attr
.
Attribute
.
Name
==
"fill"
)
//if fill equals null, write 'none'
else
if
(
attr
.
Attribute
.
Name
==
"fill"
)
//if fill equals null, write 'none'
{
string
value
=
(
string
)
attr
.
Property
.
Converter
.
ConvertTo
(
propertyValue
,
typeof
(
string
));
writer
.
WriteAttributeString
(
attr
.
Attribute
.
NamespaceAndName
,
value
);
...
...
@@ -385,25 +386,27 @@ namespace Svg
}
}
private
object
ResolveParentAttributeValue
(
string
attributeKey
)
private
bool
Try
ResolveParentAttributeValue
(
string
attributeKey
,
out
object
parentAttributeValue
)
{
a
ttribute
Key
=
char
.
ToUpper
(
attributeKey
[
0
])
+
attributeKey
.
Substring
(
1
)
;
parentA
ttribute
Value
=
null
;
object
parentValue
=
null
;
attributeKey
=
char
.
ToUpper
(
attributeKey
[
0
])
+
attributeKey
.
Substring
(
1
)
;
var
currentParent
=
Parent
;
var
resolved
=
false
;
while
(
currentParent
!=
null
)
{
if
(
currentParent
.
Attributes
.
ContainsKey
(
attributeKey
))
{
parentValue
=
currentParent
.
Attributes
[
attributeKey
];
if
(
parentValue
!=
null
)
resolved
=
true
;
parentAttributeValue
=
currentParent
.
Attributes
[
attributeKey
];
if
(
parentAttributeValue
!=
null
)
break
;
}
currentParent
=
currentParent
.
Parent
;
}
return
parentValue
;
return
resolved
;
}
protected
virtual
void
Write
(
XmlTextWriter
writer
)
...
...
This diff is collapsed.
Click to expand it.
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
Menu
Projects
Groups
Snippets
Help