Esempio n. 1
0
        private void customSummaryCheckBox_Click(object sender, RoutedEventArgs e)
        {
            MyCustomSummaryBase1 myCustomSummaryBase1 = new MyCustomSummaryBase1();

            if ((sender as CheckBox).IsChecked == true)
            {
                this.pivotGrid1.PivotCalculations.Insert(0, new PivotComputationInfo {
                    FieldHeader = "Shipped!", FieldName = "Value1", SummaryType = SummaryType.Custom, Format = "#,##0.00", Summary = myCustomSummaryBase1
                });
            }
            else
            {
                if (this.pivotGrid1.PivotRows.Any(i => i.FieldMappingName == "Value1"))
                {
                    this.pivotGrid1.PivotRows.Remove(this.pivotGrid1.PivotRows.FirstOrDefault(x => x.FieldMappingName == "Value1"));
                }
                if (this.pivotGrid1.PivotColumns.Any(i => i.FieldMappingName == "Value1"))
                {
                    this.pivotGrid1.PivotColumns.Remove(this.pivotGrid1.PivotColumns.FirstOrDefault(x => x.FieldMappingName == "Value1"));
                }
                if (this.pivotGrid1.GroupingBar.Filters.Any(i => i.Name == "Value1"))
                {
                    this.pivotGrid1.GroupingBar.Filters.Remove(this.pivotGrid1.GroupingBar.Filters.FirstOrDefault(x => x.Name == "Value1"));
                }
                if (this.pivotGrid1.PivotCalculations.Any(x => x.FieldName == "Value1"))
                {
                    this.pivotGrid1.PivotCalculations.Remove(this.pivotGrid1.PivotCalculations.FirstOrDefault(x => x.FieldName == "Value1"));
                }
            }
        }
Esempio n. 2
0
        public override void CombineSummary(SummaryBase other)
        {
            MyCustomSummaryBase1 dpsb = other as MyCustomSummaryBase1;

            if (null != dpsb)
            {
                mTotalValue += dpsb.mTotalValue;
            }
        }
Esempio n. 3
0
        protected override void Invoke(object parameter)
        {
            if (parameter is RoutedEventArgs)
            {
                RoutedEventArgs eventArgs = parameter as RoutedEventArgs;
                if (eventArgs.OriginalSource is CheckBox)
                {
                    CheckBox             sourceObject = eventArgs.OriginalSource as CheckBox;
                    MyCustomSummaryBase1 me           = new MyCustomSummaryBase1();
                    switch (sourceObject.Content.ToString())
                    {
                    case "CustomSummary":
                        if (sourceObject.IsChecked.HasValue && sourceObject.IsChecked.Value)
                        {
                            this.Target.PivotCalculations.Insert(0, new PivotComputationInfo {
                                FieldHeader = "Shipped!", FieldName = "Value1", SummaryType = SummaryType.Custom, Format = "#,##0.00", Summary = me
                            });
                        }
                        else
                        {
                            if (this.Target.PivotRows.Any(i => i.FieldMappingName == "Value1"))
                            {
                                this.Target.PivotRows.Remove(this.Target.PivotRows.FirstOrDefault(x => x.FieldMappingName == "Value1"));
                            }
                            if (this.Target.PivotColumns.Any(i => i.FieldMappingName == "Value1"))
                            {
                                this.Target.PivotColumns.Remove(this.Target.PivotColumns.FirstOrDefault(x => x.FieldMappingName == "Value1"));
                            }
                            if (this.Target.GroupingBar.Filters.Any(i => i.Name == "Value1"))
                            {
                                this.Target.GroupingBar.Filters.Remove(this.Target.GroupingBar.Filters.FirstOrDefault(x => x.Name == "Value1"));
                            }
                            if (this.Target.PivotCalculations.Any(x => x.FieldName == "Value1"))
                            {
                                this.Target.PivotCalculations.Remove(this.Target.PivotCalculations.FirstOrDefault(x => x.FieldName == "Value1"));
                            }
                        }
                        break;

                    case "Display if Discrete Values are Equal":
                        var comboBox = Common.FindVisualChild <ComboBox>(sourceObject.Parent);
                        if (sourceObject.IsChecked.HasValue && sourceObject.IsChecked.Value && comboBox != null)
                        {
                            this.Target.PivotCalculations.Insert(1, new PivotComputationInfo
                            {
                                FieldHeader = "Scrap!",
                                FieldName   = "Value3",
                                SummaryType = SummaryType.DisplayIfDiscreteValuesEqual,
                                PadString   = comboBox.SelectedIndex == 0 ? "***" : "999"
                            });
                        }
                        else
                        {
                            if (this.Target.PivotRows.Any(i => i.FieldMappingName == "Value3"))
                            {
                                this.Target.PivotRows.Remove(this.Target.PivotRows.FirstOrDefault(x => x.FieldMappingName == "Value3"));
                            }
                            if (this.Target.PivotColumns.Any(i => i.FieldMappingName == "Value3"))
                            {
                                this.Target.PivotColumns.Remove(this.Target.PivotColumns.FirstOrDefault(x => x.FieldMappingName == "Value3"));
                            }
                            if (this.Target.GroupingBar.Filters.Any(i => i.Name == "Value3"))
                            {
                                this.Target.GroupingBar.Filters.Remove(this.Target.GroupingBar.Filters.FirstOrDefault(x => x.Name == "Value3"));
                            }
                            if (this.Target.PivotCalculations.Any(x => x.FieldName == "Value3"))
                            {
                                this.Target.PivotCalculations.Remove(this.Target.PivotCalculations.FirstOrDefault(x => x.FieldName == "Value3"));
                            }
                        }
                        break;
                    }
                }
                else
                {
                    ComboBox sourceObject = eventArgs.OriginalSource as ComboBox;
                    switch (sourceObject.SelectedIndex)
                    {
                    case 0:
                        this.Target.PivotCalculations[1].PadString = "***";
                        break;

                    case 1:
                        this.Target.PivotCalculations[1].PadString = "999";
                        break;
                    }
                    if (this.Target.InternalGrid != null)
                    {
                        this.Target.InternalGrid.Refresh(true);
                    }
                }
            }
        }