Exemplo n.º 1
0
        /// <summary>
        /// Click function to open an external web site when clicking on a CID in a SmallWorld database display
        /// </summary>
        /// <param name="args"></param>

        public static void OpenUrlFromSmallWorldCid(
            string cid)
        {
            string[] px = { "PBCHM", "PDB" };

            RootTable rt = CompoundId.GetRootTableFromCid(cid);

            if (rt == null || Lex.IsUndefined(rt.CidUrl))
            {
                if (rt != null && Lex.Contains(rt.MetaTableName, MetaTable.PrimaryRootTable))
                {
                    RelatedCompoundsDialog.Show(cid);
                    return;
                }

                MessageBoxMx.ShowError("Unable to determine url link for compound Id: " + cid);
                return;
            }

            string url = rt.CidUrl;

            foreach (string p in px)             // remove unwanted URLs
            {
                if (Lex.StartsWith(cid, p))
                {
                    cid = cid.Substring(p.Length);
                }
            }

            url = Lex.Replace(url, "[CID]", cid);
            SystemUtil.StartProcess(url);
            return;
        }
Exemplo n.º 2
0
        /// <summary>
        /// Handle UI operations during tick of timer
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>

        private void Timer_Tick(object sender, EventArgs e)
        {
            if (ServiceFacade.ServiceFacade.InServiceCall)
            {
                return;                                                        // avoid multiplexing service calls that could cause problems
            }
            if (InTimer_Tick)
            {
                return;
            }
            InTimer_Tick = true;

            try
            {
                string txt = CompoundIdControl.Text;

                if (txt == PreviousInput)
                {
                    return;
                }
                if (DateTime.Now.Subtract(LastCompoundIdControlKeyDownTime).TotalSeconds < .5)
                {                 // wait for a pause in typing before doing retrieve
                    //SystemUtil.Beep(); // debug
                    return;
                }

                PreviousInput = txt;

                MetaTable  mt          = CompoundId.GetRootMetaTableFromCid(txt);
                string     cid         = CompoundId.Normalize(txt, mt);
                string     mtName      = mt.Name;
                MoleculeMx queryStruct = MoleculeUtil.SelectMoleculeForCid(cid, mt);
                RSM.StartSearchAndRetrievalOfRelatedStructures(mtName, cid, queryStruct, StructureSearchTypes);

                //Text = "Structures related to " + txt; // set form header

                InSetup = true;                 // set structure without triggering another search
                RelatedStructuresControl.MoleculeControl.Molecule = queryStruct;
                InSetup = false;
            }

            catch (Exception ex) { ex = ex; }
            finally { InTimer_Tick = false; }

#if false // code to handle either CID or structure input
            bool   userDefinedStructure = Lex.Eq(CurrentInput, "User Defined");
            string mtName = "";

            if (!userDefinedStructure)
            {
                CidMt       = CompoundId.GetRootTableFromCid(CurrentInput);
                mtName      = CidMt.Name;
                Cid         = CompoundId.Normalize(CurrentInput, CidMt);
                QueryStruct = MoleculeUtil.SelectChemicalStructureFromCid(Cid, CidMt);
                InSetup     = true;
                Text        = "Structures related to " + CurrentInput;
                ChemicalStructure.SetRendererStructure(SQuery, QueryStruct);
                InSetup = false;
            }

            else             // structure directly entered
            {
                if (!StructureChanged)
                {
                    InTimer_Tick = false;
                    return;
                }

                Cid              = SearchId.ToString();
                CidMt            = null;
                mtName           = "UserDefined";
                QueryStruct      = new ChemicalStructure(StructureFormat.MolFile, SQuery.MolfileString);
                StructureChanged = false;
            }
#endif
        }