示例#1
0
        private static void DataGridContextChangedCallback(DependencyObject sender, DependencyPropertyChangedEventArgs e)
        {
            DataGridContext dataGridContext = e.NewValue as DataGridContext;
            GroupByControl  panel           = ( GroupByControl )sender;

            if (dataGridContext != null)
            {
                panel.RegisterParentDataGridContext(dataGridContext);
            }
        }
示例#2
0
        private static void ParentGridControlChangedCallback(DependencyObject sender, DependencyPropertyChangedEventArgs e)
        {
            DataGridControl grid  = e.NewValue as DataGridControl;
            GroupByControl  panel = ( GroupByControl )sender;

            if (grid != null)
            {
                panel.PrepareDefaultStyleKey(grid.GetView());
            }
        }
示例#3
0
        protected override void OnMouseLeftButtonUp(MouseButtonEventArgs e)
        {
            bool isMouseCaptured = this.IsMouseCaptured;
            bool isPressed       = this.IsPressed;

            if (m_dragSourceManager != null)
            {
                m_dragSourceManager.ProcessMouseLeftButtonUp(e);
            }

            if (isMouseCaptured)
            {
                bool click = isPressed;

                if (click)
                {
                    bool           allowSort = true;
                    GroupByControl parentGBC = this.GetParentGroupByControl();

                    if (parentGBC != null)
                    {
                        allowSort = parentGBC.AllowSort;
                    }

                    if (allowSort)
                    {
                        DataGridContext       dataGridContext = DataGridControl.GetDataGridContext(this);
                        GroupLevelDescription groupInfo       = this.Content as GroupLevelDescription;
                        Debug.Assert((dataGridContext != null) && (groupInfo != null));

                        if ((dataGridContext != null) && (groupInfo != null))
                        {
                            ColumnBase column = dataGridContext.Columns[groupInfo.FieldName];

                            if ((column != null) && (column.AllowSort))
                            {
                                bool shiftUnpressed = ((Keyboard.Modifiers & ModifierKeys.Shift) != ModifierKeys.Shift);

                                var toggleColumnSort = dataGridContext.ToggleColumnSortCommand;
                                if (toggleColumnSort.CanExecute(column, shiftUnpressed))
                                {
                                    toggleColumnSort.Execute(column, shiftUnpressed);
                                }

                                e.Handled = true;
                            }
                        }
                    }
                }
            }

            base.OnMouseLeftButtonUp(e);
        }
示例#4
0
        bool IDropTarget.CanDropElement(UIElement draggedElement)
        {
            bool           allowGroupingModification = true;
            GroupByControl parentGBC = this.GetParentGroupByControl();

            if (parentGBC != null)
            {
                allowGroupingModification = parentGBC.IsGroupingModificationAllowed;
            }

            // We don't accept any ColumnManagerCell from Details
            DataGridContext context = DataGridControl.GetDataGridContext(draggedElement);

            ColumnManagerCell cell = draggedElement as ColumnManagerCell;

            bool isAlreadyGroupedBy = false;

            if (cell != null)
            {
                isAlreadyGroupedBy = GroupingHelper.IsAlreadyGroupedBy(cell);
                ColumnBase parentColumn = cell.ParentColumn;

                if ((parentColumn == null) || (!parentColumn.AllowGroup))
                {
                    return(false);
                }
            }

            DataGridContext sourceDetailContext = DataGridControl.GetDataGridContext(this);

            Debug.Assert(sourceDetailContext != null);
            DetailConfiguration sourceDetailConfig = (sourceDetailContext != null) ? sourceDetailContext.SourceDetailConfiguration : null;

            DataGridContext draggedDetailContext = DataGridControl.GetDataGridContext(draggedElement);

            Debug.Assert(draggedDetailContext != null);
            DetailConfiguration draggedDetailConfig = (draggedDetailContext != null) ? draggedDetailContext.SourceDetailConfiguration : null;


            bool canDrop = (sourceDetailConfig == draggedDetailConfig) &&
                           (allowGroupingModification) &&
                           ((draggedElement is ColumnManagerCell) || (draggedElement is GroupByItem)) &&
                           (draggedElement != this) &&
                           (isAlreadyGroupedBy == false);

            if (canDrop && (cell != null))
            {
                canDrop = GroupingHelper.ValidateMaxGroupDescriptions(draggedDetailContext);
            }

            return(canDrop);
        }
示例#5
0
        private void m_dragSourceManager_DragOutsideQueryCursor(object sender, QueryCursorEventArgs e)
        {
            GroupByControl parentGBC = this.GetParentGroupByControl();

            if ((parentGBC == null) || !parentGBC.IsGroupingModificationAllowed)
            {
                return;
            }

            DataGridContext dataGridContext = DataGridControl.GetDataGridContext(this);

            if ((dataGridContext != null) && (dataGridContext.DataGridControl != null))
            {
                UIViewBase uiViewBase = dataGridContext.DataGridControl.GetView() as UIViewBase;

                e.Cursor = (uiViewBase != null)
          ? uiViewBase.RemovingGroupCursor
          : UIViewBase.DefaultGroupDraggedOutsideCursor;
            }
            else
            {
                e.Cursor = UIViewBase.DefaultGroupDraggedOutsideCursor;
            }
        }
示例#6
0
        void m_dragSourceManager_DroppedOutside(object sender, EventArgs e)
        {
            bool           allowGroupingModification = true;
            GroupByControl parentGBC = this.GetParentGroupByControl();

            if (parentGBC != null)
            {
                allowGroupingModification = parentGBC.IsGroupingModificationAllowed;
            }

            if (allowGroupingModification)
            {
                DataGridContext dataGridContext = DataGridControl.GetDataGridContext(this);
                Debug.Assert(dataGridContext != null);

                if (dataGridContext != null)
                {
                    GroupingHelper.RemoveGroupDescription(
                        dataGridContext.Items.GroupDescriptions,
                        this.Content as GroupLevelDescription,
                        dataGridContext.DataGridControl);
                }
            }
        }