/// <summary> /// Display any structure and related compounds for input string or /// Matching database contents /// </summary> /// <param name="inputString"></param> /// <param name="showRelatedCompounds"></param> public void ShowQuickSearchPopup( string inputString, bool updateRelatedCompounds) { string extCid = "", tok, tok2; MRUEdit clc = CommandLineControl; // be sure popup is properly positioned if (clc.FindForm() == SessionManager.Instance.ShellForm) // slightly different position for Shell form that other forms { Left = clc.Left; Top = clc.Bottom; } else { Point p = clc.PointToScreen(new Point(0, clc.Bottom)); // get screen coord for upper left corner of popup Point p2 = this.Parent.PointToClient(p); // convert screen coord back to relative Left = p2.X; // position below input control Top = p2.Y; } // See if input matches structure Molecule = null; if (StructurePopupEnabled && !String.IsNullOrEmpty(inputString)) { Cid = CompoundId.Normalize(inputString); extCid = CompoundId.Format(Cid); CidMt = CompoundId.GetRootMetaTableFromCid(Cid); Molecule = MoleculeUtil.SelectMoleculeForCid(Cid, CidMt); RelatedDataButton.Enabled = (CidMt != null && Lex.Eq(CidMt.Root.Name, MetaTable.PrimaryRootTable)); AllDataButtonStb.Enabled = QbUtil.IsMdbAssayDataViewAvailable(CidMt); } if (Molecule != null) { string txt = extCid; if (CidMt != null) { txt = CidMt.KeyMetaColumn.Label + " " + txt; } if (Lex.IsUndefined(Molecule.Id)) { Molecule.Id = txt; } if (SS.I.FindRelatedCpdsInQuickSearch) { txt += " and Related Structures"; } StructurePanel.Text = txt; RelatedStructuresControl.MoleculeControl.Molecule = Molecule; if (SS.I.FindRelatedCpdsInQuickSearch) { Width = InitialStructurePanelWidth; // assure correct width } else { Width = InitialStructurePanelWidthWithoutRelatedStructureOptions; RSM.ClearSearchStatus(); } if (!StructurePanel.Visible) // if structure not showing then set height to initial height { Height = InitialStructurePanelHeight; } StructurePanel.Location = new Point(0, 0); StructurePanel.Visible = true; //Size = StructurePanel.Size; ListControl.Visible = false; Visible = true; RenderId++; if (updateRelatedCompounds) { UpdateRelatedCidsDisplay(CidMt, Cid, Molecule, RenderId); } return; } // See if input matches database contents tree else if (ContentsPopupEnabled) { DoQuickSearchAndDisplayOfContentsTree(inputString); return; } HideQuickSearchPopup(); return; }
void Initialize2( MRUEdit clc, Form parentForm, ContentsTreeControl contentsTree, bool newPopup) { QuickSearchPopup qsp = this; // debug //if (newPopup) // just created? if (!Initialized) { Visible = false; //Width = 236; // set proper size //Height = 186; Point p = clc.PointToScreen(new Point(0, clc.Bottom)); Point p2 = parentForm.PointToClient(p); Left = p.X; // position below input control Top = p.Y + clc.Height * 2; BringToFront(); ContentsTree = contentsTree; RelatedStructuresControl rsp = RelatedStructuresControl; InitialStructurePanelWidth = StructurePanel.Width; //rsp.Width + 12; // initial StructurePanel width InitialStructurePanelWidthWithoutRelatedStructureOptions = rsp.MoleculeControl.Right + 10; //InitialStructurePanelWidth = 400; // debug InitialStructurePanelHeight = rsp.Top + rsp.MoleculeControl.Height + 15; // initial StructurePanel height to just below structure box StructurePanel.Dock = DockStyle.Fill; OtherCidsList.Visible = false; MoleculeControl strBox = RelatedStructuresControl.MoleculeControl; // make structure box wider to the left int newBoxLeft = 4; int dx = strBox.Left - newBoxLeft; // amount to widen structure box int w2 = strBox.Width + dx; int h2 = strBox.Height; RSM = new RelatedStructureControlManager(); RelatedStructuresControl.RSM = RSM; RSM.RSC = RelatedStructuresControl; RSM.HideUndefinedStructureList = true; // don't show structure panel until after search complete RelatedStructuresControl.RenderSearchResultsCompleteCallBack = RenderSearchResultsCompleteCallBack; RelatedStructuresControl.SetupCheckmarks(); Initialized = true; } CommandLineControl = clc; // associated command line comtrol clc.GotFocus += CommandLine_GotFocus; clc.KeyDown += CommandLine_KeyDown; // add command line events for us clc.KeyUp += CommandLine_KeyUp; clc.PreviewKeyDown += CommandLine_PreviewKeyDown; if (!Timer.Enabled) { Timer.Enabled = true; PreviousInput = ""; // need to clear to get redisplay of structure } return; }