示例#1
0
        private void FucoFilterAndFind_ApplyFilterClicked(object sender, TUcoFilterAndFind.TContextEventExtControlArgs e)
        {
            if (FCallerFormOrControl.DoValidation(true, TErrorProcessingMode.Epm_All))
            {
                ApplyFilter();
                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();
                }
            }
        }
示例#2
0
        /// <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;
        }
示例#3
0
 /// <summary>
 /// Notification that the tab has been switched.  We may need to check if the scrollbar is visible
 /// </summary>
 private void FucoFilterAndFind_TabSwitched(object sender, TUcoFilterAndFind.TContextEventArgs e)
 {
     FPnlFilterFind_Resize(sender, null);
 }
示例#4
0
        /// <summary>
        /// Main method that is called when the Find Next button is clicked
        /// </summary>
        public void FucoFilterAndFind_FindNextClicked(object sender, TUcoFilterAndFind.TContextEventExtSearchDirectionArgs e)
        {
            if (e.Context == TUcoFilterAndFind.EventContext.ecFindPanel)
            {
                if (e.SearchUpwards)
                {
                    for (int rowNum = FCallerFormOrControl.GetSelectedRowIndex() - 1; rowNum > 0; rowNum--)
                    {
                        DataRowView rowView = (DataRowView)FGrid.Rows.IndexToDataSourceRow(rowNum);

                        if (FCallerFormOrControl.IsMatchingRow(rowView.Row))
                        {
                            FCallerFormOrControl.SelectRowInGrid(rowNum);

                            if (sender != null)
                            {
                                ((Control)sender).Focus();
                            }

                            return;
                        }
                    }
                }
                else
                {
                    for (int rowNum = Math.Max(2, FCallerFormOrControl.GetSelectedRowIndex() + 1); rowNum < FGrid.Rows.Count; rowNum++)
                    {
                        DataRowView rowView = (DataRowView)FGrid.Rows.IndexToDataSourceRow(rowNum);

                        if (FCallerFormOrControl.IsMatchingRow(rowView.Row))
                        {
                            FCallerFormOrControl.SelectRowInGrid(rowNum);

                            if (sender != null)
                            {
                                ((Control)sender).Focus();
                            }

                            return;
                        }
                    }
                }
            }
        }
示例#5
0
        /// <summary>
        /// Main method that handles the actions arising from toggling the filter panel on/off
        /// </summary>
        public void ToggleFilter()
        {
            if (FPnlFilterFind.Width == 0)
            {
                // Create the Filter and Find UserControl on-the-fly (loading the UserControl only when is is shown so that the screen can load faster!)
                if (FucoFilterAndFind == null)
                {
                    // Add columns to data table where filtering is numeric
                    FCallerFormOrControl.AddNumericColumnConversions();

                    // Create the individual panels from the YAML
                    FCallerFormOrControl.CreateFilterFindPanels();

                    // Construct a complete new Filter/Find Panel
                    FucoFilterAndFind = new TUcoFilterAndFind(
                        FFilterPanelControls.GetFilterPanels(),
                        FFilterPanelControls.GetExtraFilterPanels(),
                        FFindPanelControls.GetFindPanels(),
                        FFilterAndFindParameters);

                    FucoFilterAndFind.Dock = DockStyle.Fill;
                    FPnlFilterFind.Controls.Add(FucoFilterAndFind);

                    FucoFilterAndFind.Expanded += delegate {
                        ToggleFilter();
                    };
                    FucoFilterAndFind.Collapsed += delegate {
                        ToggleFilter();
                    };

                    FucoFilterAndFind.ApplyFilterClicked += new EventHandler <TUcoFilterAndFind.TContextEventExtControlArgs>(
                        FucoFilterAndFind_ApplyFilterClicked);
                    FucoFilterAndFind.ArgumentCtrlValueChanged += new EventHandler <TUcoFilterAndFind.TContextEventExtControlValueArgs>(
                        FucoFilterAndFind_ArgumentCtrlValueChanged);
                    FucoFilterAndFind.FindNextClicked += new EventHandler <TUcoFilterAndFind.TContextEventExtSearchDirectionArgs>(
                        FucoFilterAndFind_FindNextClicked);
                    FucoFilterAndFind.TabSwitched += FucoFilterAndFind_TabSwitched;
                    FucoFilterAndFind.FilterFindTabFocused += new EventHandler(FilterFindTabGotFocus);

                    SetStatusBarText();
                }

                FGrid.IncludeFixedRowsInAutoSizeColumns = false;
                FPnlFilterFind.Width = FFilterAndFindParameters.FindAndFilterInitialWidth;
                FChkToggleFilter.Checked = true;
                FCallerFormOrControl.FilterToggled();

                FucoFilterAndFind_ArgumentCtrlValueChanged(FucoFilterAndFind,
                    new TUcoFilterAndFind.TContextEventExtControlValueArgs(TUcoFilterAndFind.EventContext.ecFilterTab, null, null, null));
            }
            else
            {
                // Collapse the filter panel and uncheck the button if there is no active filter
                FGrid.IncludeFixedRowsInAutoSizeColumns = true;
                FPnlFilterFind.Width = 0;
                FCallerFormOrControl.FilterToggled();
                FCurrentActiveFilter = FFilterPanelControls.GetCurrentFilter(
                    true,
                    FucoFilterAndFind.KeepFilterTurnedOnButtonDepressed,
                    FucoFilterAndFind.ShowFilterIsAlwaysOnLabel);

                ((DevAge.ComponentModel.BoundDataView)FGrid.DataSource).DataView.RowFilter = FCurrentActiveFilter;

                FChkToggleFilter.Checked = false;
            }

            FButtonPanel.UpdateRecordNumberDisplay();
            SetRecordNumberDisplayProperties();
            FCallerFormOrControl.SelectRowInGrid(this.FCallerFormOrControl.GetSelectedRowIndex());
            FPnlFilterFind.Visible = FPnlFilterFind.Width > 0;
        }
