private void OnWpfButtonClick(object sender, EventArgs e) { string module = $"{_product}.{_class}.{MethodBase.GetCurrentMethod().Name}()"; WpfEventArgs args = (WpfEventArgs)e; if (args.Button.ToUpper().Equals("OK")) { DialogResult = DialogResult.OK; CMLConverter cc = new CMLConverter(); JSONConverter jc = new JSONConverter(); Model.Model model = jc.Import(args.OutputValue); OutputValue = cc.Export(model); } if (args.Button.ToUpper().Equals("CANCEL")) { DialogResult = DialogResult.Cancel; OutputValue = ""; } WpfChemDoodle editor = elementHost1.Child as WpfChemDoodle; if (editor != null) { editor.OnButtonClick -= OnWpfButtonClick; editor = null; } Hide(); }
private void EditorHost_Load(object sender, EventArgs e) { string module = $"{_product}.{_class}.{MethodBase.GetCurrentMethod().Name}()"; Cursor.Current = Cursors.WaitCursor; if (TopLeft.X != 0 && TopLeft.Y != 0) { Left = (int)TopLeft.X; Top = (int)TopLeft.Y; } CMLConverter cc = new CMLConverter(); JSONConverter jc = new JSONConverter(); Model.Model model = cc.Import(_cml); WpfChemDoodle editor = new WpfChemDoodle(); editor.Telemetry = Telemetry; editor.ProductAppDataPath = ProductAppDataPath; editor.UserOptions = UserOptions; editor.TopLeft = TopLeft; editor.StructureJson = jc.Export(model); editor.IsSingleMolecule = model.Molecules.Count == 1; editor.AverageBondLength = model.MeanBondLength; editor.InitializeComponent(); elementHost1.Child = editor; editor.OnButtonClick += OnWpfButtonClick; this.Show(); Application.DoEvents(); }