Skip to content

Commit

Permalink
small coding fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
jogibear9988 committed Dec 10, 2018
1 parent db8756e commit f410861
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 48 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# Build Folders (you can keep bin if you'd like, to store dlls and pdbs)
[Bb]in/
[Oo]bj/
.vs/

# mstest test results
TestResults
Expand Down
4 changes: 2 additions & 2 deletions SVGImage/Example/MainWindow.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@
xmlns:svg1="clr-namespace:SVGImage.SVG;assembly=DotNetProjects.SVGImage"
Title="MainWindow" Height="1000" Width="1500" Background="{DynamicResource {x:Static SystemColors.ActiveCaptionBrushKey}}" Foreground="{DynamicResource {x:Static SystemColors.ActiveBorderBrushKey}}">
<Grid Background="Wheat">
<svg1:SVGImage Source="/Example;component/Images/bb.svg" Margin="10,10,0,0" RenderTransformOrigin="0.5,0.5" VerticalContentAlignment="Center" HorizontalContentAlignment="Center" HorizontalAlignment="Left" Width="261" Height="181" VerticalAlignment="Top" />
<svg1:SVGImage Source="/Example;component/Images/bb.svg" Margin="576,377,0,0" RenderTransformOrigin="0.5,0.5" VerticalContentAlignment="Center" HorizontalContentAlignment="Center" HorizontalAlignment="Left" Width="261" Height="181" VerticalAlignment="Top" />
<svg1:SVGImage Source="/Example;component/Images/brush.svg" Margin="276,10,0,0" RenderTransformOrigin="0.5,0.5" VerticalContentAlignment="Center" HorizontalContentAlignment="Center" HorizontalAlignment="Left" Width="261" Height="181" VerticalAlignment="Top" />
<svg1:SVGImage Source="/Example;component/Images/Soccer_ball_animated.svg" UseAnimations="True" Margin="493,10,0,0" RenderTransformOrigin="0.5,0.5" VerticalContentAlignment="Center" HorizontalContentAlignment="Center" HorizontalAlignment="Left" Width="261" Height="181" VerticalAlignment="Top" />
<svg1:SVGImage Source="/Example;component/Images/example8.1.test01.svg" Margin="10,196,0,0" RenderTransformOrigin="0.5,0.5" VerticalContentAlignment="Center" HorizontalContentAlignment="Center" HorizontalAlignment="Left" Width="261" Height="181" VerticalAlignment="Top" />
<svg1:SVGImage Source="/Example;component/Images/tombigel_green_router.svg" Margin="759,10,0,0" RenderTransformOrigin="0.5,0.5" VerticalContentAlignment="Center" HorizontalContentAlignment="Center" HorizontalAlignment="Left" Width="261" Height="181" VerticalAlignment="Top" />
<svg1:SVGImage Source="/Example;component/Images/test_3.svg" Margin="716,196,0,0" RenderTransformOrigin="0.5,0.5" VerticalContentAlignment="Center" HorizontalContentAlignment="Center" HorizontalAlignment="Left" Width="261" Height="181" VerticalAlignment="Top" />
<svg1:SVGImage Source="/Example;component/Images/example radgrad01.svg" Margin="15,223,0,0" RenderTransformOrigin="0.848,0.125" VerticalContentAlignment="Center" HorizontalContentAlignment="Center" HorizontalAlignment="Left" Width="261" Height="181" VerticalAlignment="Top" />
<svg1:SVGImage Source="/Example;component/Images/example radgrad01.svg" Margin="10,387,0,0" RenderTransformOrigin="0.848,0.125" VerticalContentAlignment="Center" HorizontalContentAlignment="Center" HorizontalAlignment="Left" Width="261" Height="181" VerticalAlignment="Top" />
<svg1:SVGImage Source="/Example;component/Images/clipping_css.svg" Margin="352,250,0,0" RenderTransformOrigin="0.5,0.5" VerticalContentAlignment="Center" HorizontalContentAlignment="Center" HorizontalAlignment="Left" Width="261" Height="181" VerticalAlignment="Top" />
<svg1:SVGImage Source="/Example;component/Images/tiger.svg" Margin="982,10,0,0" RenderTransformOrigin="0.5,0.5" VerticalContentAlignment="Center" HorizontalContentAlignment="Center" HorizontalAlignment="Left" Width="500" Height="367" VerticalAlignment="Top" />
<svg1:SVGImage Source="/Example;component/Images/171.svg" Margin="10,568,738,10" RenderTransformOrigin="0.5,0.5" VerticalContentAlignment="Center" HorizontalContentAlignment="Center" />
Expand Down
6 changes: 1 addition & 5 deletions SVGImage/SVGImage/SVG/ClipArtElement.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Xml;
using System.Xml;

