Example #1
0
        void IDropTarget.Drop(UIElement draggedElement, RelativePoint mousePosition)
        {
            if (m_dropMarkAdorner == null)
            {
                return;
            }

            var dataGridContext = DataGridControl.GetDataGridContext(this);

            if (dataGridContext == null)
            {
                return;
            }

            var draggedOverGroupLevelDescription = this.Content as GroupLevelDescription;

            if (draggedOverGroupLevelDescription == null)
            {
                return;
            }

            var alignment = m_dropMarkAdorner.Alignment;

            this.HideDropMark();

            var draggedCell = draggedElement as ColumnManagerCell;

            if (draggedCell != null)
            {
                GroupingHelper.AddNewGroupFromColumnManagerCell(draggedCell, draggedOverGroupLevelDescription, alignment, dataGridContext.DataGridControl);
            }
            else
            {
                var draggedGroupBy = draggedElement as GroupByItem;

                Debug.Assert(draggedGroupBy != null);

                if (draggedGroupBy != null)
                {
                    var draggedGroupLevelDescription = draggedGroupBy.Content as GroupLevelDescription;

                    GroupingHelper.MoveGroupDescription(dataGridContext.Columns, dataGridContext.Items.GroupDescriptions, draggedOverGroupLevelDescription, alignment, draggedGroupLevelDescription, dataGridContext.DataGridControl);
                }
            }
        }
Example #2
0
        void IDropTarget.Drop(UIElement draggedElement)
        {
            if (m_dropMarkAdorner != null)
            {
                DataGridContext dataGridContext = DataGridControl.GetDataGridContext(this);

                Debug.Assert(dataGridContext != null);
                if (dataGridContext != null)
                {
                    GroupLevelDescription draggedOverGroupLevelDescription = this.Content as GroupLevelDescription;

                    Debug.Assert(draggedOverGroupLevelDescription != null);
                    if (draggedOverGroupLevelDescription != null)
                    {
                        DropMarkAlignment alignment = m_dropMarkAdorner.Alignment;

                        this.HideDropMark();

                        ColumnManagerCell draggedCell = draggedElement as ColumnManagerCell;

                        if (draggedCell != null)
                        {
                            GroupingHelper.AddNewGroupFromColumnManagerCell(draggedCell, draggedOverGroupLevelDescription, alignment, dataGridContext.DataGridControl);
                        }
                        else
                        {
                            GroupByItem draggedGroupBy = draggedElement as GroupByItem;

                            Debug.Assert(draggedGroupBy != null);

                            if (draggedGroupBy != null)
                            {
                                GroupLevelDescription draggedGroupLevelDescription = draggedGroupBy.Content as GroupLevelDescription;

                                GroupingHelper.MoveGroupDescription(dataGridContext.Columns, dataGridContext.Items.GroupDescriptions, draggedOverGroupLevelDescription, alignment, draggedGroupLevelDescription, dataGridContext.DataGridControl);
                            }
                        }
                    }
                }
            }
        }
 public static void AppendNewGroupFromColumnManagerCell(ColumnManagerCell cell, DataGridControl parentDataGridControl)
 {
     GroupingHelper.AddNewGroupFromColumnManagerCell(cell, null, DropMarkAlignment.Far, parentDataGridControl);
 }
        void IDropTarget.Drop(UIElement draggedElement)
        {
            ColumnManagerCell draggedColumnManagerCell = draggedElement as ColumnManagerCell;

            if (m_dropMarkAdorner != null)
            {
                GroupLevelDescription draggedOverGroupLevelDescription = this.Content as GroupLevelDescription;

                DropMarkAlignment alignment = m_dropMarkAdorner.Alignment;
                this.HideDropMark();

                if (draggedColumnManagerCell != null)
                {
                    DataGridContext dataGridContext = DataGridControl.GetDataGridContext(this);

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

                    GroupingHelper.AddNewGroupFromColumnManagerCell(draggedColumnManagerCell, draggedOverGroupLevelDescription, alignment, parentGrid);
                }
                else
                {
                    HierarchicalGroupByItem draggedGroupByItem = draggedElement as HierarchicalGroupByItem;

                    if (draggedGroupByItem == null)
                    {
                        return;
                    }

                    GroupLevelDescription draggedGroupLevelDescription = draggedGroupByItem.Content as GroupLevelDescription;

                    DataGridContext dataGridContext = DataGridControl.GetDataGridContext(this);

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

                    GroupLevelDescription destinationGroupLevelDescription = this.Content as GroupLevelDescription;

                    GroupingHelper.MoveGroupDescription(this.ParentColumns, this.ParentGroupDescriptions,
                                                        destinationGroupLevelDescription, alignment,
                                                        draggedGroupLevelDescription, parentDataGridControl);
                }
            }
            else
            {
                // We try to add a new Group which is not in the current GroupLevelDescriptions
                if (draggedColumnManagerCell == null)
                {
                    return;
                }

                DataGridContext dataGridContext = DataGridControl.GetDataGridContext(this);

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

                GroupingHelper.AppendNewGroupFromColumnManagerCell(draggedColumnManagerCell, parentGrid);
            }

            HierarchicalGroupByControl parentGBC = GroupingHelper.GetHierarchicalGroupByControl(this);

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

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