Skip to content

Commit

Permalink
Merge pull request #13 from soapgu/master
Browse files Browse the repository at this point in the history
fix some svg can not parse bug
  • Loading branch information
jogibear9988 committed Mar 14, 2019
2 parents 0723c6d + 0a32d24 commit 513d493
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 2 deletions.
3 changes: 3 additions & 0 deletions SVGImage/Example/Example.csproj
Expand Up @@ -213,6 +213,9 @@
<ItemGroup>
<Resource Include="Images\acid1.css" />
</ItemGroup>
<ItemGroup>
<Resource Include="Images\error.svg" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
Expand Down
23 changes: 23 additions & 0 deletions SVGImage/Example/Images/error.svg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion SVGImage/Example/MainWindow.xaml
Expand Up @@ -25,6 +25,6 @@
<svg1:SVGImage Source="/Example;component/Images/5.svg" Margin="0,400,0,0" RenderTransformOrigin="0.5,0.5" VerticalContentAlignment="Center" HorizontalContentAlignment="Center" HorizontalAlignment="Right" Width="260" Height="100" VerticalAlignment="Top" />
<svg1:SVGImage Source="/Example;component/Images/6.svg" Margin="0,500,0,0" RenderTransformOrigin="0.5,0.5" VerticalContentAlignment="Center" HorizontalContentAlignment="Center" HorizontalAlignment="Right" Width="260" Height="100" VerticalAlignment="Top" />
<svg1:SVGImage Source="/Example;component/Images/acid1.svg" Margin="0,600,0,0" RenderTransformOrigin="0.5,0.5" VerticalContentAlignment="Center" HorizontalContentAlignment="Center" HorizontalAlignment="Right" Width="260" Height="180" VerticalAlignment="Top" />

<svg1:SVGImage Source="/Example;component/Images/error.svg"></svg1:SVGImage>
</Grid>
</Window>
5 changes: 4 additions & 1 deletion SVGImage/SVGImage/SVG/SVGRender.cs
Expand Up @@ -395,8 +395,10 @@ internal DrawingGroup LoadGroup(IList<Shape> elements, Rect? viewBox, bool isSwi
PathShape.CurveTo lastc = null;
PathShape.QuadraticCurveTo lastq = null;
Point lastcirPoint = new Point(0, 0);
PathGeometry path = PathGeometry.CreateFromGeometry(PathGeometry.Parse(r.Data));
//PathGeometry path = new PathGeometry();

PathGeometry path = new PathGeometry();
/*
foreach (PathShape.PathElement element in r.Elements)
{
bool isRelative = element.IsRelative;
Expand Down Expand Up @@ -546,6 +548,7 @@ internal DrawingGroup LoadGroup(IList<Shape> elements, Rect? viewBox, bool isSwi
continue;
}
}
*/
/*
if (r.Transform != null)
path.Transform = r.Transform;
Expand Down
6 changes: 6 additions & 0 deletions SVGImage/SVGImage/SVG/Shapes/PathShape.cs
Expand Up @@ -192,6 +192,9 @@ public IList<PathElement> Elements
}

public bool ClosePath { get; private set; }

public string Data { get; private set; }

// http://apike.ca/prog_svg_paths.html
public PathShape(SVG svg, XmlNode node, Shape parent) : base(svg, node, parent)
{
Expand All @@ -203,6 +206,8 @@ public PathShape(SVG svg, XmlNode node, Shape parent) : base(svg, node, parent)

this.ClosePath = false;
string path = XmlUtil.AttrValue(node, "d", string.Empty);
this.Data = path;
/*
CommandSplitter cmd = new CommandSplitter(path);
string commandstring;
char command;
Expand Down Expand Up @@ -272,6 +277,7 @@ public PathShape(SVG svg, XmlNode node, Shape parent) : base(svg, node, parent)
System.Diagnostics.Debug.Assert(false, string.Format("type '{0}' not supported", commandstring));
}
*/
}
}
}

0 comments on commit 513d493

Please sign in to comment.