/// <summary> /// Select a MoleculeMx object for a compound id /// </summary> /// <param name="cid"></param> /// <param name="mt"></param> /// <returns></returns> public static MoleculeMx SelectMoleculeForCid( string cid, MetaTable mt = null) { MoleculeMx mol = null; Stopwatch sw = Stopwatch.StartNew(); mol = MoleculeCache.Get(cid); // see if molecule in cache if (mol != null) { return(mol); } if (ServiceFacade.UseRemoteServices) { string mtName = mt?.Name; Mobius.Services.Native.INativeSession nativeClient = ServiceFacade.CreateNativeSessionProxy(); Services.Native.NativeMethodTransportObject resultObject = ServiceFacade.InvokeNativeMethod(nativeClient, (int)Services.Native.ServiceCodes.MobiusCompoundUtilService, (int)Services.Native.ServiceOpCodes.MobiusCompoundUtilService.SelectMoleculeFromCid, new Services.Native.NativeMethodTransportObject(new object[] { cid, mtName })); // , setStereoChemistryComments ((System.ServiceModel.IClientChannel)nativeClient).Close(); if (resultObject == null) { return(null); } byte[] ba = resultObject.Value as byte[]; if (ba != null && ba.Length > 0) { MobiusDataType mdt = MobiusDataType.DeserializeBinarySingle(ba); mol = mdt as MoleculeMx; } } else { mol = QEL.MoleculeUtil.SelectMoleculeForCid(cid, mt); } if (MoleculeMx.IsDefined(mol)) { bool isUcdb = (mt != null && mt.Root.IsUserDatabaseStructureTable); // user compound database if (!isUcdb) { MoleculeCache.AddMolecule(cid, mol); // add to cache } } long ms = sw.ElapsedMilliseconds; return(mol); }
private void ViewMoleculeInNewWindowMenuItem_Click(object sender, EventArgs e) { int gri = MoleculeGrid.LastMouseDownRowIdx; if (gri < 0 || gri >= StructureList.Count) { return; } MoleculeListItem sli = StructureList[gri]; if (!MoleculeMx.IsDefined(sli.Molecule)) { return; } MoleculeViewer.ShowMolecule(sli.Molecule); return; }