public RectangleF GetBRect(float margin)
{
if (this is ISharpGDIPath)
{
ISharpGDIPath gdiPathElm = (ISharpGDIPath)this;
GraphicsPath gp = gdiPathElm.GetGraphicsPath();
SvgMatrix svgMatrix = (SvgMatrix)this.GetScreenCTM();
RectangleF bounds = gp.GetBounds(svgMatrix.ToMatrix());
bounds = RectangleF.Inflate(bounds, margin, margin);
return(bounds);
}
else if (this is ISvgUseElement)
{
SvgUseElement use = (SvgUseElement)this;
SvgTransformableElement refEl = use.ReferencedElement as SvgTransformableElement;
if (refEl == null)
{
return(RectangleF.Empty);
}
XmlElement refElParent = (XmlElement)refEl.ParentNode;
OwnerDocument.Static = true;
use.CopyToReferencedElement(refEl);
this.AppendChild(refEl);
RectangleF bbox = refEl.GetBRect(margin);
this.RemoveChild(refEl);
use.RestoreReferencedElement(refEl);
refElParent.AppendChild(refEl);
OwnerDocument.Static = false;
return(bbox);
}
else
{
RectangleF union = RectangleF.Empty;
SvgTransformableElement transformChild;
foreach (XmlNode childNode in ChildNodes)
{
if (childNode is SvgDefsElement)
{
continue;
}
if (childNode is ISvgTransformable)
{
transformChild = (SvgTransformableElement)childNode;
RectangleF bbox = transformChild.GetBRect(margin);
if (bbox != RectangleF.Empty)
{
if (union == RectangleF.Empty)
{
union = bbox;
}
else
{
union = RectangleF.Union(union, bbox);
}
}
}
}
return(union);
}
}