diff --git a/Shape Converter/BusinessLogic/Exporter/SvgExporter.cs b/Shape Converter/BusinessLogic/Exporter/SvgExporter.cs
index c852d51..1caf343 100644
--- a/Shape Converter/BusinessLogic/Exporter/SvgExporter.cs
+++ b/Shape Converter/BusinessLogic/Exporter/SvgExporter.cs
@@ -20,6 +20,8 @@
// along with this program. If not, see.
using System.Globalization;
+using System.IO;
+using System.IO.Compression;
using System.Text;
using System.Windows.Media;
using System.Xml;
@@ -35,9 +37,41 @@ namespace ShapeConverter.BusinessLogic.Exporter
public static class SvgExporter
{
///
- /// Export to an image format
+ /// Export to SVG
///
public static void ExportSvg(GraphicVisual visual, int width, string filename)
+ {
+ XElement root = CreateXmlExport(visual, width);
+
+ using (var writer = XmlWriter.Create(filename, new XmlWriterSettings { OmitXmlDeclaration = true, Indent = true }))
+ {
+ root.Save(writer);
+ }
+ }
+
+ ///
+ /// Export to SVGZ
+ ///
+ public static void ExportSvgz(GraphicVisual visual, int width, string filename)
+ {
+ XElement root = CreateXmlExport(visual, width);
+
+ using (var fs = File.Create(filename))
+ {
+ using (var gz = new GZipStream(fs, CompressionMode.Compress))
+ {
+ using (var writer = XmlWriter.Create(gz, new XmlWriterSettings { OmitXmlDeclaration = true, Indent = true }))
+ {
+ root.Save(writer);
+ }
+ }
+ }
+ }
+
+ ///
+ /// Create the xml export structure
+ ///
+ private static XElement CreateXmlExport(GraphicVisual visual, int width)
{
XNamespace ns = "http://www.w3.org/2000/svg";
XElement root = new XElement(ns + "svg");
@@ -51,7 +85,7 @@ public static void ExportSvg(GraphicVisual visual, int width, string filename)
XElement definitions = new XElement(ns + "defs");
int definitionsCount = 0;
- var element = Generate(normalizedVisual, ns, definitions, ref definitionsCount);
+ var element = GenerateXmlTree(normalizedVisual, ns, definitions, ref definitionsCount);
if (definitions.HasElements)
{
@@ -59,18 +93,13 @@ public static void ExportSvg(GraphicVisual visual, int width, string filename)
}
root.Add(element);
-
- using (var writer =
- XmlWriter.Create(filename, new XmlWriterSettings { OmitXmlDeclaration = true, Indent = true }))
- {
- root.Save(writer);
- }
+ return root;
}
///
/// Generate a visual recursively to xml
///
- private static XElement Generate(GraphicVisual visual, XNamespace ns, XElement definitions, ref int definitionsCount)
+ private static XElement GenerateXmlTree(GraphicVisual visual, XNamespace ns, XElement definitions, ref int definitionsCount)
{
XElement element = null;
@@ -106,7 +135,7 @@ private static XElement Generate(GraphicVisual visual, XNamespace ns, XElement d
foreach (var childVisual in group.Children)
{
- var path = Generate(childVisual, ns, definitions, ref definitionsCount);
+ var path = GenerateXmlTree(childVisual, ns, definitions, ref definitionsCount);
element.Add(path);
}
@@ -192,7 +221,7 @@ private static void SetColors(GraphicPath graphicPath, XElement pathElement, XNa
if (!DoubleUtilities.IsZero(graphicPath.StrokeDashOffset))
{
- pathElement.Add(new XAttribute("stroke-dashoffset", DoubleUtilities.FormatString(graphicPath.StrokeDashOffset * graphicPath.StrokeThickness)));
+ pathElement.Add(new XAttribute("stroke-dashoffset", DoubleUtilities.FormatString(graphicPath.StrokeDashOffset * graphicPath.StrokeThickness)));
}
}
}
diff --git a/Shape Converter/Properties/AssemblyInfo.cs b/Shape Converter/Properties/AssemblyInfo.cs
index baa8970..e97e404 100644
--- a/Shape Converter/Properties/AssemblyInfo.cs
+++ b/Shape Converter/Properties/AssemblyInfo.cs
@@ -71,5 +71,5 @@
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
-[assembly: AssemblyVersion("2.26.0.0")]
-[assembly: AssemblyFileVersion("2.26.0.0")]
+[assembly: AssemblyVersion("2.27.0.0")]
+[assembly: AssemblyFileVersion("2.27.0.0")]
diff --git a/Shape Converter/Shell/Exporter/VisualExporter.cs b/Shape Converter/Shell/Exporter/VisualExporter.cs
index c3b2261..80e5de9 100644
--- a/Shape Converter/Shell/Exporter/VisualExporter.cs
+++ b/Shape Converter/Shell/Exporter/VisualExporter.cs
@@ -36,7 +36,7 @@ public static void Export(GraphicVisual visual, int width, bool addMargin, out s
{
message = string.Empty;
var saveDialog = new Microsoft.Win32.SaveFileDialog();
- saveDialog.Filter = "ICO File (*.ico)|*.ico|SVG File (*.svg)|*.svg|PNG File (*.png)|*.png|JPG File (*.jpg)|*.jpg|TIFF File (*.tiff)|*.tiff|BMP File (*.bmp)|*.bmp|GIF File (*.gif)|*.gif|EPS File (*.eps)|*.eps";
+ saveDialog.Filter = "ICO File (*.ico)|*.ico|SVG File (*.svg)|*.svg|SVGZ File (*.svgz)|*.svgz|PNG File (*.png)|*.png|JPG File (*.jpg)|*.jpg|TIFF File (*.tiff)|*.tiff|BMP File (*.bmp)|*.bmp|GIF File (*.gif)|*.gif|EPS File (*.eps)|*.eps";
var result = saveDialog.ShowDialog();
@@ -53,6 +53,10 @@ public static void Export(GraphicVisual visual, int width, bool addMargin, out s
SvgExporter.ExportSvg(visual, width, saveDialog.FileName);
break;
+ case ".svgz":
+ SvgExporter.ExportSvgz(visual, width, saveDialog.FileName);
+ break;
+
case ".ico":
IcoExporter.ExportIco(visual, saveDialog.FileName);
break;