private void executeToolStripMenuItem_Click(object sender, System.EventArgs e) { try { var writer = new StringWriter(); foreach (var item in designerControl1.Items) { var json = _engine.Run(item); writer.WriteLine(json); } var viewer = new FormCodeViewer { Code = writer.ToString() }; viewer.Show(this); } catch (System.Exception ex) { MessageBox.Show(ex.Message, @"engine error", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void generateCodeToolStripMenuItem_Click(object sender, System.EventArgs e) { var generator = new CalculationCodeGenerator(); const string newLine = "\r\n "; var codeBlocks = designerControl1.Items.OfType<NodeComponent>() .Where(node => !string.IsNullOrEmpty(node.Name)) .Select(node => string.Format("let {0} = {1}{2}", node.Name, newLine, generator.GenerateCode(node, newLine))); var viewer = new FormCodeViewer { Code = string.Join("\r\n", codeBlocks) }; viewer.Show(this); }