Commit dd436504 authored by HeinrichAD's avatar HeinrichAD
Browse files

Fix NullReferenceException by using the textbox as SVG XML input source.

A NullReferenceException occurred when the SVG XML will be loaded over
the textbox. The reason is that in this case the svgDoc.BaseUri is null.
parent e32ea566
......@@ -25,7 +25,6 @@ namespace SVGViewer
if (openSvgFile.ShowDialog() == DialogResult.OK)
{
SvgDocument svgDoc = SvgDocument.Open(openSvgFile.FileName);
RenderSvg(svgDoc);
}
}
......@@ -44,7 +43,13 @@ namespace SVGViewer
//var render = new DebugRenderer();
//svgDoc.Draw(render);
svgImage.Image = svgDoc.Draw();
svgImage.Image.Save(System.IO.Path.Combine(System.IO.Path.GetDirectoryName(svgDoc.BaseUri.LocalPath), "output.png"));
string outputDir;
if (svgDoc.BaseUri == null)
outputDir = System.IO.Path.GetDirectoryName(Application.ExecutablePath);
else
outputDir = System.IO.Path.GetDirectoryName(svgDoc.BaseUri.LocalPath);
svgImage.Image.Save(System.IO.Path.Combine(outputDir, "output.png"));
}
}
}
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