private bool ExportSvgDialog() { if (svgExportFileDialog.ShowDialog() == DialogResult.OK) { try { File.WriteAllText(svgExportFileDialog.FileName, LineEndUtil.ToUnix(_generator.GenerateCode(ExportStrokeWidth))); return(true); } catch (Exception ex) { MessageBox.Show(ex.Message, "Error encountered", MessageBoxButtons.OK, MessageBoxIcon.Error); } } return(false); }
private bool SaveCodeDialog() { if (saveCodeFileDialog.ShowDialog() == DialogResult.OK) { try { File.WriteAllText(saveCodeFileDialog.FileName, LineEndUtil.ToUnix(outTextBox.Text)); _modified = false; return(true); } catch (Exception ex) { MessageBox.Show(ex.Message, "Error encountered", MessageBoxButtons.OK, MessageBoxIcon.Error); } } return(false); }
private bool ExecuteCommand(string text) { _modified = true; Command[] commands = null; try { commands = CrcParser.ParseCommands(text).ToArray(); } catch (Exception ex) { MessageBox.Show(ex.Message, "Parser Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } if (commands != null) { Debug.WriteLine($"Parsed {commands.Length} commands"); try { foreach (var cmd in commands) { _generator.ExecuteCommand(cmd); } _svg = SvgDocument.FromSvg <SvgDocument>(_generator.GenerateCode(RenderStrokeWidth)); RenderSvg(); if (outTextBox.Text != "") { outTextBox.AppendText("\r\n"); } outTextBox.AppendText(LineEndUtil.ToWindows(text)); return(true); } catch (Exception ex) { MessageBox.Show(ex.Message, "Render Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } } return(false); }