private void EditCml_Click(object sender, EventArgs e) { string module = $"{_product}.{_class}.{MethodBase.GetCurrentMethod().Name}()"; try { if (!string.IsNullOrEmpty(_lastCml)) { using (EditorHost editorHost = new EditorHost(_lastCml, "CML")) { editorHost.ShowDialog(this); if (editorHost.DialogResult == DialogResult.OK) { HandleChangedCml(editorHost.OutputValue, "CML Editor result"); } } TopMost = true; TopMost = false; Activate(); } } catch (Exception exception) { _telemetry.Write(module, "Exception", $"Exception: {exception.Message}"); _telemetry.Write(module, "Exception(Data)", $"Exception: {exception}"); MessageBox.Show(exception.StackTrace, exception.Message); } }
private void EditWithAcme_Click(object sender, EventArgs e) { #if !DEBUG string module = $"{_product}.{_class}.{MethodBase.GetCurrentMethod().Name}()"; try { #endif if (!string.IsNullOrEmpty(_lastCml)) { using (EditorHost editorHost = new EditorHost(_lastCml, "ACME")) { editorHost.ShowDialog(this); if (editorHost.DialogResult == DialogResult.OK) { CMLConverter cc = new CMLConverter(); var clone = cc.Import(_lastCml); Debug.WriteLine( $"Pushing F: {clone.ConciseFormula} BL: {clone.MeanBondLength.ToString("#,##0.00")} onto Stack"); _undoStack.Push(clone); Model m = cc.Import(editorHost.OutputValue); m.Relabel(true); _lastCml = cc.Export(m); // Cause re-read of settings (in case they have changed) _editorOptions = new AcmeOptions(null); SetDisplayOptions(); RedoStack.SetOptions(_editorOptions); UndoStack.SetOptions(_editorOptions); ShowChemistry($"Edited {m.ConciseFormula}", m); } } TopMost = true; TopMost = false; Activate(); } #if !DEBUG } catch (Exception exception) { _telemetry.Write(module, "Exception", $"Exception: {exception.Message}"); _telemetry.Write(module, "Exception(Data)", $"Exception: {exception}"); MessageBox.Show(exception.StackTrace, exception.Message); } #endif }
private void EditLabels_Click(object sender, EventArgs e) { string module = $"{_product}.{_class}.{MethodBase.GetCurrentMethod().Name}()"; #if !DEBUG try #endif { if (!string.IsNullOrEmpty(_lastCml)) { using (EditorHost editorHost = new EditorHost(_lastCml, "LABELS")) { editorHost.ShowDialog(this); if (editorHost.DialogResult == DialogResult.OK) { CMLConverter cc = new CMLConverter(); var clone = cc.Import(_lastCml); Debug.WriteLine( $"Pushing F: {clone.ConciseFormula} BL: {clone.MeanBondLength.ToString("#,##0.00")} onto Stack"); _undoStack.Push(clone); Model m = cc.Import(editorHost.OutputValue); m.Relabel(true); _lastCml = cc.Export(m); ShowChemistry($"Edited {m.ConciseFormula}", m); } } TopMost = true; TopMost = false; Activate(); } } #if !DEBUG catch (Exception exception) { _telemetry.Write(module, "Exception", $"Exception: {exception.Message}"); _telemetry.Write(module, "Exception(Data)", $"Exception: {exception}"); MessageBox.Show(exception.StackTrace, exception.Message); } #endif }