Commit ec99fa95 authored by H1Gdev's avatar H1Gdev Committed by mrbean-bremen
Browse files

Fix: Crash viewer when entering text.

- Catch exceptions in event handler.
parent 838008c1
......@@ -22,28 +22,40 @@ namespace SVGViewer
private void open_Click(object sender, EventArgs e)
{
if (openSvgFile.ShowDialog() == DialogResult.OK)
try
{
if (openSvgFile.ShowDialog() == DialogResult.OK)
{
SvgDocument svgDoc = SvgDocument.Open(openSvgFile.FileName);
RenderSvg(svgDoc);
}
}
catch
{
SvgDocument svgDoc = SvgDocument.Open(openSvgFile.FileName);
RenderSvg(svgDoc);
}
}
private void textBox1_TextChanged(object sender, EventArgs e)
{
using(var s = new MemoryStream(Encoding.UTF8.GetBytes(textBox1.Text)))
{
SvgDocument svgDoc = SvgDocument.Open<SvgDocument>(s, null);
RenderSvg(svgDoc);
}
try
{
using (var s = new MemoryStream(Encoding.UTF8.GetBytes(textBox1.Text)))
{
SvgDocument svgDoc = SvgDocument.Open<SvgDocument>(s, null);
RenderSvg(svgDoc);
}
}
catch
{
}
}
private void RenderSvg(SvgDocument svgDoc)
{
//var render = new DebugRenderer();
//svgDoc.Draw(render);
svgImage.Image = svgDoc.Draw();
string outputDir;
if (svgDoc.BaseUri == null)
outputDir = System.IO.Path.GetDirectoryName(Application.ExecutablePath);
......
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