/// <summary> /// Constructor /// </summary> public CriteriaStructure() { SetupDepth++; InitializeComponent(); if (SystemUtil.InDesignMode) { return; } //Ensure the correct BorderWidth and TitleBarHeight are calculated so that the form is the correct height nwr 3/1/2019 ClientSize = new Size(Size.Width - 6, Size.Height - 40); // Calulate and save initial form size and location information FormMetricsInfo fmi = WindowsHelper.GetFormMetrics(this); QueryMolCtl.AllowEditing = true; int pad = QueryMolCtl.Left; // left side padding int cw = QueryMolCtl.Width + pad * 2; // client width with no rt-side search results preview panel int fw = cw + fmi.BorderWidth * 2; // associated form width int ch = fmi.ClientSize.Height + (RetrieveModel.Top - OK.Top); // client height without a search options panel int fh = ch + fmi.TitleBarHeight + fmi.BorderWidth * 2; // associated form height InitialFormSize = new Size(fw, fh); BottomCtlsHeight = fmi.ClientSize.Height - BottomDivider.Top; Screen screen = Screen.PrimaryScreen; // calc initial size for form with SmallWorld search selected int swWidth = 1000; // predefined width to include preview results if (swWidth > screen.WorkingArea.Width) { swWidth = screen.WorkingArea.Width; } int swHeight = InitialFormSize.Height + SmallWorldOptions.Height + BottomCtlsHeight; if (swHeight > screen.WorkingArea.Height) { swHeight = screen.WorkingArea.Height; } SmallWorldSize = new Size(swWidth, swHeight); Size = InitialFormSize; // set initial form size Location = WindowsHelper.GetCenteredScreenLocation(SmallWorldSize); // set location of form based on SmallWorld form size PreviewPanel.Anchor = AnchorStyles.Left | AnchorStyles.Top | AnchorStyles.Right | AnchorStyles.Bottom; PreviewCtl.BorderStyle = BorderStyle.None; PreviewCtl.Dock = DockStyle.Fill; // dock ctl within PreviewPanel SSOptions.BorderStyle = BorderStyle.None; SSOptions.Location = SmallWorldOptions.Location; // use SmallWorld locate other option controls SimOptions.BorderStyle = BorderStyle.None; SimOptions.Location = SmallWorldOptions.Location; FSOptions.BorderStyle = BorderStyle.None; FSOptions.Location = SmallWorldOptions.Location; SmallWorldOptions.BorderStyle = BorderStyle.None; // Hide SmallWorld option if not permitted for this user if (!SmallWorldIsAvailableForUser) { SmallWorld.Visible = false; None.Location = SmallWorld.Location; } SetupDepth--; return; }
/// <summary> /// Display proper options subform or hide options if not showing /// based on the Psc settings /// </summary> void SetupOptions(bool initialSetup = false) { FormMetricsInfo fmi = WindowsHelper.GetFormMetrics(this); SetupDepth++; bool showOptions = ShowOptions; if (Psc.SearchType != StructureSearchType.Unknown) // && Psc.SearchType != StructureSearchType.SSS) // don't show SS options for now { ShowOptionsButton.Enabled = true; } else // no options available { showOptions = false; ShowOptionsButton.Enabled = false; } ShowOptionsButton.ImageIndex = (showOptions ? 1 : 0); // set proper ShowOptions Expand/Contract image button BottomDivider.Visible = (showOptions || Psc.SearchType == StructureSearchType.SmallWorld); // line above OK/Cancel if (Psc.SearchType == StructureSearchType.Substructure) { FSOptions.Visible = SimOptions.Visible = SmallWorldOptions.Visible = PreviewPanel.Visible = false; SSOptions.Visible = showOptions; int optHeight = showOptions ? SSOptions.Height + BottomCtlsHeight : 0; Size = new Size(InitialFormSize.Width, InitialFormSize.Height + optHeight); SSOptions.Setup(Psc); } else if (Psc.SearchType == StructureSearchType.MolSim) { SSOptions.Visible = FSOptions.Visible = SmallWorldOptions.Visible = PreviewPanel.Visible = false; SimOptions.Visible = showOptions; int optHeight = showOptions ? SimOptions.Height + BottomCtlsHeight : 0; Size = new Size(InitialFormSize.Width, InitialFormSize.Height + optHeight); SimOptions.Setup(Psc); } else if (Psc.SearchType == StructureSearchType.FullStructure) { SSOptions.Visible = SimOptions.Visible = SmallWorldOptions.Visible = PreviewPanel.Visible = false; FSOptions.Visible = showOptions; int optHeight = showOptions ? FSOptions.Height + BottomCtlsHeight : 0; Size = new Size(InitialFormSize.Width, InitialFormSize.Height + optHeight); FSOptions.Setup(Psc); } else if (Psc.SearchType == StructureSearchType.SmallWorld) { SSOptions.Visible = FSOptions.Visible = SimOptions.Visible = false; SmallWorldOptions.Visible = showOptions; SmallWorldOptions.CriteriaStructureForm = this; // link SmallWorldOptions to us SmallWorldPredefinedParameters swp = Psc.SmallWorldParameters; SmallWorldOptions.Setup(swp); Size = SmallWorldSize; // set form size same as last time if (!PreviewPanel.Visible) // if preview not visible then adjust size and show { PreviewCtl.InitializeView(); Size cs = this.ClientRectangle.Size; PreviewPanel.Width = cs.Width - PreviewPanel.Left - 2; PreviewPanel.Height = BottomDivider.Top - PreviewPanel.Top + 2; PreviewPanel.Visible = true; } if (initialSetup) { SmallWorldOptions.StartInitialQueryExecution(); // start search if initial setup } } else { Size = InitialFormSize; // no search type } Refresh(); SetupDepth--; return; }