Commit 3034b3d3 authored by Tebjan Halm's avatar Tebjan Halm
Browse files

* added get path to svggroup

* added method to collect paths of children elements
* fixed possible bug getinheritedattribute
parent 6998823a
...@@ -71,6 +71,22 @@ namespace Svg ...@@ -71,6 +71,22 @@ namespace Svg
renderer.ScaleTransform(this.Width.ToDeviceValue() / this.ViewBox.Width, this.Height.ToDeviceValue() / this.ViewBox.Height, MatrixOrder.Append); renderer.ScaleTransform(this.Width.ToDeviceValue() / this.ViewBox.Width, this.Height.ToDeviceValue() / this.ViewBox.Height, MatrixOrder.Append);
} }
} }
/// <summary>
/// Gets the <see cref="GraphicsPath"/> for this element.
/// </summary>
/// <value></value>
public GraphicsPath Path
{
get
{
var path = new GraphicsPath();
AddPaths(this, path);
return path;
}
}
/// <summary> /// <summary>
/// Initializes a new instance of the <see cref="SvgFragment"/> class. /// Initializes a new instance of the <see cref="SvgFragment"/> class.
...@@ -78,7 +94,7 @@ namespace Svg ...@@ -78,7 +94,7 @@ namespace Svg
public SvgFragment() public SvgFragment()
{ {
this._height = new SvgUnit(SvgUnitType.Percentage, 100.0f); this._height = new SvgUnit(SvgUnitType.Percentage, 100.0f);
this._width = 1000.0f; this._width = new SvgUnit(SvgUnitType.Percentage, 100.0f);
this.ViewBox = SvgViewBox.Empty; this.ViewBox = SvgViewBox.Empty;
} }
} }
......
...@@ -3,6 +3,7 @@ using System.Collections.Generic; ...@@ -3,6 +3,7 @@ using System.Collections.Generic;
using System.Xml; using System.Xml;
using System.Text; using System.Text;
using System.Drawing; using System.Drawing;
using System.Drawing.Drawing2D;
namespace Svg namespace Svg
{ {
...@@ -33,7 +34,14 @@ namespace Svg ...@@ -33,7 +34,14 @@ namespace Svg
/// <value></value> /// <value></value>
public override System.Drawing.Drawing2D.GraphicsPath Path public override System.Drawing.Drawing2D.GraphicsPath Path
{ {
get { return null; } get
{
var path = new GraphicsPath();
AddPaths(this, path);
return path;
}
} }
/// <summary> /// <summary>
......
...@@ -41,27 +41,31 @@ ...@@ -41,27 +41,31 @@
<UseApplicationTrust>false</UseApplicationTrust> <UseApplicationTrust>false</UseApplicationTrust>
<BootstrapperEnabled>true</BootstrapperEnabled> <BootstrapperEnabled>true</BootstrapperEnabled>
<TargetFrameworkProfile /> <TargetFrameworkProfile />
<AllowUnsafeBlocks>False</AllowUnsafeBlocks>
<NoStdLib>False</NoStdLib>
<TreatWarningsAsErrors>false</TreatWarningsAsErrors>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols> <DebugType>Full</DebugType>
<DebugType>full</DebugType>
<Optimize>false</Optimize> <Optimize>false</Optimize>
<OutputPath>..\..\..\..\..\..\Dev\vvvv\vvvv\public\common\src\thirdparty\</OutputPath> <OutputPath>..\..\vvvv\public\common\src\thirdparty\</OutputPath>
<DefineConstants>TRACE;DEBUG;REFLECTION</DefineConstants> <DefineConstants>TRACE;DEBUG;REFLECTION</DefineConstants>
<ErrorReport>prompt</ErrorReport> <ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel> <WarningLevel>4</WarningLevel>
<CodeAnalysisRuleSet>AllRules.ruleset</CodeAnalysisRuleSet> <CodeAnalysisRuleSet>AllRules.ruleset</CodeAnalysisRuleSet>
<DebugSymbols>true</DebugSymbols>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType> <DebugType>PdbOnly</DebugType>
<Optimize>true</Optimize> <Optimize>true</Optimize>
<OutputPath>..\..\..\..\..\..\Dev\vvvv\vvvv\public\common\src\thirdparty\</OutputPath> <OutputPath>..\..\vvvv\public\common\src\thirdparty\</OutputPath>
<DefineConstants>TRACE</DefineConstants> <DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport> <ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel> <WarningLevel>4</WarningLevel>
<CodeAnalysisRules> <CodeAnalysisRules>
</CodeAnalysisRules> </CodeAnalysisRules>
<CodeAnalysisRuleSet>AllRules.ruleset</CodeAnalysisRuleSet> <CodeAnalysisRuleSet>AllRules.ruleset</CodeAnalysisRuleSet>
<DebugSymbols>false</DebugSymbols>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<Reference Include="Microsoft.JScript" /> <Reference Include="Microsoft.JScript" />
...@@ -208,4 +212,17 @@ ...@@ -208,4 +212,17 @@
<PostBuildEvent> <PostBuildEvent>
</PostBuildEvent> </PostBuildEvent>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition=" '$(Platform)' == 'AnyCPU' ">
<RegisterForComInterop>False</RegisterForComInterop>
<GenerateSerializationAssemblies>Auto</GenerateSerializationAssemblies>
<BaseAddress>4194304</BaseAddress>
<PlatformTarget>AnyCPU</PlatformTarget>
<FileAlignment>4096</FileAlignment>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)' == 'Debug' ">
<CheckForOverflowUnderflow>False</CheckForOverflowUnderflow>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)' == 'Release' ">
<CheckForOverflowUnderflow>False</CheckForOverflowUnderflow>
</PropertyGroup>
</Project> </Project>
\ No newline at end of file
...@@ -63,7 +63,7 @@ namespace Svg ...@@ -63,7 +63,7 @@ namespace Svg
/// <returns>The attribute value if available; otherwise the ancestors value for the same attribute; otherwise the default value of <typeparamref name="TAttributeType"/>.</returns> /// <returns>The attribute value if available; otherwise the ancestors value for the same attribute; otherwise the default value of <typeparamref name="TAttributeType"/>.</returns>
public TAttributeType GetInheritedAttribute<TAttributeType>(string attributeName) public TAttributeType GetInheritedAttribute<TAttributeType>(string attributeName)
{ {
if (this.ContainsKey(attributeName) && base[attributeName] != null) if (this.ContainsKey(attributeName) /*&& base[attributeName] != null*/)
{ {
return (TAttributeType)base[attributeName]; return (TAttributeType)base[attributeName];
} }
......
...@@ -405,6 +405,26 @@ namespace Svg ...@@ -405,6 +405,26 @@ namespace Svg
{ {
this.Render(renderer); this.Render(renderer);
} }
/// <summary>
/// Recursive method to add up the paths of all children
/// </summary>
/// <param name="elem"></param>
/// <param name="path"></param>
protected void AddPaths(SvgElement elem, GraphicsPath path)
{
foreach(var c in elem.Children)
{
if (c is SvgVisualElement)
{
var cp = ((SvgVisualElement)c).Path;
if (cp != null) path.AddPath(cp, false);
}
AddPaths(c, path);
}
}
/// <summary> /// <summary>
/// Creates a new object that is a copy of the current instance. /// Creates a new object that is a copy of the current instance.
......
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