예제 #1
0
        protected virtual void EditFilterDescriptor(RadFilterComposeMenuItem menuItem)
        {
            RadFilterComposeMenuItem filterComposeMenuItem = menuItem;

            this.clickedBetweenItem = false;
            if (menuItem.Text == LocalizationProvider <RadGridLocalizationProvider> .CurrentProvider.GetLocalizedString("FilterFunctionsBetween") || menuItem.Text == LocalizationProvider <RadGridLocalizationProvider> .CurrentProvider.GetLocalizedString("FilterFunctionNotBetween"))
            {
                this.clickedBetweenItem = true;
            }
            string themeName = this.ThemeName;

            using (BaseCompositeFilterDialog compositeFilterForm = this.CreateCompositeFilterForm())
            {
                compositeFilterForm.Initialize(this.dataColumn, filterComposeMenuItem.FilterDescriptor, true);
                compositeFilterForm.ThemeName = themeName;
                if (compositeFilterForm.ShowDialog() == DialogResult.Cancel)
                {
                    return;
                }
                FilterDescriptor filterDescriptor = compositeFilterForm.FilterDescriptor;
                if (!GridFilterCellElement.ValidateUserFilter(filterDescriptor))
                {
                    return;
                }
                this.filterDescriptor = filterDescriptor;
                this.OnFilterConfirmed();
            }
        }
        private void FilterMenuItem_Click(object sender, EventArgs e)
        {
            RadFilterOperationMenuItem operationMenuItem = sender as RadFilterOperationMenuItem;

            if (operationMenuItem != null)
            {
                this.SetFilterOperator(operationMenuItem.Operator);
            }
            else
            {
                RadFilterComposeMenuItem filterComposeMenuItem = sender as RadFilterComposeMenuItem;
            }
        }
예제 #3
0
        protected virtual void OnFilterMenuItemClick(object sender, EventArgs e)
        {
            RadFilterOperationMenuItem operationMenuItem = sender as RadFilterOperationMenuItem;

            if (operationMenuItem != null && !operationMenuItem.IsChecked)
            {
                this.SetFilterOperator(operationMenuItem.Operator);
            }
            RadFilterComposeMenuItem menuItem = sender as RadFilterComposeMenuItem;

            if (menuItem == null)
            {
                return;
            }
            this.EditFilterDescriptor(menuItem);
        }
예제 #4
0
        protected virtual RadDropDownMenu CreateFilterMenu(System.Type dataType)
        {
            FilterDescriptor          descriptor       = this.Descriptor;
            CompositeFilterDescriptor filterDescriptor = descriptor as CompositeFilterDescriptor;

            CompositeFilterDescriptor.DescriptorType descriptorType = CompositeFilterDescriptor.GetDescriptorType(filterDescriptor);
            RadDropDownMenu menu = new RadDropDownMenu();
            List <FilterOperationContext> filterOperations = FilterOperationContext.GetFilterOperations(dataType);
            bool flag = this.ColumnInfo is GridViewMultiComboBoxColumn;

            foreach (FilterOperationContext context in filterOperations)
            {
                if (!flag || context.Operator == FilterOperator.None || (context.Operator == FilterOperator.IsEqualTo || context.Operator == FilterOperator.IsNotEqualTo))
                {
                    RadFilterOperationMenuItem operationMenuItem = new RadFilterOperationMenuItem(context);
                    operationMenuItem.IsChecked = filterDescriptor == null && operationMenuItem.Operator == descriptor.Operator;
                    operationMenuItem.Click    += new EventHandler(this.FilterMenuItem_Click);
                    menu.Items.Add((RadItem)operationMenuItem);
                }
            }
            if (GridViewHelper.IsNumeric(dataType) || (object)dataType == (object)typeof(DateTime))
            {
                RadFilterComposeMenuItem filterComposeMenuItem1 = new RadFilterComposeMenuItem("FilterFunctionsBetween");
                filterComposeMenuItem1.IsChecked        = filterDescriptor != null && descriptorType == CompositeFilterDescriptor.DescriptorType.Between;
                filterComposeMenuItem1.FilterDescriptor = (FilterDescriptor)this.GetCompositeFilterDescriptor(CompositeFilterDescriptor.DescriptorType.Between, filterDescriptor, dataType);
                filterComposeMenuItem1.Click           += new EventHandler(this.FilterMenuItem_Click);
                menu.Items.Add((RadItem)filterComposeMenuItem1);
                RadFilterComposeMenuItem filterComposeMenuItem2 = new RadFilterComposeMenuItem("FilterFunctionNotBetween");
                filterComposeMenuItem2.IsChecked        = descriptorType == CompositeFilterDescriptor.DescriptorType.NotBetween;
                filterComposeMenuItem2.FilterDescriptor = (FilterDescriptor)this.GetCompositeFilterDescriptor(CompositeFilterDescriptor.DescriptorType.NotBetween, filterDescriptor, dataType);
                filterComposeMenuItem2.Click           += new EventHandler(this.FilterMenuItem_Click);
                menu.Items.Add((RadItem)filterComposeMenuItem2);
            }
            if ((object)dataType != (object)typeof(Image))
            {
                RadFilterComposeMenuItem filterComposeMenuItem = new RadFilterComposeMenuItem("FilterFunctionsCustom");
                filterComposeMenuItem.FilterDescriptor = descriptor.Clone() as FilterDescriptor;
                filterComposeMenuItem.Click           += new EventHandler(this.FilterMenuItem_Click);
                filterComposeMenuItem.IsChecked        = filterDescriptor != null && descriptorType == CompositeFilterDescriptor.DescriptorType.Unknown;
                menu.Items.Add((RadItem)filterComposeMenuItem);
            }
            menu.PopupOpening += new RadPopupOpeningEventHandler(this.contextMenu_PopupOpening);
            menu.PopupClosed  += new RadPopupClosedEventHandler(this.contextMenu_PopupClosed);
            GridViewContextMenuManager.UpdateMenuTheme((GridVisualElement)this.GridViewElement, menu);
            return(menu);
        }
