using System.Drawing;
using System.Drawing.Drawing2D;
namespace Svg
{
///
/// An element used to group SVG shapes.
///
[SvgElement("g")]
public class SvgGroup : SvgVisualElement
{
public SvgGroup()
{
}
///
/// Gets the for this element.
///
///
public override System.Drawing.Drawing2D.GraphicsPath Path(SvgRenderer renderer)
{
return GetPaths(this, renderer);
}
///
/// Gets the bounds of the element.
///
/// The bounds.
public override System.Drawing.RectangleF Bounds
{
get
{
var r = new RectangleF();
foreach(var c in this.Children)
{
if (c is SvgVisualElement)
{
// First it should check if rectangle is empty or it will return the wrong Bounds.
// This is because when the Rectangle is Empty, the Union method adds as if the first values where X=0, Y=0
if (r.IsEmpty)
{
r = ((SvgVisualElement)c).Bounds;
}
else
{
var childBounds = ((SvgVisualElement)c).Bounds;
if (!childBounds.IsEmpty)
{
r = RectangleF.Union(r, childBounds);
}
}
}
}
return r;
}
}
protected override bool Renderable { get { return false; } }
/////
///// Renders the and contents to the specified object.
/////
///// The object to render to.
//protected override void Render(SvgRenderer renderer)
//{
// if (!Visible || !Displayable)
// return;
// if (this.PushTransforms(renderer))
// {
// this.SetClip(renderer);
// base.RenderChildren(renderer);
// this.ResetClip(renderer);
// this.PopTransforms(renderer);
// }
//}
public override SvgElement DeepCopy()
{
return DeepCopy();
}
public override SvgElement DeepCopy()
{
var newObj = base.DeepCopy() as SvgGroup;
if (this.Fill != null)
newObj.Fill = this.Fill.DeepCopy() as SvgPaintServer;
return newObj;
}
}
}