Exemple #1
0
 private void button5_Click(object sender, RoutedEventArgs e)
 {
     if ((sender as Button).IsEnabled)
     {
         if (this.pivotGrid1.GroupingBar != null && this.pivotGrid1.GroupingBar.AllowMultiFunctionalSortFilter)
         {
             FilterConverter filterconv = new FilterConverter();
             for (int i = 0; i < this.pivotGrid1.Filters.Count; i++)
             {
                 filterconv.UpdateDictionary(this.pivotGrid1.Filters[i].DimensionName);
             }
         }
         else
         {
             ImageConverter imgconv = new ImageConverter();
             for (int i = 0; i < this.pivotGrid1.Filters.Count; i++)
             {
                 imgconv.UpdateDictionary(this.pivotGrid1.Filters[i].DimensionName);
             }
         }
         this.pivotGrid1.Filters.Clear();
         this.pivotGrid1.InternalGrid.Refresh(true);
     }
     this.pivotGrid1.InvalidateCells();
 }
        protected override void Invoke(object parameter)
        {
            if (parameter is RoutedEventArgs)
            {
                RoutedEventArgs eventArgs = parameter as RoutedEventArgs;

                Button current = eventArgs.OriginalSource as Button;
                if (current == null)
                {
                    return;
                }
                switch (current.Name)
                {
                case "button1":
                    if (current.IsEnabled)
                    {
                        this.Target.Filters.Add(new FilterExpression("Product"));
                    }
                    break;

                case "button2":
                    if (current.IsEnabled)
                    {
                        this.Target.Filters.Remove(this.Target.Filters.FirstOrDefault(i => i.DimensionName == "Product"));
                    }
                    this.Target.Filters.Remove(this.Target.Filters.FirstOrDefault(i => i.Name == "Product"));

                    break;

                case "button3":
                    if (current.IsEnabled)
                    {
                        this.Target.Filters.Insert(0, new FilterExpression("State"));
                    }
                    break;

                case "button4":
                    if (current.IsEnabled)
                    {
                        if (this.Target.Filters.Count > 1)
                        {
                            this.Target.Filters.RemoveAt(1);
                        }
                        else if (this.Target.GroupingBar.Filters.Count > 1)
                        {
                            this.Target.GroupingBar.Filters.RemoveAt(1);
                        }
                        else
                        {
                            MessageBox.Show("Please add the item before remove", "Warning!");
                        }
                    }

                    break;

                case "button5":
                    if (current.IsEnabled)
                    {
                        if (this.Target.GroupingBar != null && this.Target.GroupingBar.AllowMultiFunctionalSortFilter)
                        {
                            FilterConverter filterconv = new FilterConverter();
                            for (int i = 0; i < this.Target.Filters.Count; i++)
                            {
                                filterconv.UpdateDictionary(this.Target.Filters[i].DimensionName);
                            }
                        }
                        else
                        {
                            ImageConverter imgconv = new ImageConverter();
                            for (int i = 0; i < this.Target.Filters.Count; i++)
                            {
                                imgconv.UpdateDictionary(this.Target.Filters[i].DimensionName);
                            }
                        }
                        this.Target.Filters.Clear();
                        this.Target.InternalGrid.Refresh(true);
                    }
                    break;
                }
            }
            this.Target.InvalidateCells();
        }