예제 #5
0
        private void FilterMenuItem_Click(object sender, EventArgs e)
        {
            RadFilterOperationMenuItem operationMenuItem = sender as RadFilterOperationMenuItem;

            if (operationMenuItem != null)
            {
                this.SetFilterOperator(operationMenuItem.Operator);
            }
            else
            {
                RadFilterComposeMenuItem menuItem = sender as RadFilterComposeMenuItem;
                if (menuItem == null)
                {
                    return;
                }
                this.EditFilterDescriptor(menuItem);
            }
        }
예제 #6
0
        protected virtual void CreateFilterOperationsMenuItems()
        {
            FilterDescriptor          filterDescriptor1 = this.GetFilterDescriptor();
            CompositeFilterDescriptor filterDescriptor2 = filterDescriptor1 as CompositeFilterDescriptor;

            CompositeFilterDescriptor.DescriptorType descriptorType = CompositeFilterDescriptor.GetDescriptorType(filterDescriptor2);
            RadMenuItem radMenuItem = new RadMenuItem();

            radMenuItem.IsChecked = false;
            radMenuItem.Text      = LocalizationProvider <RadGridLocalizationProvider> .CurrentProvider.GetLocalizedString("FilterMenuAvailableFilters");

            radMenuItem.StretchVertically = false;
            this.Items.Add((RadItem)radMenuItem);
            RadMenuSeparatorItem menuSeparatorItem = new RadMenuSeparatorItem();

            menuSeparatorItem.StretchVertically = false;
            this.Items.Add((RadItem)menuSeparatorItem);
            System.Type filteringDataType = this.ColumnFilteringDataType;
            foreach (FilterOperationContext filterOperation in FilterOperationContext.GetFilterOperations(filteringDataType))
            {
                if (filterOperation.Operator == FilterOperator.None || filterOperation.Operator == FilterOperator.IsNull || filterOperation.Operator == FilterOperator.IsNotNull)
                {
                    RadFilterOperationMenuItem operationMenuItem = new RadFilterOperationMenuItem(filterOperation);
                    operationMenuItem.Click += new EventHandler(this.FilterMenuItem_Click);
                    if (filterOperation.Operator == FilterOperator.None)
                    {
                        operationMenuItem.Enabled = filterDescriptor2 != null && filterDescriptor2.Operator != FilterOperator.None || operationMenuItem.Operator != filterDescriptor1.Operator;
                        operationMenuItem.Text    = LocalizationProvider <RadGridLocalizationProvider> .CurrentProvider.GetLocalizedString("FilterMenuClearFilters");

                        operationMenuItem.Image             = (Image)Resources.ClearFilter;
                        operationMenuItem.TextImageRelation = TextImageRelation.ImageBeforeText;
                        operationMenuItem.ImageAlignment    = ContentAlignment.MiddleLeft;
                        operationMenuItem.DisplayStyle      = DisplayStyle.ImageAndText;
                        this.Items.Insert(0, (RadItem)operationMenuItem);
                    }
                    else
                    {
                        operationMenuItem.IsChecked = (filterDescriptor2 == null || filterDescriptor2.Operator == FilterOperator.None) && operationMenuItem.Operator == filterDescriptor1.Operator;
                        if (operationMenuItem.IsChecked)
                        {
                            radMenuItem.IsChecked = true;
                        }
                        radMenuItem.Items.Add((RadItem)operationMenuItem);
                    }
                }
                else
                {
                    RadFilterComposeMenuItem filterComposeMenuItem = new RadFilterComposeMenuItem();
                    filterComposeMenuItem.Text                      = filterOperation.Name;
                    filterComposeMenuItem.FilterDescriptor          = filterDescriptor1.Clone() as FilterDescriptor;
                    filterComposeMenuItem.FilterDescriptor.Operator = filterOperation.Operator;
                    filterComposeMenuItem.Click                    += new EventHandler(this.FilterMenuItem_Click);
                    filterComposeMenuItem.IsChecked                 = (filterDescriptor2 == null || filterDescriptor2.Operator == FilterOperator.None) && filterOperation.Operator == filterDescriptor1.Operator;
                    if (filterComposeMenuItem.IsChecked)
                    {
                        radMenuItem.IsChecked = true;
                    }
                    radMenuItem.Items.Add((RadItem)filterComposeMenuItem);
                }
            }
            if (GridViewHelper.IsNumeric(filteringDataType) || (object)filteringDataType == (object)typeof(DateTime))
            {
                RadFilterComposeMenuItem filterComposeMenuItem1 = new RadFilterComposeMenuItem("FilterFunctionsBetween");
                filterComposeMenuItem1.IsChecked = filterDescriptor2 != null && filterDescriptor2.Operator != FilterOperator.None && descriptorType == CompositeFilterDescriptor.DescriptorType.Between;
                if (filterComposeMenuItem1.IsChecked)
                {
                    radMenuItem.IsChecked = true;
                }
                filterComposeMenuItem1.FilterDescriptor = (FilterDescriptor)this.GetCompositeFilterDescriptor(CompositeFilterDescriptor.DescriptorType.Between, filterDescriptor2);
                filterComposeMenuItem1.Click           += new EventHandler(this.FilterMenuItem_Click);
                radMenuItem.Items.Add((RadItem)filterComposeMenuItem1);
                RadFilterComposeMenuItem filterComposeMenuItem2 = new RadFilterComposeMenuItem("FilterFunctionNotBetween");
                filterComposeMenuItem2.IsChecked = descriptorType == CompositeFilterDescriptor.DescriptorType.NotBetween;
                if (filterComposeMenuItem2.IsChecked)
                {
                    radMenuItem.IsChecked = true;
                }
                filterComposeMenuItem2.FilterDescriptor = (FilterDescriptor)this.GetCompositeFilterDescriptor(CompositeFilterDescriptor.DescriptorType.NotBetween, filterDescriptor2);
                filterComposeMenuItem2.Click           += new EventHandler(this.FilterMenuItem_Click);
                radMenuItem.Items.Add((RadItem)filterComposeMenuItem2);
            }
            if ((object)filteringDataType == (object)typeof(Image))
            {
                return;
            }
            RadFilterComposeMenuItem filterComposeMenuItem3 = new RadFilterComposeMenuItem("FilterFunctionsCustom");

            filterComposeMenuItem3.FilterDescriptor = filterDescriptor1.Clone() as FilterDescriptor;
            filterComposeMenuItem3.Click           += new EventHandler(this.FilterMenuItem_Click);
            filterComposeMenuItem3.IsChecked        = filterDescriptor2 != null && filterDescriptor2.Operator != FilterOperator.None && descriptorType == CompositeFilterDescriptor.DescriptorType.Unknown;
            if (filterComposeMenuItem3.IsChecked)
            {
                radMenuItem.IsChecked = true;
            }
            radMenuItem.Items.Add((RadItem)filterComposeMenuItem3);
        }