///<summary> /// Sets up the Filter Button and the Filter and Find UserControl. Call this immediately after creating an instance of this class. /// </summary> public void SetupFilterAndFindControls() { LoadFilterIcons(); // Further set up certain Controls Properties that can't be set directly in the WinForms Generator... FChkToggleFilter.AutoSize = true; FChkToggleFilter.Text = MCommonResourcestrings.StrBtnTextFilter; FChkToggleFilter.Tag = MCommonResourcestrings.StrCtrlSuppressChangeDetection; FChkToggleFilter.Image = FFilterImages.Images[0]; // 'Filter is inactive' icon FChkToggleFilter.ImageAlign = ContentAlignment.MiddleLeft; FChkToggleFilter.Appearance = Appearance.Button; FChkToggleFilter.TextAlign = ContentAlignment.MiddleCenter; // Same as 'real' Button FChkToggleFilter.MinimumSize = new Size(75, 22); // To prevent shrinkage! FChkToggleFilter.Click += new EventHandler(this.ToggleFilterPanel); FPetraUtilsObject.SetToolTip(FChkToggleFilter, FPreviousFilterTooltip); FPetraUtilsObject.SetStatusBarText(FChkToggleFilter, MCommonResourcestrings.StrClickToShowHideFilterPanel); // Prepare parameters for the UserControl that will display the Filter and Find Panels FCallerFormOrControl.InitialiseFilterFindParameters(out FFilterAndFindParameters); // Show Filter and Find Panels initially collapsed or expanded FPnlFilterFind.Width = 0; FPnlFilterFind.Resize += FPnlFilterFind_Resize; // Ensure that the Filter and Find Panel 'pushes' the Grid away instead of overlaying the Grid FGrid.BringToFront(); if (FFilterAndFindParameters.FindAndFilterInitiallyExpanded) { ToggleFilter(); } }
/// <summary> /// Enables and disables the UI. Invokes setting up of the Grid after a /// successful search operation. /// </summary> private void EnableDisableUI(bool AEnable) { String SearchTarget; pnlBtnOKCancelHelpLayout.Enabled = Convert.ToBoolean(AEnable); if (Convert.ToBoolean(AEnable)) { if (FLocationFindObject.Progress.JobFinished) { if (FPagedDataTable.Rows.Count > 0) { /* hide message */ Application.DoEvents(); this.Cursor = Cursors.Default; /* * Setup result DataGrid */ SetupResultDataGrid(); grdResult.Visible = true; grdResult.BringToFront(); // Make the Grid respond on updown keys grdResult.Focus(); // this is needed so that the next 'Enter' press acts as if the the 'Accept' Button got pressed grdResult.Selection.Focus(new Position(1, 2), true); // Display the number of found Locations if (grdResult.TotalRecords > 1) { SearchTarget = StrSearchTargetPluralText; } else { SearchTarget = StrSearchTargetText; } grpResult.Text = MPartnerResourcestrings.StrSearchResult + ": " + grdResult.TotalRecords.ToString() + ' ' + SearchTarget + ' ' + MPartnerResourcestrings.StrFoundText; btnOK.Enabled = true; } else { this.Cursor = Cursors.Default; /* no results, inform user, then no further action */ lblSearchInfo.Text = MPartnerResourcestrings.StrNoRecordsFound1Text + ' ' + StrSearchTargetText + MPartnerResourcestrings.StrNoRecordsFound2Text; lblSearchInfo.BringToFront(); btnOK.Enabled = false; grdResult.Enabled = false; Application.DoEvents(); } } else { /* Search operation interrupted by user */ this.Cursor = Cursors.Default; grpResult.Text = MPartnerResourcestrings.StrSearchResult; lblSearchInfo.Text = MPartnerResourcestrings.StrSearchStopped; btnSearch.Enabled = true; btnOK.Enabled = false; // StatusBar update FPetraUtilsObject.WriteToStatusBar(MCommonResourcestrings.StrGenericReady); FPetraUtilsObject.SetStatusBarText(btnSearch, MPartnerResourcestrings.StrSearchButtonHelpText); Application.DoEvents(); // Ensure Client doesn't crash in case user presses <Tab> followed by <Enter> grdResult.Dispose(); grdResult = null; } } /* Enable/disable remaining controls */ btnClearCriteria.Enabled = Convert.ToBoolean(AEnable); tlpAllCriteria.Enabled = Convert.ToBoolean(AEnable); /* Set search button text */ if (Convert.ToBoolean(AEnable)) { btnSearch.Text = MPartnerResourcestrings.StrSearchButtonText; } else { btnSearch.Text = MPartnerResourcestrings.StrSearchButtonStopText; } }