Exemple #1
0
        void ListItemSelectedCallback(MoleculeListItem sli)
        {
            if (MolEditorCtl == null)
            {
                return;
            }

            if (sli == null)
            {
                DialogResult = DialogResult.Cancel;
                return;
            }

            MoleculeMx mol = sli.Molecule;

            MolEditorCtl.SetPrimaryTypeAndValue(mol.PrimaryFormat, mol.PrimaryValue);
            MolEditorCtl.TagString = sli.Name + "\t" + sli.Molecule.PrimaryValue;             // store name to use if molecule is unchanged
            DialogResult           = DialogResult.OK;
        }
Exemple #2
0
        /// <summary>
        /// Retrieve an existing molecule and store in MoleculeControl
        /// </summary>
        /// <param name="molCtl"></param>
        /// <param name="mc"></param>

        public static void RetrieveDatabaseStructure(
            MoleculeControl molCtl,
            MetaColumn mc)
        {
            MetaTable mt = null;
            string    cid = "", txt;

            txt = "compound id";
            if (mc != null)
            {
                mt   = mc.MetaTable;
                txt += " (" + mt.KeyMetaColumn.Label + ", etc.)";
            }

            txt = "Enter the " + txt + " that you want to use as a model.";

            while (true)
            {
                cid = InputCompoundId.Show(txt, "Retrieve Molecule from Database", cid, mt);
                if (String.IsNullOrEmpty(cid))
                {
                    return;
                }

                string molString = InputCompoundId.Molecule.PrimaryValue;
                if (String.IsNullOrEmpty(molString))
                {
                    MessageBoxMx.ShowError("Compound number is not in the database, try again.");
                    continue;
                }

                MoleculeMx cs = InputCompoundId.Molecule;

                cs.RemoveStructureCaption();                                      // remove any caption
                molCtl.SetPrimaryTypeAndValue(cs.PrimaryFormat, cs.PrimaryValue); // set mol
                molCtl.SetTemporaryMoleculeTag(cid);                              // associate the cid in case saved as history/favorite
                break;
            }
        }