private void SelectSearcher_OnSelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            string module = $"{_product}.{_class}.{MethodBase.GetCurrentMethod().Name}()";

            if (!_loading)
            {
                Globals.Chem4WordV3.Telemetry.Write(module, "Action", "Triggered");

                PlugInComboItem pci = SelectSearcherPlugIn.SelectedItem as PlugInComboItem;
                SelectedSearcherDescription.Text = pci?.Description;
                IChem4WordSearcher searcher = Globals.Chem4WordV3.GetSearcherPlugIn(pci.Name);
                SelectedSearcherSettings.IsEnabled = searcher.HasSettings;
                Dirty = true;
            }
        }
        private void LoadSettings()
        {
            string module = $"{_product}.{_class}.{MethodBase.GetCurrentMethod().Name}()";

            #region Editor Plug-Ins Tab

            SelectEditorPlugIn.Items.Clear();
            SelectRendererPlugIn.Items.Clear();
            SelectSearcherPlugIn.Items.Clear();
            SelectedEditorSettings.IsEnabled   = false;
            SelectedRendererSettings.IsEnabled = false;
            SelectedSearcherSettings.IsEnabled = false;

            string selectedEditor = SystemOptions.SelectedEditorPlugIn;

            foreach (IChem4WordEditor editor in Globals.Chem4WordV3.Editors)
            {
                PlugInComboItem pci = new PlugInComboItem()
                {
                    Name        = editor.Name,
                    Description = editor.Description
                };
                int item = SelectEditorPlugIn.Items.Add(pci);

                if (editor.Name.Equals(selectedEditor))
                {
                    SelectedEditorSettings.IsEnabled     = editor.HasSettings;
                    SelectedEditorPlugInDescription.Text = editor.Description;
                    SelectEditorPlugIn.SelectedIndex     = item;
                }
            }

            string selectedRenderer = SystemOptions.SelectedRendererPlugIn;
            foreach (IChem4WordRenderer renderer in Globals.Chem4WordV3.Renderers)
            {
                PlugInComboItem pci = new PlugInComboItem()
                {
                    Name        = renderer.Name,
                    Description = renderer.Description
                };
                int item = SelectRendererPlugIn.Items.Add(pci);
                if (renderer.Name.Equals(selectedRenderer))
                {
                    SelectedRendererSettings.IsEnabled = renderer.HasSettings;
                    SelectedRendererDescription.Text   = renderer.Description;
                    SelectRendererPlugIn.SelectedIndex = item;
                }
            }

            foreach (IChem4WordSearcher searcher in Globals.Chem4WordV3.Searchers.OrderBy(s => s.DisplayOrder))
            {
                PlugInComboItem pci = new PlugInComboItem()
                {
                    Name        = searcher.Name,
                    Description = searcher.Description
                };
                int item = SelectSearcherPlugIn.Items.Add(pci);
                if (SelectSearcherPlugIn.Items.Count == 1)
                {
                    SelectedSearcherSettings.IsEnabled = searcher.HasSettings;
                    SelectedSearcherDescription.Text   = searcher.Description;
                    SelectSearcherPlugIn.SelectedIndex = item;
                }
            }

            #endregion Editor Plug-Ins Tab

            #region Telemetry Tab

            string betaValue = Globals.Chem4WordV3.ThisVersion.Root?.Element("IsBeta")?.Value;
            bool   isBeta    = betaValue != null && bool.Parse(betaValue);

            TelemetryEnabled.IsChecked = isBeta || SystemOptions.TelemetryEnabled;
            TelemetryEnabled.IsEnabled = !isBeta;
            if (!isBeta)
            {
                BetaInformation.Visibility = Visibility.Hidden;
            }

            #endregion Telemetry Tab

            #region General Tab

            ApplyDefaultOnImportFile.IsChecked    = SystemOptions.SetBondLengthOnImportFromFile;
            ApplyDefaultOnImportSearch.IsChecked  = SystemOptions.SetBondLengthOnImportFromSearch;
            ApplyDefaultOnImportLibrary.IsChecked = SystemOptions.SetBondLengthOnImportFromLibrary;

            RemoveExplicitOnImportFile.IsChecked    = SystemOptions.RemoveExplicitHydrogensOnImportFromFile;
            RemoveExplicitOnImportSearch.IsChecked  = SystemOptions.RemoveExplicitHydrogensOnImportFromSearch;
            RemoveExplicitOnImportLibrary.IsChecked = SystemOptions.RemoveExplicitHydrogensOnImportFromLibrary;

            foreach (var item in DefaultBondLength.Items)
            {
                var cbi = item as ComboBoxItem;
                if (int.Parse(cbi.Tag as string) == SystemOptions.BondLength)
                {
                    DefaultBondLength.SelectedItem = item;
                    break;
                }
            }

            #endregion General Tab
        }
