Example #1
0
 public void ShowPivotDialog(bool alwaysAddNewLevel)
 {
     if (null == BindingListSource)
     {
         return;
     }
     PivotEditor.ShowPivotEditor(FormUtil.FindTopLevelOwner(this), BindingListSource, alwaysAddNewLevel);
 }
Example #2
0
        public static void ShowPivotEditor(Control owner, BindingListSource bindingListSource, bool alwaysAddNewLevel)
        {
            var viewContext = bindingListSource.ViewContext;

            using (var groupingTotalForm = new PivotEditor(viewContext))
            {
                var transformResults = bindingListSource.BindingListView.QueryResults.TransformResults;
                var currentPivotSpec = alwaysAddNewLevel ? null : transformResults.RowTransform as PivotSpec;
                IList <DataPropertyDescriptor> allProperties;
                if (currentPivotSpec == null)
                {
                    allProperties = transformResults.PivotedRows.ItemProperties;
                    groupingTotalForm.PivotSpec = PivotSpec.EMPTY;
                }
                else
                {
                    groupingTotalForm.PivotSpec = currentPivotSpec;
                    allProperties = transformResults.Parent.PivotedRows.ItemProperties;
                }
                if (allProperties.Count > MAX_COLUMN_COUNT)
                {
                    string message = string.Format(Resources.PivotingForm_ShowPivotingForm_The_Pivot_Editor_cannot_be_shown_because_there_are_more_than__0__columns_,
                                                   MAX_COLUMN_COUNT);
                    viewContext.ShowMessageBox(owner, message, MessageBoxButtons.OK);
                    return;
                }
                groupingTotalForm.AllProperties = allProperties;
                if (groupingTotalForm.ShowDialog(owner) == DialogResult.OK)
                {
                    if (currentPivotSpec == null)
                    {
                        bindingListSource.BindingListView.TransformStack =
                            bindingListSource.BindingListView.TransformStack.PushTransform(groupingTotalForm.PivotSpec);
                    }
                    else
                    {
                        bindingListSource.BindingListView.TransformStack =
                            bindingListSource.BindingListView.TransformStack.Predecessor.PushTransform(groupingTotalForm.PivotSpec);
                    }
                }
            }
        }