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
fecffa78
Commit
fecffa78
authored
Jan 26, 2019
by
mrbean-bremen
Committed by
mrbean-bremen
Jan 27, 2019
Browse files
Added support for marker attributes in groups
- partly fixes respective W3C examples
parent
2d7852b7
Changes
2
Hide whitespace changes
Inline
Side-by-side
Source/Basic Shapes/SvgMarkerElement.cs
View file @
fecffa78
...
...
@@ -20,7 +20,7 @@ namespace Svg
/// <summary>
/// Gets or sets the marker (
start cap
) of the path.
/// Gets or sets the marker (
mid points
) of the path.
/// </summary>
[
SvgAttribute
(
"marker-mid"
,
true
)]
public
Uri
MarkerMid
...
...
@@ -41,7 +41,8 @@ namespace Svg
}
/// <summary>
/// Renders the stroke of the <see cref="SvgVisualElement"/> to the specified <see cref="ISvgRenderer"/>
/// Renders the stroke of the element to the specified <see cref="ISvgRenderer"/>.
/// Includes rendering of all markers defined in attributes.
/// </summary>
/// <param name="renderer">The <see cref="ISvgRenderer"/> object to render to.</param>
protected
internal
override
bool
RenderStroke
(
ISvgRenderer
renderer
)
...
...
Source/Document Structure/SvgGroup.cs
View file @
fecffa78
using
Svg.ExtensionMethods
;
using
System
;
using
System.Drawing
;
using
System.Drawing.Drawing2D
;
namespace
Svg
{
...
...
@@ -7,8 +8,54 @@ namespace Svg
/// An element used to group SVG shapes.
/// </summary>
[
SvgElement
(
"g"
)]
public
class
SvgGroup
:
Svg
Visual
Element
public
class
SvgGroup
:
Svg
Marker
Element
{
bool
markersSet
=
false
;
/// <summary>
/// If the group has marker attributes defined, add them to all children
/// that are able to display markers. Only done once.
/// </summary>
private
void
AddMarkers
()
{
if
(!
markersSet
)
{
if
(
this
.
MarkerStart
!=
null
||
this
.
MarkerMid
!=
null
||
this
.
MarkerEnd
!=
null
)
{
foreach
(
var
c
in
this
.
Children
)
{
if
(
c
is
SvgMarkerElement
)
{
if
(
this
.
MarkerStart
!=
null
&&
((
SvgMarkerElement
)
c
).
MarkerStart
==
null
)
{
((
SvgMarkerElement
)
c
).
MarkerStart
=
this
.
MarkerStart
;
}
if
(
this
.
MarkerMid
!=
null
&&
((
SvgMarkerElement
)
c
).
MarkerMid
==
null
)
{
((
SvgMarkerElement
)
c
).
MarkerMid
=
this
.
MarkerMid
;
}
if
(
this
.
MarkerEnd
!=
null
&&
((
SvgMarkerElement
)
c
).
MarkerEnd
==
null
)
{
((
SvgMarkerElement
)
c
).
MarkerEnd
=
this
.
MarkerEnd
;
}
}
}
}
markersSet
=
true
;
}
}
/// <summary>
/// Add group markers to children before rendering them.
/// This is only done on first rendering.
/// </summary>
/// <param name="renderer">The <see cref="ISvgRenderer"/> to render the child <see cref="SvgElement"/>s to.</param>
protected
override
void
Render
(
ISvgRenderer
renderer
)
{
AddMarkers
();
base
.
Render
(
renderer
);
}
/// <summary>
/// Gets the <see cref="GraphicsPath"/> for this element.
/// </summary>
...
...
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