Пример #1
0
        /// <summary>
        /// Retrieve a saved molecule and store in Renditor
        /// </summary>
        /// <param name="ctl"></param>

        public static void RetrieveSavedMolecule(MoleculeControl molCtl)
        {
            MoleculeMx cs;
            string     fileName = null;

            if (!UIMisc.ReadMoleculeFileDialog(out cs, out fileName))
            {
                return;
            }

            molCtl.SetupAndRenderMolecule(cs);
            molCtl.SetTemporaryMoleculeTag(Path.GetFileNameWithoutExtension(fileName));             // associate the file name in case saved as history/favorite
            return;
        }
Пример #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;
            }
        }