Esempio n. 3
0
        private void LoadSettings()
        {
            string module = $"{_product}.{_class}.{MethodBase.GetCurrentMethod().Name}()";

            #region Editor Plug Ins Tab

            SelectEditorPlugIn.Items.Clear();
            SelectRendererPlugIn.Items.Clear();
            SelectSearcherPlugIn.Items.Clear();
            SelectedEditorSettings.IsEnabled   = false;
            SelectedRendererSettings.IsEnabled = false;
            SelectedSearcherSettings.IsEnabled = false;

            Version browser = null;
            try
            {
                browser = new Forms.WebBrowser().Version;
            }
            catch
            {
                browser = null;
            }

            if (SystemOptions.SelectedEditorPlugIn.Equals(Constants.DefaultEditorPlugIn800))
            {
                if (browser?.Major < Constants.ChemDoodleWeb800MinimumBrowserVersion)
                {
                    SystemOptions.SelectedEditorPlugIn = Constants.DefaultEditorPlugIn702;
                }
            }

            string selectedEditor = SystemOptions.SelectedEditorPlugIn;

            foreach (IChem4WordEditor editor in Globals.Chem4WordV3.Editors)
            {
                bool add = !(editor.Name.Equals(Constants.DefaultEditorPlugIn800) &&
                             browser?.Major < Constants.ChemDoodleWeb800MinimumBrowserVersion);

                if (add)
                {
                    PlugInComboItem pci = new PlugInComboItem()
                    {
                        Name        = editor.Name,
                        Description = editor.Description
                    };
                    int item = SelectEditorPlugIn.Items.Add(pci);

                    if (editor.Name.Equals(selectedEditor))
                    {
                        SelectedEditorSettings.IsEnabled     = editor.HasSettings;
                        SelectedEditorPlugInDescription.Text = editor.Description;
                        SelectEditorPlugIn.SelectedIndex     = item;
                    }
                }
            }

            string selectedRenderer = SystemOptions.SelectedRendererPlugIn;
            foreach (IChem4WordRenderer renderer in Globals.Chem4WordV3.Renderers)
            {
                PlugInComboItem pci = new PlugInComboItem()
                {
                    Name        = renderer.Name,
                    Description = renderer.Description
                };
                int item = SelectRendererPlugIn.Items.Add(pci);
                if (renderer.Name.Equals(selectedRenderer))
                {
                    SelectedRendererSettings.IsEnabled = renderer.HasSettings;
                    SelectedRendererDescription.Text   = renderer.Description;
                    SelectRendererPlugIn.SelectedIndex = item;
                }
            }

            foreach (IChem4WordSearcher searcher in Globals.Chem4WordV3.Searchers.OrderBy(s => s.DisplayOrder))
            {
                PlugInComboItem pci = new PlugInComboItem()
                {
                    Name        = searcher.Name,
                    Description = searcher.Description
                };
                int item = SelectSearcherPlugIn.Items.Add(pci);
                if (SelectSearcherPlugIn.Items.Count == 1)
                {
                    SelectedSearcherSettings.IsEnabled = searcher.HasSettings;
                    SelectedSearcherDescription.Text   = searcher.Description;
                    SelectSearcherPlugIn.SelectedIndex = item;
                }
            }

            #endregion Editor Plug Ins Tab

            #region Telemetry Tab

            string betaValue = Globals.Chem4WordV3.ThisVersion.Root?.Element("IsBeta")?.Value;
            bool   isBeta    = betaValue != null && bool.Parse(betaValue);

            TelemetryEnabled.IsChecked = isBeta || SystemOptions.TelemetryEnabled;
            TelemetryEnabled.IsEnabled = !isBeta;
            if (!isBeta)
            {
                BetaInformation.Visibility = Visibility.Hidden;
            }

            #endregion Telemetry Tab
        }