Example #1
0
        public bool ChangeSettings(Point topLeft)
        {
            string module = $"{_product}.{_class}.{MethodBase.GetCurrentMethod().Name}()";

            try
            {
                Telemetry.Write(module, "Verbose", "Called");
                _searcherOptions = new ChEBIOptions(SettingsPath);

                ChEBISettings settings = new ChEBISettings();
                settings.Telemetry = Telemetry;
                settings.TopLeft   = topLeft;

                ChEBIOptions tempOptions = _searcherOptions.Clone();
                settings.SettingsPath    = SettingsPath;
                settings.SearcherOptions = tempOptions;

                DialogResult dr = settings.ShowDialog();
                if (dr == DialogResult.OK)
                {
                    _searcherOptions = tempOptions.Clone();
                }
                settings.Close();
                settings = null;
            }
            catch (Exception ex)
            {
                new ReportError(Telemetry, TopLeft, module, ex).ShowDialog();
            }
            return(true);
        }
Example #2
0
        public DialogResult Search()
        {
            string module = $"{_product}.{_class}.{MethodBase.GetCurrentMethod().Name}()";

            try
            {
                _searcherOptions = new ChEBIOptions(SettingsPath);

                using (new WaitCursor())
                {
                    var searcher = new SearchChEBI();
                    searcher.TopLeft      = TopLeft;
                    searcher.Telemetry    = Telemetry;
                    searcher.SettingsPath = SettingsPath;
                    searcher.UserOptions  = _searcherOptions;
                    using (new WaitCursor(Cursors.Default))
                    {
                        DialogResult dr = searcher.ShowDialog();
                        if (dr == DialogResult.OK)
                        {
                            Properties = new Dictionary <string, string>();
                            Telemetry.Write(module, "Information", $"Importing Id {searcher.ChebiId}");
                            Cml = searcher.Cml;
                        }

                        return(dr);
                    }
                }
            }
            catch (Exception ex)
            {
                new ReportError(Telemetry, TopLeft, module, ex).ShowDialog();
                return(DialogResult.Cancel);
            }
        }
Example #3
0
        public ChEBIOptions Clone()
        {
            ChEBIOptions clone = new ChEBIOptions();

            // Copy serialised properties
            clone.SetValuesFromCopy(this);

            clone.SettingsPath = SettingsPath;

            return(clone);
        }
Example #4
0
 private void SetValuesFromCopy(ChEBIOptions options)
 {
     ChEBIWebServiceUri = options.StripTrailingSlash(options.ChEBIWebServiceUri);
     DisplayOrder       = options.DisplayOrder;
     MaximumResults     = options.MaximumResults;
 }