namespace SVGImage.SVG
{
Expand Down
24 changes: 3 additions & 21 deletions SVGImage/SVGImage/SVG/SVG.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@
using System.Collections.Generic;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Text;
using System.Windows;
using System.Xml;

Expand All @@ -14,8 +12,6 @@ namespace SVGImage.SVG
{
public class SVG
{
private PaintServerManager m_paintServers = new PaintServerManager();

internal Dictionary<string, Shape> m_shapes = new Dictionary<string, Shape>();

internal Dictionary<string, List<XmlAttribute>> m_styles = new Dictionary<string, List<XmlAttribute>>();
Expand All @@ -39,18 +35,10 @@ public Shape GetShape(string id)
return shape;
}

public PaintServerManager PaintServers
{
get
{
return this.m_paintServers;
}
}
public PaintServerManager PaintServers { get; } = new PaintServerManager();

public SVG()
{

}
{ }

public SVG(string filename)
{
Expand Down Expand Up @@ -80,13 +68,7 @@ public SVG(Stream stream)
this.Parse(n);
}

public IList<Shape> Elements
{
get
{
return this.m_elements.AsReadOnly();
}
}
public IList<Shape> Elements => this.m_elements.AsReadOnly();

private void Parse(XmlNode node)
{
Expand Down
33 changes: 13 additions & 20 deletions SVGImage/SVGImage/SVG/SVGRender.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,38 +13,23 @@ namespace SVGImage.SVG
// http://commons.oreilly.com/wiki/index.php/SVG_Essentials
public class SVGRender
{
private SVG m_svg;

public SVG SVG
{
get
{
return this.m_svg;
}
}
public SVG SVG { get; private set; }

public bool UseAnimations { get; set; }

public Color? OverrideColor { get; set; }

public DrawingGroup LoadDrawing(string filename)
{
this.m_svg = new SVG(filename);
return this.CreateDrawing(this.m_svg);
this.SVG = new SVG(filename);
return this.CreateDrawing(this.SVG);
}

public DrawingGroup LoadDrawing(Stream stream)
{
this.m_svg = new SVG(stream);

/*var aa = new MemoryStream();
var qq = XmlWriter.Create(aa, new XmlWriterSettings() { OmitXmlDeclaration = true, Indent = true });
XamlWriter.Save(this.CreateDrawing(this.m_svg), qq);
aa.Position = 0;
var bb = new StreamReader(aa);
var cc = bb.ReadToEnd();*/
this.SVG = new SVG(stream);

return this.CreateDrawing(this.m_svg);
return this.CreateDrawing(this.SVG);
}

public DrawingGroup CreateDrawing(SVG svg)
Expand Down Expand Up @@ -268,13 +253,15 @@ private DrawingGroup LoadGroup(IList<Shape> elements, Rect? viewBox)
if (rect.RadiusX == 0 && rect.RadiusY > 0) rect.RadiusX = rect.RadiusY;
var di = this.NewDrawingItem(shape, rect);
AddDrawingToGroup(grp, shape, di);
continue;
}
if (shape is LineShape)
{
LineShape r = shape as LineShape;
LineGeometry line = new LineGeometry(r.P1, r.P2);
var di = this.NewDrawingItem(shape, line);
AddDrawingToGroup(grp, shape, di);
continue;
}
if (shape is PolylineShape)
{
Expand All @@ -290,6 +277,7 @@ private DrawingGroup LoadGroup(IList<Shape> elements, Rect? viewBox)
}
var di = this.NewDrawingItem(shape, path);
AddDrawingToGroup(grp, shape, di);
continue;
}
if (shape is PolygonShape)
{
Expand All @@ -305,26 +293,30 @@ private DrawingGroup LoadGroup(IList<Shape> elements, Rect? viewBox)
}
var di = this.NewDrawingItem(shape, path);
AddDrawingToGroup(grp, shape, di);
continue;
}
if (shape is CircleShape)
{
CircleShape r = shape as CircleShape;
EllipseGeometry c = new EllipseGeometry(new Point(r.CX, r.CY), r.R, r.R);
var di = this.NewDrawingItem(shape, c);
AddDrawingToGroup(grp, shape, di);
continue;
}
if (shape is EllipseShape)
{
EllipseShape r = shape as EllipseShape;
EllipseGeometry c = new EllipseGeometry(new Point(r.CX, r.CY), r.RX, r.RY);
var di = this.NewDrawingItem(shape, c);
AddDrawingToGroup(grp, shape, di);
continue;
}
if (shape is ImageShape)
{
ImageShape image = shape as ImageShape;
ImageDrawing i = new ImageDrawing(image.ImageSource, new Rect(image.X, image.Y, image.Width, image.Height));
AddDrawingToGroup(grp, shape, i);
continue;
}
if (shape is TextShape)
{
Expand All @@ -346,6 +338,7 @@ private DrawingGroup LoadGroup(IList<Shape> elements, Rect? viewBox)
}
}
}
continue;
}
if (shape is PathShape)
{
Expand Down

0 comments on commit f410861

Please sign in to comment.