Esempio n. 1
0
        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();
        }
Esempio n. 2
0
        private void OnWpfButtonClick(object sender, EventArgs e)
        {
            WpfEventArgs args = (WpfEventArgs)e;

            switch (args.Button.ToLower())
            {
            case "ok":
                DialogResult = DialogResult.OK;
                SettingsControl sc = elementHost1.Child as SettingsControl;
                if (sc != null)
                {
                    SystemOptions = sc.SystemOptions;
                    SaveChanges();
                    sc.Dirty = false;
                    Hide();
                }
                break;

            case "cancel":
                DialogResult  = DialogResult.Cancel;
                _closedInCode = true;
                Hide();
                break;
            }
        }
        private void Save_OnClick(object sender, RoutedEventArgs e)
        {
            string module = $"{_product}.{_class}.{MethodBase.GetCurrentMethod().Name}()";

            // Copy current model values to options before saving
            AcmeOptions.BondLength           = (int)SettingsModel.CurrentBondLength;
            AcmeOptions.ShowMoleculeGrouping = SettingsModel.ShowMoleculeGroups;
            AcmeOptions.ShowHydrogens        = SettingsModel.ShowImplicitHydrogens;
            AcmeOptions.ColouredAtoms        = SettingsModel.ShowAtomsInColour;
            AcmeOptions.ShowCarbons          = SettingsModel.ShowAllCarbonAtoms;

            AcmeOptions.Save();
            if (AcmeOptions.Errors.Any())
            {
                Telemetry.Write(module, "Exception", string.Join(Environment.NewLine, AcmeOptions.Errors));
                AcmeOptions.Errors = new List <string>();
            }
            AcmeOptions.Dirty = false;

            WpfEventArgs args = new WpfEventArgs();

            args.Button      = "SAVE";
            args.OutputValue = "";
            OnButtonClick?.Invoke(this, args);
        }
        private void Cancel_OnClick(object sender, RoutedEventArgs e)
        {
            AcmeOptions.Dirty = false;
            WpfEventArgs args = new WpfEventArgs();

            args.Button      = "CANCEL";
            args.OutputValue = "";
            OnButtonClick?.Invoke(this, args);
        }
Esempio n. 5
0
        private void button_Click(object sender, RoutedEventArgs e)
        {
            WpfEventArgs args = new WpfEventArgs();

            args.OutputValue = "Two is done !";
            args.Button      = "OK";

            if (OnOkButtonClick != null)
            {
                OnOkButtonClick(this, args);
            }
        }
        private void UcSettingsOnOnButtonClick(object sender, WpfEventArgs e)
        {
            if (e.Button.Equals("CANCEL"))
            {
                Close();
            }

            if (e.Button.Equals("SAVE"))
            {
                Close();
            }
        }
        private void CancelButton_OnClick(object sender, RoutedEventArgs e)
        {
            string module = $"{_product}.{_class}.{MethodBase.GetCurrentMethod().Name}()";

            Globals.Chem4WordV3.Telemetry.Write(module, "Action", "Triggered");

            WpfEventArgs args = new WpfEventArgs();

            args.Button      = "Cancel";
            args.OutputValue = "";

            OnButtonClick?.Invoke(this, args);
        }
Esempio n. 8
0
        private void UsOnOnButtonClick(object sender, WpfEventArgs e)
        {
            if (e.Button.Equals("CANCEL"))
            {
                Close();
            }

            if (e.Button.Equals("SAVE"))
            {
                DialogResult = DialogResult.OK;
                Close();
            }
        }
Esempio n. 9
0
        private void Save_OnClick(object sender, RoutedEventArgs e)
        {
            // Copy current model values to options before saving
            Options.BondLength         = (int)SettingsModel.CurrentBondLength;
            Options.ShowMoleculeGroups = SettingsModel.ShowMoleculeGroups;
            FileUtils.SaveAcmeSettings(Options, Telemetry, TopLeft);
            Options.Dirty = false;

            WpfEventArgs args = new WpfEventArgs();

            args.Button      = "SAVE";
            args.OutputValue = "";
            OnButtonClick?.Invoke(this, args);
        }
Esempio n. 10
0
        private void Cancel_OnClick(object sender, RoutedEventArgs e)
        {
            string module = $"{_product}.{_class}.{MethodBase.GetCurrentMethod().Name}()";

            try
            {
                WpfEventArgs args = new WpfEventArgs();
                args.OutputValue = "";
                args.Button      = "Cancel";

                OnButtonClick?.Invoke(this, args);
            }
            catch (Exception ex)
            {
                new ReportError(Telemetry, TopLeft, module, ex).ShowDialog();
            }
        }
Esempio n. 11
0
        private void Ok_OnClick(object sender, RoutedEventArgs e)
        {
            string module = $"{_product}.{_class}.{MethodBase.GetCurrentMethod().Name}()";

            try
            {
                if (!_loading)
                {
                    if (_saveSettings)
                    {
                        SaveSettings();
                    }

                    WpfEventArgs args = new WpfEventArgs();

                    // Set defaults if fetch fails
                    args.OutputValue = "";
                    args.Button      = "Cancel";

                    object obj = ExecuteJavaScript("GetJSON");
                    if (obj != null)
                    {
                        string mol = obj.ToString();
                        if (!string.IsNullOrEmpty(mol))
                        {
                            args.OutputValue = mol;
                            args.Button      = "OK";

                            OnButtonClick?.Invoke(this, args);
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                new ReportError(Telemetry, TopLeft, module, ex).ShowDialog();
            }
        }
Esempio n. 12
0
 private void AcmeEditorOnFeedbackChange(object sender, WpfEventArgs e)
 {
     MessageFromWpf.Text = e.OutputValue;
 }
Esempio n. 13
0
 private void ActiveViewModelOnFeedbackChange(object sender, WpfEventArgs e)
 {
     OnFeedbackChange?.Invoke(this, e);
 }