/// <summary> /// Main method that is called when a control on the filter/find panel is changed /// </summary> public void FucoFilterAndFind_ArgumentCtrlValueChanged(object sender, TUcoFilterAndFind.TContextEventExtControlValueArgs e) { if (e.Context == TUcoFilterAndFind.EventContext.ecFindPanel) { // No need for any dynamic response on the Find panel return; } // Something has changed on the filter/find panel // If this is the first activation we need to initialise combo boxes because they will now have been populated for the first time if ((sender is TUcoFilterAndFind) && !FIsFilterFindInitialised) { // First time of diaplaying the panel(s) // we need to initialise all the combo boxes to their clear value FFilterPanelControls.InitialiseComboBoxes(); FFindPanelControls.InitialiseComboBoxes(); FIsFilterFindInitialised = true; } // We need to call ValidateAllData before applying the new filter, // but not if it was ValidateAllData that is causing the argumentCtrlValue change by clearing the discretionary filters if (!FClearingDiscretionaryFilters) { if (!FCallerFormOrControl.DoValidation(true, TErrorProcessingMode.Epm_All)) { // Remember who called us and why, so we can replay the event when the data becomes valid again Control senderAsControl = (sender as Control); if ((senderAsControl != null) && (senderAsControl.CanFocus)) { FFailedValidation_CtrlChangeEventArgsInfo = new TEventArgsInfo(sender, e); } return; } } Cursor prevCursor = FPetraUtilsObject.GetForm().Cursor; FPetraUtilsObject.GetForm().Cursor = Cursors.WaitCursor; // Do we need to update the filter? // Yes if // 1. the panel is being shown and one or other has no ApplyNow button // 2. a control has been changed on a panel with no ApplyNow button bool DynamicStandardFilterPanel = (((FucoFilterAndFind.ShowApplyFilterButton == TUcoFilterAndFind.FilterContext.None) || (FucoFilterAndFind.ShowApplyFilterButton == TUcoFilterAndFind.FilterContext.ExtraFilterOnly))); bool DynamicExtraFilterPanel = FucoFilterAndFind.IsExtraFilterShown && (((FucoFilterAndFind.ShowApplyFilterButton == TUcoFilterAndFind.FilterContext.None) || (FucoFilterAndFind.ShowApplyFilterButton == TUcoFilterAndFind.FilterContext.StandardFilterOnly))); if ((sender is TUcoFilterAndFind) && (FPnlFilterFind.Width > 0)) { if (((FucoFilterAndFind.KeepFilterTurnedOnButtonDepressed == TUcoFilterAndFind.FilterContext.None) || (FucoFilterAndFind.KeepFilterTurnedOnButtonDepressed == TUcoFilterAndFind.FilterContext.ExtraFilterOnly)) || (FucoFilterAndFind.IsExtraFilterShown && ((FucoFilterAndFind.KeepFilterTurnedOnButtonDepressed == TUcoFilterAndFind.FilterContext.None) || (FucoFilterAndFind.KeepFilterTurnedOnButtonDepressed == TUcoFilterAndFind.FilterContext.StandardFilterOnly)))) { ApplyFilter(); Console.WriteLine("The panel has been toggled ON: Applying the dynamic filter"); } else { Console.WriteLine("The panel has been toggled ON: Skipping dynamic filtering because the KeepFilterOn button(s) were depressed."); } } else if (((e.Context == TUcoFilterAndFind.EventContext.ecStandardFilterPanel) && DynamicStandardFilterPanel) || ((e.Context == TUcoFilterAndFind.EventContext.ecExtraFilterPanel) && DynamicExtraFilterPanel)) { ApplyFilter(); Console.WriteLine("Applying the filter dynamically, due to a control value change"); } if ((DynamicStandardFilterPanel || DynamicExtraFilterPanel) && !FucoFilterAndFind.IgnoreValueChangedEvent && !FClearingDiscretionaryFilters) { // If we are dynamic filtering we try to re-select the row we highlighted before - otherwise we keep the highlight in the same position // However, if we are clearing the filter or the userControl is sending duplicate events, we skip this step int newRowAfterFiltering = FGrid.DataSourceRowToIndex2( FCallerFormOrControl.GetSelectedDataRow(), FCallerFormOrControl.GetSelectedRowIndex() - 1) + 1; FCallerFormOrControl.SelectRowInGrid(newRowAfterFiltering == 0 ? FCallerFormOrControl.GetSelectedRowIndex() : newRowAfterFiltering); if (sender as TUcoFilterAndFind == null) { ((Control)sender).Focus(); } } FPetraUtilsObject.GetForm().Cursor = prevCursor; }
/// <summary> /// Main method that is called when a control on the filter/find panel is changed /// </summary> public void FucoFilterAndFind_ArgumentCtrlValueChanged(object sender, TUcoFilterAndFind.TContextEventExtControlValueArgs e) { if (e.Context == TUcoFilterAndFind.EventContext.ecFindPanel) { // No need for any dynamic response on the Find panel return; } // Something has changed on the filter/find panel // If this is the first activation we need to initialise combo boxes because they will now have been populated for the first time if ((sender is TUcoFilterAndFind) && !FIsFilterFindInitialised) { // First time of diaplaying the panel(s) // we need to initialise all the combo boxes to their clear value FFilterPanelControls.InitialiseComboBoxes(); FFindPanelControls.InitialiseComboBoxes(); FIsFilterFindInitialised = true; } // We need to call ValidateAllData before applying the new filter, // but not if it was ValidateAllData that is causing the argumentCtrlValue change by clearing the discretionary filters if (!FClearingDiscretionaryFilters) { if (!FCallerFormOrControl.DoValidation(true, true)) { // Remember who called us and why, so we can replay the event when the data becomes valid again Control senderAsControl = (sender as Control); if ((senderAsControl != null) && (senderAsControl.CanFocus)) { FFailedValidation_CtrlChangeEventArgsInfo = new TEventArgsInfo(sender, e); } return; } } Cursor prevCursor = FPetraUtilsObject.GetForm().Cursor; FPetraUtilsObject.GetForm().Cursor = Cursors.WaitCursor; // Do we need to update the filter? // Yes if // 1. the panel is being shown and one or other has no ApplyNow button // 2. a control has been changed on a panel with no ApplyNow button bool DynamicStandardFilterPanel = (((FucoFilterAndFind.ShowApplyFilterButton == TUcoFilterAndFind.FilterContext.None) || (FucoFilterAndFind.ShowApplyFilterButton == TUcoFilterAndFind.FilterContext.ExtraFilterOnly))); bool DynamicExtraFilterPanel = FucoFilterAndFind.IsExtraFilterShown && (((FucoFilterAndFind.ShowApplyFilterButton == TUcoFilterAndFind.FilterContext.None) || (FucoFilterAndFind.ShowApplyFilterButton == TUcoFilterAndFind.FilterContext.StandardFilterOnly))); if ((sender is TUcoFilterAndFind) && (FPnlFilterFind.Width > 0)) { if (((FucoFilterAndFind.KeepFilterTurnedOnButtonDepressed == TUcoFilterAndFind.FilterContext.None) || (FucoFilterAndFind.KeepFilterTurnedOnButtonDepressed == TUcoFilterAndFind.FilterContext.ExtraFilterOnly)) || (FucoFilterAndFind.IsExtraFilterShown && ((FucoFilterAndFind.KeepFilterTurnedOnButtonDepressed == TUcoFilterAndFind.FilterContext.None) || (FucoFilterAndFind.KeepFilterTurnedOnButtonDepressed == TUcoFilterAndFind.FilterContext.StandardFilterOnly)))) { ApplyFilter(); Console.WriteLine("The panel has been toggled ON: Applying the dynamic filter"); } else { Console.WriteLine("The panel has been toggled ON: Skipping dynamic filtering because the KeepFilterOn button(s) were depressed."); } } else if (((e.Context == TUcoFilterAndFind.EventContext.ecStandardFilterPanel) && DynamicStandardFilterPanel) || ((e.Context == TUcoFilterAndFind.EventContext.ecExtraFilterPanel) && DynamicExtraFilterPanel)) { ApplyFilter(); Console.WriteLine("Applying the filter dynamically, due to a control value change"); } if ((DynamicStandardFilterPanel || DynamicExtraFilterPanel) && !FucoFilterAndFind.IgnoreValueChangedEvent && !FClearingDiscretionaryFilters) { // If we are dynamic filtering we try to re-select the row we highlighted before - otherwise we keep the highlight in the same position // However, if we are clearing the filter or the userControl is sending duplicate events, we skip this step int newRowAfterFiltering = FGrid.DataSourceRowToIndex2( FCallerFormOrControl.GetSelectedDataRow(), FCallerFormOrControl.GetSelectedRowIndex() - 1) + 1; FCallerFormOrControl.SelectRowInGrid(newRowAfterFiltering == 0 ? FCallerFormOrControl.GetSelectedRowIndex() : newRowAfterFiltering); if (sender as TUcoFilterAndFind == null) { ((Control)sender).Focus(); } } FPetraUtilsObject.GetForm().Cursor = prevCursor; }