示例#6
0
 /// <summary>
 /// Switches the 'Keep Filter Turned On' Button to the 'on'/'depressed' state.
 /// </summary>
 /// <param name="AFilterContext">Filter Context in which to switch the Button on.</param>
 public void SwitchOnKeepFilterTurnedOn(TUcoFilterAndFind.FilterContext AFilterContext)
 {
     FucoFilterAndFind.SwitchOnKeepFilterTurnedOn(AFilterContext);
 }
 private void FindAndFilter_ArgumentCtrlValueChanged(object AUcoEventSender, TUcoFilterAndFind.TContextEventExtControlValueArgs AUcoEventArgs)
 {
     // TODO
 }
示例#8
0
        /// <summary>
        /// Gets the current filter from all the inputs on the filter panel
        /// </summary>
        /// <returns>The current filter from all the inputs on the filter panel</returns>
        public string GetCurrentFilter(bool AIsCollapsed,
            TUcoFilterAndFind.FilterContext AKeepFilterOnButtonDepressedContext,
            TUcoFilterAndFind.FilterContext AFilterAlwaysOnLabelContext)
        {
            // Start with the base filter
            string filter = FBaseFilter;

            bool bIgnoreStandardFilter = (AIsCollapsed
                                          && (AKeepFilterOnButtonDepressedContext == TUcoFilterAndFind.FilterContext.None
                                              || AKeepFilterOnButtonDepressedContext == TUcoFilterAndFind.FilterContext.ExtraFilterOnly) /*
                                                                                                                                          * && (AFilterAlwaysOnLabelContext == TUcoFilterAndFind.FilterContext.None
                                                                                                                                          || AFilterAlwaysOnLabelContext == TUcoFilterAndFind.FilterContext.ExtraFilterOnly)*/);
            string stdFilter = (bIgnoreStandardFilter) ? String.Empty : GetCurrentFilter(FStandardFilterPanels);

            bool bIgnoreExtraFilter = (AIsCollapsed
                                       && (AKeepFilterOnButtonDepressedContext == TUcoFilterAndFind.FilterContext.None
                                           || AKeepFilterOnButtonDepressedContext == TUcoFilterAndFind.FilterContext.StandardFilterOnly)
                                       && (AFilterAlwaysOnLabelContext == TUcoFilterAndFind.FilterContext.None
                                           || AFilterAlwaysOnLabelContext == TUcoFilterAndFind.FilterContext.StandardFilterOnly));
            string extFilter = (bIgnoreExtraFilter) ? String.Empty : GetCurrentFilter(FExtraFilterPanels);

            if ((filter.Length > 0) && (stdFilter.Length > 0))
            {
                filter += " AND ";
            }

            filter += stdFilter;

            if ((filter.Length > 0) && (extFilter.Length > 0))
            {
                filter += " AND ";
            }

            filter += extFilter;
            return filter;
        }