void IDropTarget.Drop(UIElement draggedElement, RelativePoint mousePosition) { ColumnManagerCell cell = draggedElement as ColumnManagerCell; if (cell == null) { return; } HierarchicalGroupByControlNode hierarchicalGroupByControlNode = this.GetHierarchicalGroupByControlNodeFromColumnManagerCell(cell); // It may not be visible if (hierarchicalGroupByControlNode != null) { hierarchicalGroupByControlNode.HideFarDropMark(cell); } DataGridContext dataGridContext = DataGridControl.GetDataGridContext(this); DataGridControl parentGrid = (dataGridContext != null) ? dataGridContext.DataGridControl : null; GroupingHelper.AppendNewGroupFromColumnManagerCell(cell, parentGrid); // Notify groups have changed for NoGroupContent this.UpdateHasGroups(); }
bool IDropTarget.CanDropElement(UIElement draggedElement, RelativePoint mousePosition) { var draggedCell = draggedElement as ColumnManagerCell; if (draggedCell == null) { return(false); } var manager = draggedCell.DragSourceManager as ColumnReorderingDragSourceManager; if ((manager != null) && manager.IsAnimatedColumnReorderingEnabled && draggedCell.IsBeingDragged) { var dataGridContext = DataGridControl.GetDataGridContext(this); if ((dataGridContext == null) || !dataGridContext.Columns.Contains(draggedCell.ParentColumn)) { return(false); } // We are not interested by the y-axis. var relativePoint = mousePosition.GetPoint(this); var xPosition = new RelativePoint(this, new Point(relativePoint.X, this.ActualHeight / 2d)); var targetCell = (from dropTarget in manager.GetDropTargetsAtPoint(xPosition) let dropCell = dropTarget as ColumnManagerCell where (dropCell != null) select dropCell).FirstOrDefault(); if ((targetCell == null) || (targetCell == draggedCell) || (( IDropTarget )targetCell).CanDropElement(draggedElement, xPosition)) { return(true); } } return(false); }
void IDropTarget.DragOver(UIElement draggedElement, RelativePoint mousePosition) { var cell = draggedElement as ColumnManagerCell; if (cell == null) { return; } var draggedElementContext = DataGridControl.GetDataGridContext(draggedElement); var lastIndex = draggedElementContext.GroupLevelDescriptions.Count - 1; if (lastIndex < 0) { return; } var groupByItem = this.ItemContainerGenerator.ContainerFromIndex(lastIndex) as GroupByItem; if (groupByItem == null) { throw new DataGridInternalException("groupByItem is null."); } groupByItem.ShowDropMark(mousePosition); }
void IDropTarget.DragOver(UIElement draggedElement, RelativePoint mousePosition) { ColumnManagerCell cell = draggedElement as ColumnManagerCell; if (cell != null) { HierarchicalGroupByControlNode hierarchicalGroupByControlNode = this.GetHierarchicalGroupByControlNodeFromColumnManagerCell(cell); // It may not be visible if (hierarchicalGroupByControlNode != null) { hierarchicalGroupByControlNode.ShowFarDropMark(cell, mousePosition); } } else { HierarchicalGroupByItem hierarchicalGroupByItem = draggedElement as HierarchicalGroupByItem; if (hierarchicalGroupByItem == null) { return; } HierarchicalGroupByControlNode hierarchicalGroupByControlNode = this.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); } }
void IDropTarget.Drop(UIElement draggedElement, RelativePoint mousePosition) { var cell = draggedElement as ColumnManagerCell; if (cell == null) { return; } var draggedElementContext = DataGridControl.GetDataGridContext(draggedElement); var lastIndex = draggedElementContext.GroupLevelDescriptions.Count - 1; if (lastIndex >= 0) { var groupByItem = this.ItemContainerGenerator.ContainerFromIndex(lastIndex) as GroupByItem; if (groupByItem == null) { throw new DataGridInternalException("groupByItem is null."); } groupByItem.HideDropMark(); } var dataGridContext = DataGridControl.GetDataGridContext(this); var dataGridControl = (dataGridContext != null) ? dataGridContext.DataGridControl : null; GroupingHelper.AppendNewGroupFromColumnManagerCell(cell, dataGridControl); }
internal void ShowDropMark(RelativePoint mousePosition) { if (m_dropMarkAdorner == null) { var dataGridContext = this.DataGridContext; var grid = (dataGridContext != null) ? dataGridContext.DataGridControl : null; Pen pen = UIViewBase.GetDropMarkPen(this); if ((pen == null) && (grid != null)) { UIViewBase uiViewBase = grid.GetView() as UIViewBase; pen = uiViewBase.DefaultDropMarkPen; } DropMarkOrientation orientation = UIViewBase.GetDropMarkOrientation(this); if ((orientation == DropMarkOrientation.Default) && (grid != null)) { UIViewBase uiViewBase = grid.GetView() as UIViewBase; orientation = uiViewBase.DefaultDropMarkOrientation; } m_dropMarkAdorner = new DropMarkAdorner(this, pen, orientation); AdornerLayer adornerLayer = AdornerLayer.GetAdornerLayer(this); if (adornerLayer != null) { adornerLayer.Add(m_dropMarkAdorner); } } m_dropMarkAdorner.UpdateAlignment(mousePosition); }
internal void ProcessDrop(ColumnManagerCell draggedCell, RelativePoint mousePosition) { var manager = default(ColumnReorderingDragSourceManager); if (draggedCell != null) { manager = draggedCell.DragSourceManager as ColumnReorderingDragSourceManager; } if ((manager != null) && (manager.IsAnimatedColumnReorderingEnabled)) { manager.CommitReordering(); } else { this.HideDropMark(); var dataGridContext = this.DataGridContext; Debug.Assert(dataGridContext != null); if (dataGridContext != null) { var targetColumn = draggedCell.ParentColumn; var pivotColumn = this.ParentColumn; Debug.Assert(targetColumn != null); Debug.Assert(pivotColumn != null); var relativePosition = mousePosition.GetPoint(this); var offset = Point.Subtract(mousePosition.GetPoint(draggedCell), relativePosition); var moveBefore = true; // We assumme the cells are layouted horizontally. if (Math.Abs(offset.X) >= Math.Abs(offset.Y)) { // Consider the case where the columns are layouted from left to right in reverse order. var reverse = ((offset.X > 0d) == (targetColumn.VisiblePosition >= pivotColumn.VisiblePosition)); moveBefore = ((relativePosition.X < this.ActualWidth / 2d) != reverse); } // We assume the cells are layouted vertically. else { // Consider the case where the columns are layouted from top to bottom in reverse order. var reverse = ((offset.Y > 0d) == (targetColumn.VisiblePosition >= pivotColumn.VisiblePosition)); moveBefore = ((relativePosition.Y < this.ActualHeight / 2d) != reverse); } var success = (moveBefore) ? dataGridContext.MoveColumnBefore(targetColumn, pivotColumn) : dataGridContext.MoveColumnAfter(targetColumn, pivotColumn); Debug.Assert(success); } } }
void IDropTarget.Drop(UIElement draggedElement, RelativePoint mousePosition) { var draggedCell = draggedElement as ColumnManagerCell; if (draggedCell == null) { return; } this.ProcessDrop(draggedCell, mousePosition); }
internal void ShowFarDropMark(ColumnManagerCell cell, RelativePoint mousePosition) { Debug.Assert(cell != null); if (cell == null) { return; } DataGridContext cellDataGridContext = DataGridControl.GetDataGridContext(cell); Debug.Assert(cellDataGridContext != null); if (cellDataGridContext == null) { throw new DataGridInternalException("DataGridContext cannot be null on ColumnManagerCell."); } // We already have GroupLevelDescriptions for this level, we should show DropMark on the last HierarchicalGroupByItem if (cellDataGridContext.GroupLevelDescriptions.Count > 0) { Debug.Assert(cellDataGridContext.GroupLevelDescriptions == this.GroupLevelDescriptions); if (cellDataGridContext.GroupLevelDescriptions != this.GroupLevelDescriptions) { return; } int lastIndex = this.GroupLevelDescriptions.Count - 1; // If there if (lastIndex > -1) { HierarchicalGroupByItem hierarchicalGroupByItem = this.ItemContainerGenerator.ContainerFromItem(this.GroupLevelDescriptions[lastIndex]) as HierarchicalGroupByItem; Debug.Assert(hierarchicalGroupByItem != null); if (hierarchicalGroupByItem == null) { return; } hierarchicalGroupByItem.ShowFarDropMark(mousePosition); } else { this.ShowFarDropMark(mousePosition); } } else { this.ShowFarDropMark(mousePosition); } }
internal void UpdateAlignment(RelativePoint mousePosition) { var relativePosition = mousePosition.GetPoint(this.AdornedElement); var elementSize = this.AdornedElement.RenderSize; if (m_orientation == DropMarkOrientation.Horizontal) { this.Alignment = (relativePosition.Y < elementSize.Height / 2d) ? DropMarkAlignment.Near : DropMarkAlignment.Far; } else { this.Alignment = (relativePosition.X < elementSize.Width / 2d) ? DropMarkAlignment.Near : DropMarkAlignment.Far; } }
bool IDropTarget.CanDropElement(UIElement draggedElement, RelativePoint mousePosition) { var allowGroupingModification = true; var parentGBC = this.GetParentGroupByControl(); if (parentGBC != null) { allowGroupingModification = parentGBC.IsGroupingModificationAllowed; } // We don't accept any ColumnManagerCell from Details var context = DataGridControl.GetDataGridContext(draggedElement); var cell = draggedElement as ColumnManagerCell; var isAlreadyGroupedBy = false; if (cell != null) { isAlreadyGroupedBy = GroupingHelper.IsAlreadyGroupedBy(cell); var parentColumn = cell.ParentColumn; if ((parentColumn == null) || (!parentColumn.AllowGroup)) { return(false); } } var sourceDetailContext = DataGridControl.GetDataGridContext(this); Debug.Assert(sourceDetailContext != null); var sourceDetailConfig = (sourceDetailContext != null) ? sourceDetailContext.SourceDetailConfiguration : null; var draggedDetailContext = DataGridControl.GetDataGridContext(draggedElement); Debug.Assert(draggedDetailContext != null); var draggedDetailConfig = (draggedDetailContext != null) ? draggedDetailContext.SourceDetailConfiguration : null; var canDrop = (sourceDetailConfig == draggedDetailConfig) && (allowGroupingModification) && ((draggedElement is ColumnManagerCell) || (draggedElement is GroupByItem)) && (draggedElement != this) && (isAlreadyGroupedBy == false); if (canDrop && (cell != null)) { canDrop = GroupingHelper.ValidateMaxGroupDescriptions(draggedDetailContext); } return(canDrop); }
void IDropTarget.Drop(UIElement draggedElement, RelativePoint mousePosition) { var draggedCell = draggedElement as ColumnManagerCell; if (draggedCell == null) { return; } var manager = draggedCell.DragSourceManager as ColumnReorderingDragSourceManager; if ((manager != null) && (manager.IsAnimatedColumnReorderingEnabled)) { manager.CommitReordering(); } }
void IDropTarget.DragOver(UIElement draggedElement, RelativePoint mousePosition) { var draggedCell = draggedElement as ColumnManagerCell; if (draggedCell != null) { var manager = draggedCell.DragSourceManager as ColumnReorderingDragSourceManager; // No need for drop mark when performing animated Column reordering if ((manager != null) && (manager.IsAnimatedColumnReorderingEnabled)) { return; } } this.ShowDropMark(mousePosition); }
private void ShowDropMark(RelativePoint mousePosition, DropMarkAlignment defaultAlignment, bool forceDefaultAlignment) { if (m_dropMarkAdorner == null) { DataGridContext dataGridContext = DataGridControl.GetDataGridContext(this); DataGridControl grid = (dataGridContext != null) ? dataGridContext.DataGridControl : null; Pen pen = UIViewBase.GetDropMarkPen(this); if ((pen == null) && (grid != null)) { UIViewBase uiViewBase = grid.GetView() as UIViewBase; pen = uiViewBase.DefaultDropMarkPen; } DropMarkOrientation orientation = Xceed.Wpf.DataGrid.Views.UIViewBase.GetDropMarkOrientation(this); if ((orientation == DropMarkOrientation.Default) && (grid != null)) { UIViewBase uiViewBase = grid.GetView() as UIViewBase; orientation = uiViewBase.DefaultDropMarkOrientation; } m_dropMarkAdorner = new DropMarkAdorner(this, pen, orientation); AdornerLayer adornerLayer = AdornerLayer.GetAdornerLayer(this); if (adornerLayer != null) { adornerLayer.Add(m_dropMarkAdorner); } } if (forceDefaultAlignment) { m_dropMarkAdorner.Alignment = defaultAlignment; } else { m_dropMarkAdorner.UpdateAlignment(mousePosition); } }
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); } } }
bool IDropTarget.CanDropElement(UIElement draggedElement, RelativePoint mousePosition) { var isAlreadyGroupedBy = false; var cell = draggedElement as ColumnManagerCell; if (cell != null) { isAlreadyGroupedBy = GroupingHelper.IsAlreadyGroupedBy(cell); var parentColumn = cell.ParentColumn; if ((parentColumn == null) || (!parentColumn.AllowGroup)) { return(false); } } var sourceDetailContext = DataGridControl.GetDataGridContext(this); Debug.Assert(sourceDetailContext != null); var sourceDetailConfig = (sourceDetailContext != null) ? sourceDetailContext.SourceDetailConfiguration : null; var draggedElementContext = DataGridControl.GetDataGridContext(draggedElement); Debug.Assert(draggedElementContext != null); var draggedDetailConfig = (draggedElementContext != null) ? draggedElementContext.SourceDetailConfiguration : null; var canDrop = (sourceDetailConfig == draggedDetailConfig) && (sourceDetailContext != null) && (draggedElementContext != null) && (sourceDetailContext.GroupLevelDescriptions == draggedElementContext.GroupLevelDescriptions) && (this.IsGroupingModificationAllowed) && ((draggedElement is ColumnManagerCell) || (draggedElement is GroupByItem)) && (!isAlreadyGroupedBy); if (canDrop && (cell != null)) { canDrop = GroupingHelper.ValidateMaxGroupDescriptions(draggedElementContext); } return(canDrop); }
internal void ShowDropMark(RelativePoint mousePosition) { if (m_dropMarkAdorner == null) { var dataGridContext = DataGridControl.GetDataGridContext(this); var dataGridControl = (dataGridContext != null) ? dataGridContext.DataGridControl : null; var pen = UIViewBase.GetDropMarkPen(this); if ((pen == null) && (dataGridControl != null)) { var uiViewBase = dataGridControl.GetView() as UIViewBase; if (uiViewBase != null) { pen = uiViewBase.DefaultDropMarkPen; } } var orientation = UIViewBase.GetDropMarkOrientation(this); if ((orientation == DropMarkOrientation.Default) && (dataGridControl != null)) { var uiViewBase = dataGridControl.GetView() as UIViewBase; if (uiViewBase != null) { orientation = uiViewBase.DefaultDropMarkOrientation; } } m_dropMarkAdorner = new DropMarkAdorner(this, pen, orientation); var adornerLayer = AdornerLayer.GetAdornerLayer(this); if (adornerLayer != null) { adornerLayer.Add(m_dropMarkAdorner); } } m_dropMarkAdorner.UpdateAlignment(mousePosition); }
void IDropTarget.Drop(UIElement draggedElement, RelativePoint mousePosition) { ColumnManagerCell cell = draggedElement as ColumnManagerCell; if (cell == null) { return; } HierarchicalGroupByControl parentGBC = GroupingHelper.GetHierarchicalGroupByControl(this); if (parentGBC == null) { throw new DataGridInternalException("The hierarchical group-by control node must be rooted by a HierarchicalGroupByControl."); } DataGridContext dataGridContext = DataGridControl.GetDataGridContext(this); DataGridControl parentGrid = (dataGridContext != null) ? dataGridContext.DataGridControl : null; GroupingHelper.AppendNewGroupFromColumnManagerCell(cell, parentGrid); // Notify groups have changed for NoGroupContent parentGBC.UpdateHasGroups(); HierarchicalGroupByControlNode hierarchicalGroupByControlNode = parentGBC.GetHierarchicalGroupByControlNodeFromColumnManagerCell(cell); if (hierarchicalGroupByControlNode == null) { return; } hierarchicalGroupByControlNode.HideFarDropMark(cell); this.HideFarDropMark(); }
bool IDropTarget.CanDropElement(UIElement draggedElement, RelativePoint mousePosition) { bool canDrop = this.AllowGroupingModification; ColumnManagerCell cell = null; HierarchicalGroupByItem hierarchicalGroupByItem = null; if (canDrop) { cell = draggedElement as ColumnManagerCell; 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) { DataGridContext thisDataGridContext = DataGridControl.GetDataGridContext(this); if (thisDataGridContext.Items != null) { canDrop = thisDataGridContext.Items.CanGroup; } if (canDrop) { canDrop = GroupingHelper.IsColumnManagerCellInDataGridContext(thisDataGridContext, cell); if (canDrop == true) { canDrop = GroupingHelper.ValidateMaxGroupDescriptions(DataGridControl.GetDataGridContext(draggedElement)); } } } } else { hierarchicalGroupByItem = draggedElement as HierarchicalGroupByItem; if (hierarchicalGroupByItem == null) { canDrop = false; } if (canDrop) { // Try to get the HierarchicalGroupByControlNode in which this HierarchicalGroupByItem can be added using the parent HierarchicalGroupByControl => null it can't HierarchicalGroupByControlNode draggedHierarchicalGroupByControlNode = this.GetHierarchicalGroupByControlNodeFromHierarchicalGroupByItem(hierarchicalGroupByItem); if (draggedHierarchicalGroupByControlNode == null) { canDrop = false; } } } } bool returnedValue = ((cell != null) || (hierarchicalGroupByItem != null)) && // ColumnManagerCell or HierarchicalGroupByItem (canDrop); return(returnedValue); }
void IDropTarget.DragOver(UIElement draggedElement, RelativePoint mousePosition) { }
internal void ShowFarDropMark(RelativePoint mousePosition) { this.ShowDropMark(mousePosition, DropMarkAlignment.Far, true); }
void IDropTarget.Drop(UIElement draggedElement, RelativePoint mousePosition) { 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(); }
void IDropTarget.DragOver(UIElement draggedElement, RelativePoint 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); } } }
bool IDropTarget.CanDropElement(UIElement draggedElement, RelativePoint mousePosition) { var draggedCell = draggedElement as ColumnManagerCell; if ((draggedCell == null) || (this == draggedCell)) { return(false); } var parentRow = this.ParentRow as ColumnManagerRow; if ((parentRow == null) || !parentRow.AllowColumnReorder) { return(false); } var draggedDetailContext = draggedCell.DataGridContext; var sourceDetailContext = this.DataGridContext; Debug.Assert((draggedDetailContext != null) && (sourceDetailContext != null)); if ((sourceDetailContext.SourceDetailConfiguration != draggedDetailContext.SourceDetailConfiguration) || (sourceDetailContext.GroupLevelDescriptions != draggedDetailContext.GroupLevelDescriptions)) { return(false); } if (!ColumnManagerCell.CanMove(draggedCell)) { return(false); } var manager = draggedCell.DragSourceManager as ColumnReorderingDragSourceManager; if ((manager != null) && (manager.IsAnimatedColumnReorderingEnabled)) { if (!manager.CanReorder(draggedCell, this, mousePosition)) { return(false); } } else { var relativePosition = mousePosition.GetPoint(this); var moveBefore = (relativePosition.X <= this.ActualWidth / 2d); if (moveBefore) { if (!draggedCell.CanMoveBefore(this.ParentColumn)) { return(false); } } else { if (!draggedCell.CanMoveAfter(this.ParentColumn)) { return(false); } } } return(true); }
internal void ShowFarDropMark(RelativePoint mousePosition) { int itemsCount = this.Items.Count; if (itemsCount < 1) { if (m_dropMarkAdorner == null) { DataGridContext dataGridContext = DataGridControl.GetDataGridContext(this); DataGridControl grid = (dataGridContext != null) ? dataGridContext.DataGridControl : null; Pen pen = UIViewBase.GetDropMarkPen(this); if ((pen == null) && (grid != null)) { UIViewBase uiViewBase = grid.GetView() as UIViewBase; pen = uiViewBase.DefaultDropMarkPen; } DropMarkOrientation orientation = UIViewBase.GetDropMarkOrientation(this); if ((orientation == DropMarkOrientation.Default) && (grid != null)) { UIViewBase uiViewBase = grid.GetView() as UIViewBase; orientation = uiViewBase.DefaultDropMarkOrientation; } m_dropMarkAdorner = new DropMarkAdorner(this, pen, orientation); AdornerLayer adornerLayer = AdornerLayer.GetAdornerLayer(this); if (adornerLayer != null) { adornerLayer.Add(m_dropMarkAdorner); } } // We Only want the drop mark to be displayed at the end of the HierarchicalGroupByControlNode m_dropMarkAdorner.Alignment = DropMarkAlignment.Far; } else { HierarchicalGroupByItem hierarchicalGroupByItem = this.ItemContainerGenerator.ContainerFromIndex(itemsCount - 1) as HierarchicalGroupByItem; Debug.Assert(hierarchicalGroupByItem != null); GroupLevelDescription groupLevelDescription = hierarchicalGroupByItem.Content as GroupLevelDescription; Debug.Assert(groupLevelDescription != null); // Show Far DropMark only if not already grouped if (!this.Items.Contains(groupLevelDescription)) { hierarchicalGroupByItem.ShowFarDropMark(mousePosition); } } }
private void ShowDropMark(RelativePoint mousePosition) { this.ShowDropMark(mousePosition, DropMarkAlignment.Far, false); }
bool IDropTarget.CanDropElement(UIElement draggedElement, RelativePoint mousePosition) { ColumnManagerCell cell = null; HierarchicalGroupByItem hierarchicalGroupByItem = null; bool canDrop = this.AllowGroupingModification; if (canDrop) { cell = draggedElement as ColumnManagerCell; 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 HierarchicalGroupByControlNode HierarchicalGroupByControl parentGBC = GroupingHelper.GetHierarchicalGroupByControl(this); if (parentGBC == null) { throw new DataGridInternalException("The hierarchical group-by control node must be rooted by a HierarchicalGroupByControl."); } DataGridContext parentGBCDataGridContext = DataGridControl.GetDataGridContext(parentGBC); Debug.Assert(parentGBCDataGridContext != null); 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(this); if (parentGBC == null) { throw new DataGridInternalException("The hierarchical group-by control node 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 (canDrop); return(returnedValue); }
void IDropTarget.DragOver(UIElement draggedElement, RelativePoint mousePosition) { this.ShowDropMark(mousePosition); }