示例#1
0
        /// <summary>
        /// AddToFavoritesList
        /// </summary>
        /// <param name="molEditorCtl"></param>
        /// <param name="searchType"></param>

        public static void AddToFavoritesList(
            MoleculeControl molEditorCtl,
            StructureSearchType searchType)
        {
            MoleculeListItem sli = null;
            DialogResult     dr;

            MoleculeMx mol = molEditorCtl.Molecule;

            if (MoleculeMx.IsUndefined(mol))
            {
                return;
            }

            mol = mol.Clone();             // make a copy for the list

            sli = FindStructure(mol, GetFavoriteStructuresList());
            if (sli != null)
            {
                dr = MessageBoxMx.Show("The current molecule already exists in Favorites list under the name: " + sli.Name + "\r\n" +
                                       "Do you still want the add the current query molecule to the Favorites list?", "Molecule already in Favorites", MessageBoxButtons.YesNoCancel);

                if (dr != DialogResult.Yes)
                {
                    return;
                }
            }

            string name = molEditorCtl.GetTemporaryStructureTag();

            name = InputBoxMx.Show("Enter the name that you want to assign to the molecule", "Enter Name", name);
            if (Lex.IsUndefined(name))
            {
                return;
            }

            sli              = new MoleculeListItem();
            sli.Name         = name;
            sli.Molecule     = mol;
            sli.UpdateDate   = DateTime.Now;
            sli.MoleculeType = StructureSearchTypeUtil.StructureSearchTypeToExternalName(searchType);
            FavoritesList.ItemList.Insert(0, sli);

            SaveStructureList(FavoritesList, FavoritesPreferencesParmName);
            return;
        }
示例#2
0
        /// <summary>
        /// AddToMruList
        /// </summary>
        /// <param name="molEditorCtl"></param>
        /// <param name="searchType"></param>

        public static void AddToMruList(
            MoleculeControl molEditorCtl,
            StructureSearchType searchType)
        {
            MoleculeListItem sli = null;
            DialogResult     dr;

            MoleculeMx mol = molEditorCtl.Molecule;

            if (Lex.IsUndefined(mol.PrimaryValue))
            {
                return;
            }

            mol = mol.Clone();             // make a copy of the mol

            sli = FindStructure(mol, GetMruMoleculesList());
            if (sli != null)
            {
                MruList.ItemList.Remove(sli);
            }

            sli              = new MoleculeListItem();
            sli.Name         = molEditorCtl.GetTemporaryStructureTag();     // get any associated pre-edit mol name
            sli.Molecule     = mol;
            sli.UpdateDate   = DateTime.Now;
            sli.MoleculeType = StructureSearchTypeUtil.StructureSearchTypeToExternalName(searchType);
            MruList.ItemList.Insert(0, sli);

            while (MruList.Count > MaxMruItems)
            {
                MruList.ItemList.RemoveAt(MaxMruItems - 1);
            }

            SaveStructureList(MruList, MruPreferencesParmName);
            return;
        }