コード例 #1
0
        private void OK_Click(object sender, EventArgs e)
        {
            Psc.Molecule = QueryMolCtl.Molecule.Clone();
            Psc.Molecule.RemoveStructureCaption();             // remove any structure caption that may cause a problem

            try
            {
                if (None.Checked || Lex.IsNullOrEmpty(Psc.Molecule.PrimaryValue))                 // say none if checked or no structure
                {
                    Psc.SearchType = StructureSearchType.Unknown;
                }
                else if (SubStruct.Checked)
                {
                    SSOptions.GetValues(Psc);
                }
                else if (Similarity.Checked)
                {
                    SimOptions.GetValues(Psc);
                }
                else if (Full.Checked)
                {
                    FSOptions.GetValues(Psc);
                }
                else if (SmallWorld.Checked)
                {
                    SmallWorldOptions.GetValues(Psc);
                    UpdateAssociatedSmallWorldQueryColumns(Psc);
                }

                else
                {
                    throw new Exception("No recognized search type checked");                  // shouldn't happen
                }
                Psc.ConvertToQueryColumnCriteria(Qc);
            }

            catch (Exception ex)
            {
                MessageBoxMx.ShowError(ex.Message);
                return;
            }

            MoleculeSelectorControl.AddToMruList(QueryMolCtl, Psc.SearchType);

            DialogResult = DialogResult.OK;
            return;
        }
コード例 #2
0
        /// <summary>
        /// Display proper options subform or hide options if not showing
        /// based on the Psc settings
        /// </summary>

        void SetupOptions(bool initialSetup = false)
        {
            FormMetricsInfo fmi = WindowsHelper.GetFormMetrics(this);

            SetupDepth++;
            bool showOptions = ShowOptions;

            if (Psc.SearchType != StructureSearchType.Unknown)
            // && Psc.SearchType != StructureSearchType.SSS) // don't show SS options for now
            {
                ShowOptionsButton.Enabled = true;
            }

            else             // no options available
            {
                showOptions = false;
                ShowOptionsButton.Enabled = false;
            }

            ShowOptionsButton.ImageIndex = (showOptions ? 1 : 0);                                             // set proper ShowOptions Expand/Contract image button
            BottomDivider.Visible        = (showOptions || Psc.SearchType == StructureSearchType.SmallWorld); // line above OK/Cancel

            if (Psc.SearchType == StructureSearchType.Substructure)
            {
                FSOptions.Visible = SimOptions.Visible = SmallWorldOptions.Visible = PreviewPanel.Visible = false;
                SSOptions.Visible = showOptions;

                int optHeight = showOptions ? SSOptions.Height + BottomCtlsHeight : 0;
                Size = new Size(InitialFormSize.Width, InitialFormSize.Height + optHeight);
                SSOptions.Setup(Psc);
            }

            else if (Psc.SearchType == StructureSearchType.MolSim)
            {
                SSOptions.Visible  = FSOptions.Visible = SmallWorldOptions.Visible = PreviewPanel.Visible = false;
                SimOptions.Visible = showOptions;
                int optHeight = showOptions ? SimOptions.Height + BottomCtlsHeight : 0;
                Size = new Size(InitialFormSize.Width, InitialFormSize.Height + optHeight);
                SimOptions.Setup(Psc);
            }

            else if (Psc.SearchType == StructureSearchType.FullStructure)
            {
                SSOptions.Visible = SimOptions.Visible = SmallWorldOptions.Visible = PreviewPanel.Visible = false;
                FSOptions.Visible = showOptions;

                int optHeight = showOptions ? FSOptions.Height + BottomCtlsHeight : 0;
                Size = new Size(InitialFormSize.Width, InitialFormSize.Height + optHeight);
                FSOptions.Setup(Psc);
            }

            else if (Psc.SearchType == StructureSearchType.SmallWorld)
            {
                SSOptions.Visible         = FSOptions.Visible = SimOptions.Visible = false;
                SmallWorldOptions.Visible = showOptions;

                SmallWorldOptions.CriteriaStructureForm = this;                 // link SmallWorldOptions to us

                SmallWorldPredefinedParameters swp = Psc.SmallWorldParameters;

                SmallWorldOptions.Setup(swp);

                Size = SmallWorldSize;                 // set form size same as last time

                if (!PreviewPanel.Visible)             // if preview not visible then adjust size and show
                {
                    PreviewCtl.InitializeView();

                    Size cs = this.ClientRectangle.Size;
                    PreviewPanel.Width   = cs.Width - PreviewPanel.Left - 2;
                    PreviewPanel.Height  = BottomDivider.Top - PreviewPanel.Top + 2;
                    PreviewPanel.Visible = true;
                }

                if (initialSetup)
                {
                    SmallWorldOptions.StartInitialQueryExecution();                               // start search if initial setup
                }
            }

            else
            {
                Size = InitialFormSize;              // no search type
            }
            Refresh();

            SetupDepth--;
            return;
        }