示例#1
0
        private void DragSourceManager_DragOutsideQueryCursor(object sender, QueryCursorEventArgs e)
        {
            HierarchicalGroupByControlNode hierarchicalGroupByControlNode = HierarchicalGroupByItem.GetParentHierarchicalGroupByControlNode(this);

            if ((hierarchicalGroupByControlNode == null) ||
                (!hierarchicalGroupByControlNode.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;
            }
        }
示例#2
0
        private void DragSourceManager_DroppedOutside(object sender, EventArgs e)
        {
            HierarchicalGroupByControlNode hierarchicalGroupByControlNode = HierarchicalGroupByItem.GetParentHierarchicalGroupByControlNode(this);

            if (hierarchicalGroupByControlNode == null)
            {
                throw new DataGridInternalException("hierarchicalGroupByControlNode is null.");
            }

            bool allowGroupingModification = hierarchicalGroupByControlNode.IsGroupingModificationAllowed;

            if (!allowGroupingModification)
            {
                return;
            }

            ObservableCollection <GroupDescription> groupDescriptions = this.ParentGroupDescriptions;

            if (groupDescriptions != null)
            {
                // Get the HierarchicalGroupByControl before removing us from it
                HierarchicalGroupByControl parentGBC = GroupingHelper.GetHierarchicalGroupByControl(this);

                GroupLevelDescription groupLevelDescription = this.Content as GroupLevelDescription;

                DataGridContext dataGridContext = DataGridControl.GetDataGridContext(this);

                DataGridControl parentDataGridControl = (dataGridContext != null)
          ? dataGridContext.DataGridControl
          : null;

                GroupingHelper.RemoveGroupDescription(groupDescriptions, groupLevelDescription, parentDataGridControl);

                // Notify groups have changed for NoGroupContent
                parentGBC.UpdateHasGroups();

                // Update the HasGroups property
                Debug.Assert(parentGBC != null);
                if (parentGBC == null)
                {
                    throw new DataGridInternalException("The hierarchical group-by item must be rooted by a HierarchicalGroupByControl.");
                }
            }
        }
示例#3
0
        void IDropTarget.DragLeave(UIElement draggedElement)
        {
            ColumnManagerCell cell = draggedElement as ColumnManagerCell;

            if (cell != null)
            {
                DataGridContext draggedCellDataGridContext = DataGridControl.GetDataGridContext(cell);

                HierarchicalGroupByControlNode draggedOverHierarchicalGroupByControlNode = HierarchicalGroupByItem.GetParentHierarchicalGroupByControlNode(this);

                if (draggedOverHierarchicalGroupByControlNode == null)
                {
                    throw new DataGridInternalException("We should never be dragged over and not contained inside a HierarchicalGroupByControlNode.");
                }

                if (draggedOverHierarchicalGroupByControlNode.GroupLevelDescriptions == draggedCellDataGridContext.GroupLevelDescriptions)
                {
                    this.HideDropMark();
                }
                else
                {
                    // This ColumnManagerCell does not belong this parent HierarchicalGroupByControlNode, display the DropMark on the correct one
                    HierarchicalGroupByControl parentGBC = GroupingHelper.GetHierarchicalGroupByControl(draggedOverHierarchicalGroupByControlNode);

                    if (parentGBC == null)
                    {
                        throw new DataGridInternalException("A hierarchical group-by item must be rooted by a HierarchicalGroupByControl.");
                    }

                    HierarchicalGroupByControlNode hierarchicalGroupByControlNode = parentGBC.GetHierarchicalGroupByControlNodeFromColumnManagerCell(cell);

                    Debug.Assert(hierarchicalGroupByControlNode != null, "CanDrop should have returned false");
                    if (hierarchicalGroupByControlNode == null)
                    {
                        throw new DataGridInternalException("A HierarchicalGroupByControlNode must exist for every level.");
                    }

                    hierarchicalGroupByControlNode.HideFarDropMark(cell);
                }
            }
            else
            {
                HierarchicalGroupByItem hierarchicalGroupByItem = draggedElement as HierarchicalGroupByItem;

                if (hierarchicalGroupByItem == null)
                {
                    return;
                }

                HierarchicalGroupByControlNode draggedHierarchicalGroupByControlNode = HierarchicalGroupByItem.GetParentHierarchicalGroupByControlNode(hierarchicalGroupByItem);

                HierarchicalGroupByControlNode draggedOverHierarchicalGroupByControlNode = HierarchicalGroupByItem.GetParentHierarchicalGroupByControlNode(this);

                if (draggedHierarchicalGroupByControlNode == null)
                {
                    throw new DataGridInternalException("draggedHierarchicalGroupByControlNode is null.");
                }

                if (draggedOverHierarchicalGroupByControlNode == null)
                {
                    throw new DataGridInternalException("draggedOverHierarchicalGroupByControlNode is null.");
                }

                if (draggedHierarchicalGroupByControlNode.GroupLevelDescriptions == draggedOverHierarchicalGroupByControlNode.GroupLevelDescriptions)
                {
                    this.HideDropMark();
                }
                else
                {
                    // This HierarchicalGroupByItem does not belong this parent HierarchicalGroupByControlNode, display the DropMark on the correct one
                    HierarchicalGroupByControl parentGBC = GroupingHelper.GetHierarchicalGroupByControl(draggedOverHierarchicalGroupByControlNode);

                    Debug.Assert(parentGBC != null);
                    if (parentGBC == null)
                    {
                        throw new DataGridInternalException("A hierarchical group-by item must be rooted by a HierarchicalGroupByControl.");
                    }

                    HierarchicalGroupByControlNode hierarchicalGroupByControlNode = parentGBC.GetHierarchicalGroupByControlNodeFromHierarchicalGroupByItem(hierarchicalGroupByItem);

                    Debug.Assert(hierarchicalGroupByControlNode != null, "CanDrop should have returned false");
                    if (hierarchicalGroupByControlNode == null)
                    {
                        throw new DataGridInternalException("A HierarchicalGroupByControlNode must exist for every level.");
                    }

                    hierarchicalGroupByControlNode.HideFarDropMark();
                }
            }
        }
示例#4
0
        bool IDropTarget.CanDropElement(UIElement draggedElement)
        {
            bool canDrop = true;

            // Check if this HierarchicalGroupByItem parent HierarchicalGroupByControlNode allows grouping modifications, default yes
            HierarchicalGroupByControlNode parentHierarchicalGroupByControlNode = HierarchicalGroupByItem.GetParentHierarchicalGroupByControlNode(this);

            if (parentHierarchicalGroupByControlNode != null)
            {
                canDrop = parentHierarchicalGroupByControlNode.IsGroupingModificationAllowed;
            }

            ColumnManagerCell cell = draggedElement as ColumnManagerCell;

            HierarchicalGroupByItem hierarchicalGroupByItem = null;

            if (canDrop)
            {
                if (cell != null)
                {
                    ColumnBase parentColumn = cell.ParentColumn;

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

                    // Check if already grouped using the cell's DataGridContext
                    canDrop = !GroupingHelper.IsAlreadyGroupedBy(cell);

                    if (canDrop)
                    {
                        // Get the HierarchicalGroupByControl for this HierarchicalGroupByItem
                        HierarchicalGroupByControl parentGBC = GroupingHelper.GetHierarchicalGroupByControl(parentHierarchicalGroupByControlNode);

                        if (parentGBC == null)
                        {
                            throw new DataGridInternalException("The hierarchical group-by item must be rooted by a HierarchicalGroupByControl.");
                        }

                        DataGridContext parentGBCDataGridContext = DataGridControl.GetDataGridContext(parentGBC);

                        if (parentGBCDataGridContext.Items != null)
                        {
                            canDrop = parentGBCDataGridContext.Items.CanGroup;
                        }

                        if (canDrop)
                        {
                            canDrop = GroupingHelper.IsColumnManagerCellInDataGridContext(parentGBCDataGridContext, cell);

                            if (canDrop == true)
                            {
                                canDrop = GroupingHelper.ValidateMaxGroupDescriptions(DataGridControl.GetDataGridContext(draggedElement));
                            }
                        }
                    }
                }
                else
                {
                    hierarchicalGroupByItem = draggedElement as HierarchicalGroupByItem;

                    if (hierarchicalGroupByItem == null)
                    {
                        canDrop = false;
                    }

                    if (canDrop)
                    {
                        HierarchicalGroupByControl parentGBC = GroupingHelper.GetHierarchicalGroupByControl(parentHierarchicalGroupByControlNode);

                        if (parentGBC == null)
                        {
                            throw new DataGridInternalException("The hierarchical group-by item must be rooted by a HierarchicalGroupByControl.");
                        }

                        // Try to get the HierarchicalGroupByControlNode in which this HierarchicalGroupByItem can be added using the parent HierarchicalGroupByControl => null it can't
                        HierarchicalGroupByControlNode draggedHierarchicalGroupByControlNode = parentGBC.GetHierarchicalGroupByControlNodeFromHierarchicalGroupByItem(hierarchicalGroupByItem);

                        if (draggedHierarchicalGroupByControlNode == null)
                        {
                            canDrop = false;
                        }
                    }
                }
            }


            bool returnedValue = ((cell != null) || (hierarchicalGroupByItem != null)) && // ColumnManagerCell or HierarchicalGroupByItem
                                 (draggedElement != this) &&
                                 (canDrop);


            return(returnedValue);
        }
        void IDropTarget.DragOver(UIElement draggedElement, Point mousePosition)
        {
            ColumnManagerCell cell = draggedElement as ColumnManagerCell;

            if (cell != null)
            {
                HierarchicalGroupByControl parentGBC = GroupingHelper.GetHierarchicalGroupByControl(this);

                if (parentGBC == null)
                {
                    throw new DataGridInternalException("The hierarchical group-by control node must be rooted by a HierarchicalGroupByControl.");
                }

                HierarchicalGroupByControlNode hierarchicalGroupByControlNode = parentGBC.GetHierarchicalGroupByControlNodeFromColumnManagerCell(cell);

                if (hierarchicalGroupByControlNode == null)
                {
                    throw new DataGridInternalException("A HierarchicalGroupByControlNode must exist for every level.");
                }

                hierarchicalGroupByControlNode.ShowFarDropMark(cell, mousePosition);
            }
            else
            {
                HierarchicalGroupByItem hierarchicalGroupByItem = draggedElement as HierarchicalGroupByItem;
                if (hierarchicalGroupByItem == null)
                {
                    return;
                }

                HierarchicalGroupByControlNode draggedHierarchicalGroupByControlNode = HierarchicalGroupByItem.GetParentHierarchicalGroupByControlNode(hierarchicalGroupByItem);

                if (draggedHierarchicalGroupByControlNode == null)
                {
                    throw new DataGridInternalException("draggedHierarchicalGroupByControlNode is null.");
                }

                if (draggedHierarchicalGroupByControlNode.GroupLevelDescriptions == this.GroupLevelDescriptions)
                {
                    this.ShowFarDropMark(mousePosition);
                }
                else
                {
                    // This HierarchicalGroupByItem does not belong this parent HierarchicalGroupByControlNode, display the DropMark on the correct one
                    HierarchicalGroupByControl parentGBC = GroupingHelper.GetHierarchicalGroupByControl(this);

                    if (parentGBC == null)
                    {
                        throw new DataGridInternalException("The hierarchical group-by control node must be rooted by a HierarchicalGroupByControl.");
                    }

                    HierarchicalGroupByControlNode hierarchicalGroupByControlNode = parentGBC.GetHierarchicalGroupByControlNodeFromHierarchicalGroupByItem(hierarchicalGroupByItem);

                    Debug.Assert(hierarchicalGroupByControlNode != null, "CanDrop should have returned false");
                    if (hierarchicalGroupByControlNode == null)
                    {
                        throw new DataGridInternalException("A HierarchicalGroupByControlNode must exist for every level.");
                    }

                    hierarchicalGroupByControlNode.ShowFarDropMark(mousePosition);
                }
            }
        }