Пример #1
0
        public FlexPivotDemo()
        {
            InitializeComponent();
            Tag = Properties.Resources.Pivot;

            flexPivotPage.Loaded += (s, ea) =>
            {
                if (!flexPivotPage.IsVisible)
                {
                    return;
                }
                if (isLoaded)
                {
                    return;
                }
                isLoaded = true;

                var fpEngine = flexPivotPage.FlexPivotPanel.FlexPivotEngine;
                // apply update to view
                fpEngine.BeginUpdate();
                fpEngine.DataSource = Utils.PivotDataSet.Tables[0].DefaultView;
                // set value field limit to 4 (**default is 1)
                fpEngine.ValueFields.MaxItems = 4;

                //// create conditional formatting
                //fpEngine.Fields["ExtendedPrice"].StyleHigh.ForeColor = System.Drawing.Color.Green;
                //fpEngine.Fields["ExtendedPrice"].StyleHigh.ConditionType = C1.FlexPivot.ConditionType.Percentage;
                //fpEngine.Fields["ExtendedPrice"].StyleHigh.Value = 0.8;
                //fpEngine.Fields["ExtendedPrice"].StyleLow.ForeColor = System.Drawing.Color.Red;
                //fpEngine.Fields["ExtendedPrice"].StyleLow.ConditionType = C1.FlexPivot.ConditionType.Percentage;
                //fpEngine.Fields["ExtendedPrice"].StyleLow.Value = 0.1;

                fpEngine.Fields["ExtendedPrice"].Caption = "Sales";
                fpEngine.RowFields.Add("Country");
                fpEngine.ColumnFields.Add("Salesperson");
                fpEngine.ValueFields.Add("ExtendedPrice");
                fpEngine.Fields["ExtendedPrice"].Format = "c0";
                fpEngine.EndUpdate();

                var views = Utils.PivotViews;
                // build new menu with predefined views
                var menuViews = new C1MenuTool();
                menuViews.Label             = "Views";
                menuViews.IconTemplate      = C1IconTemplate.Edit;
                menuViews.VerticalAlignment = VerticalAlignment.Center;
                ToolTipService.SetToolTip(menuViews, "Select a predefined FlexPivot view.");
                foreach (var id in views.Keys)
                {
                    var mi = new C1ButtonTool();
                    mi.Label   = id;
                    mi.Padding = new Thickness(5);
                    mi.Tag     = views[id];
                    mi.Click  += mi_Click;
                    menuViews.Tools.Add(mi);
                }

                // add new menu to the page's main menu
                flexPivotPage.MainMenu.Items.Insert(6, menuViews);
            };
        }
        public CustomPage()
        {
            InitializeComponent();
            Tag = Properties.Resources.Page;
            pivotPage.Loaded += (s, ea) =>
            {
                if (!pivotPage.IsVisible)
                {
                    return;
                }
                if (isLoaded)
                {
                    return;
                }
                isLoaded = true;

                // view not found in storage, use default
                var fpEngine = pivotPage.FlexPivotEngine;
                fpEngine.DataSource = Utils.PivotDataSet.Tables[0].DefaultView;
                fpEngine.BeginUpdate();
                fpEngine.RowFields.Add("Country", "City");
                fpEngine.ColumnFields.Add("Salesperson");
                fpEngine.ValueFields.Add("ExtendedPrice");
                fpEngine.Fields["ExtendedPrice"].Format = "n0";
                fpEngine.ShowTotalsRows = ShowTotals.Subtotals;
                pivotPage.Updated      += FlexPivotPage_Updated;

                fpEngine.EndUpdate();

                // get predefined views from XML resource
                var views = Utils.PivotViews;

                // build new menu with predefined views
                var menuViews = new C1MenuTool();
                menuViews.Label             = "Views";
                menuViews.IconTemplate      = C1IconTemplate.Edit;
                menuViews.VerticalAlignment = VerticalAlignment.Center;
                ToolTipService.SetToolTip(menuViews, "Select a predefined FlexPivot view.");
                foreach (var id in views.Keys)
                {
                    var mi = new C1ButtonTool();
                    mi.Label   = id;
                    mi.Padding = new Thickness(5);
                    mi.Tag     = views[id];
                    mi.Click  += mi_Click;
                    menuViews.Tools.Add(mi);
                }

                // add new menu to the page's main menu
                pivotPage.MainMenu.Items.Insert(6, menuViews);

                // add collapseall menu to page's main menu
                collapseAllView                   = new C1ButtonTool();
                collapseAllView.Label             = "CollapseAll";
                collapseAllView.IconTemplate      = C1IconTemplate.ArrowDown;
                collapseAllView.VerticalAlignment = VerticalAlignment.Center;
                ToolTipService.SetToolTip(collapseAllView, "Collapse all the subtotals rows and columns.");
                collapseAllView.Click += collapseAllView_Click;
                pivotPage.MainMenu.Items.Insert(11, collapseAllView);
            };
        }