Commit fecffa78 authored by mrbean-bremen's avatar mrbean-bremen Committed by mrbean-bremen
Browse files

Added support for marker attributes in groups

- partly fixes respective W3C examples
parent 2d7852b7
......@@ -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)
......
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 : SvgVisualElement
public class SvgGroup : SvgMarkerElement
{
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>
......
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