public DialogResult Edit() { DialogResult dialogResult = DialogResult.Cancel; string module = $"{_product}.{_class}.{MethodBase.GetCurrentMethod().Name}()"; try { Telemetry.Write(module, "Verbose", "Called"); using (EditorHost host = new EditorHost(Cml)) { host.TopLeft = TopLeft; DialogResult showDialog = host.ShowDialog(); if (showDialog == DialogResult.OK) { dialogResult = showDialog; Cml = host.OutputValue; } host.Close(); } } catch (Exception ex) { new ReportError(Telemetry, TopLeft, module, ex).ShowDialog(); } return(dialogResult); }
public DialogResult Edit() { DialogResult result = DialogResult.Cancel; string module = $"{_product}.{_class}.{MethodBase.GetCurrentMethod().Name}()"; try { Telemetry.Write(module, "Verbose", "Called"); if (HasSettings) { LoadSettings(); } // Strip off Formulae and ChemicalNames as we don't edit them here CMLConverter cmlConverter = new CMLConverter(); Model.Model model = cmlConverter.Import(Cml); foreach (Molecule molecule in model.Molecules) { molecule.ChemicalNames.Clear(); molecule.Formulas.Clear(); molecule.ConciseFormula = ""; } EditorHost host = new EditorHost(cmlConverter.Export(model)); host.TopLeft = TopLeft; host.ShowDialog(); result = host.Result; Cml = host.OutputValue; host.Close(); host.Dispose(); } catch (Exception ex) { new ReportError(Telemetry, TopLeft, module, ex).ShowDialog(); } return(result); }