Commit 05922300 authored by Tebjan Halm's avatar Tebjan Halm
Browse files

* better path collection method

* fixed missing files
parent bc1d94f4
......@@ -38,9 +38,9 @@ namespace Svg
{
var path = new GraphicsPath();
AddPaths(this, path);
//AddPaths(this, path);
return path;
return GetPaths(this);
}
}
......@@ -50,7 +50,16 @@ namespace Svg
/// <value>The bounds.</value>
public override System.Drawing.RectangleF Bounds
{
get { return new System.Drawing.RectangleF(); }
get
{
var r = new RectangleF();
foreach(var c in this.Children)
{
if(c is SvgVisualElement)
r = RectangleF.Union(r, ((SvgVisualElement)c).Bounds);
}
return r;
}
}
/// <summary>
......
......@@ -91,6 +91,7 @@
<Compile Include="Clipping and Masking\SvgClipPath.cs" />
<Compile Include="Clipping and Masking\SvgMask.cs" />
<Compile Include="DataTypes\ISvgViewPort.cs" />
<Compile Include="DataTypes\SvgAspectRatio.cs" />
<Compile Include="DataTypes\SvgElementStyle.cs" />
<Compile Include="DataTypes\SvgCoordinateUnits.cs" />
<Compile Include="DataTypes\SvgUnitCollection.cs" />
......
......@@ -415,23 +415,64 @@ namespace Svg
{
foreach(var child in elem.Children)
{
if (!(child is SvgGroup) && child is SvgVisualElement)
if (child is SvgVisualElement)
{
var childPath = ((SvgVisualElement)child).Path;
if (childPath != null)
if(!(child is SvgGroup))
{
childPath = (GraphicsPath)childPath.Clone();
if(child.Transforms != null)
childPath.Transform(child.Transforms.GetMatrix());
var childPath = ((SvgVisualElement)child).Path;
path.AddPath(childPath, false);
if (childPath != null)
{
childPath = (GraphicsPath)childPath.Clone();
if(child.Transforms != null)
childPath.Transform(child.Transforms.GetMatrix());
path.AddPath(childPath, false);
}
}
}
AddPaths(child, path);
}
}
/// <summary>
/// Recursive method to add up the paths of all children
/// </summary>
/// <param name="elem"></param>
/// <param name="path"></param>
protected GraphicsPath GetPaths(SvgElement elem)
{
var ret = new GraphicsPath();
foreach(var child in elem.Children)
{
if (child is SvgVisualElement)
{
if(!(child is SvgGroup))
{
var childPath = ((SvgVisualElement)child).Path;
if (childPath != null)
{
childPath = (GraphicsPath)childPath.Clone();
if(child.Transforms != null)
childPath.Transform(child.Transforms.GetMatrix());
ret.AddPath(childPath, false);
}
}
else
{
var childPath = GetPaths(child);
if(child.Transforms != null)
childPath.Transform(child.Transforms.GetMatrix());
}
}
}
return ret;
}
/// <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