void IDragDropElement.OnDragDropComplete(DragCompleteContext dragContext)
        {
            if (dragContext != null)
            {
                var data = dragContext.PayloadData as DataGridColumnHeaderDragOperation;

                if (data != null && data.HeaderOwner != null)
                {
                    data.HeaderOwner.DragBehavior.OnDragDropCompleted(this, dragContext.DragSuccessful);

                    var columnReordered = dragContext.DragSuccessful && (dragContext.Destination is DataGridColumnHeader || dragContext.Destination is DataGridColumnHeaderPanel);

                    if (!columnReordered && this.reorderCoordinator != null)
                    {
                        this.reorderCoordinator.CancelReorderOperation(this, data.InitialSourceIndex);
                    }
                }

                var gridOwner = this.Owner as RadDataGrid;
                if (gridOwner != null)
                {
                    var gridPeer = FrameworkElementAutomationPeer.FromElement(gridOwner) as RadDataGridAutomationPeer;
                    if (gridPeer != null && gridPeer.childrenCache != null)
                    {
                        gridPeer.childrenCache = null;
                    }
                }
            }
        }
 void IDragDropElement.OnDragDropComplete(DragCompleteContext dragContext)
 {
     if (dragContext != null)
     {
         this.ParentGrid.DragBehavior.OnReorderCompleted(this, dragContext.DragSuccessful);
     }
 }
        void IDragDropElement.OnDragVisualCleared(DragCompleteContext dragContext)
        {
            this.Opacity = 1;

            if (this.Column != null)
            {
                this.Content = this.Column.Header;
            }

            if (this.Owner != null)
            {
                this.Owner.InvalidateHeadersMeasure();
                this.Owner.updateService.RegisterUpdate(UpdateFlags.AffectsColumnsWidth);
            }
        }
Пример #4
0
        private void FinalizeReorder(DragCompleteContext context)
        {
            if (context != null)
            {
                var data = context.PayloadData as ReorderItemsDragOperation;

                if (data != null)
                {
                    this.ListView.DragBehavior.OnDragDropCompleted(this, context.DragSuccessful);

                    var itemReordered = context.DragSuccessful;

                    if (!itemReordered && this.reorderCoordinator != null)
                    {
                        this.reorderCoordinator.CancelReorderOperation(this, data.InitialSourceIndex);
                    }
                }
            }
        }
Пример #5
0
        void IDragDropElement.OnDragDropComplete(DragCompleteContext dragContext)
        {
            if (dragContext != null)
            {
                var data = dragContext.PayloadData as DataGridColumnHeaderDragOperation;

                if (data != null && data.HeaderOwner != null)
                {
                    data.HeaderOwner.DragBehavior.OnDragDropCompleted(this, dragContext.DragSuccessful);

                    var columnReordered = dragContext.DragSuccessful && (dragContext.Destination is DataGridColumnHeader || dragContext.Destination is DataGridColumnHeaderPanel);

                    if (!columnReordered && this.reorderCoordinator != null)
                    {
                        this.reorderCoordinator.CancelReorderOperation(this, data.InitialSourceIndex);
                    }
                }
            }
        }
 void IDragDropElement.OnDragVisualCleared(DragCompleteContext dragContext)
 {
     this.IsHitTestVisible = true;
     this.Opacity          = 1;
 }
Пример #7
0
 void IDragDropElement.OnDragVisualCleared(DragCompleteContext dragContext)
 {
 }
Пример #8
0
 void IDragDropElement.OnDragDropComplete(DragCompleteContext dragContext)
 {
 }
Пример #9
0
        void IDragDropElement.OnDragDropComplete(DragCompleteContext context)
        {
            var data = context.PayloadData as ReorderItemsDragOperation;

            if (data != null)
            {
                this.FinalizeReorder(context);

                object destinationDataItem = this.GetDestinationDataItem(data);
                bool   isExecuted          = this.ListView.commandService.ExecuteCommand(CommandId.ItemReorderComplete, new ItemReorderCompleteContext(data.Data, destinationDataItem, this));
            }
            else
            {
                if (context.DragSuccessful)
                {
                    double offset   = 0;
                    var    dragMode = DragDrop.GetDragPositionMode(this);

                    if (this.ListView.Orientation == Orientation.Horizontal)
                    {
                        switch (dragMode)
                        {
                        case DragPositionMode.RailXForward:
                            offset = Math.Max(0, this.dragY);
                            break;

                        case DragPositionMode.RailXBackwards:
                            offset = Math.Min(0, dragY);
                            break;

                        case DragPositionMode.RailX:
                            offset = this.dragY;
                            break;

                        default:
                            break;
                        }
                    }
                    else
                    {
                        switch (dragMode)
                        {
                        case DragPositionMode.RailXForward:
                            offset = Math.Max(0, this.dragX);
                            break;

                        case DragPositionMode.RailXBackwards:
                            offset = Math.Min(0, dragX);
                            break;

                        case DragPositionMode.RailX:
                            offset = this.dragX;
                            break;

                        default:
                            break;
                        }
                    }
                    var swipeContext = new ItemSwipeActionCompleteContext(this.DataContext, this, offset);

                    bool isExecuted = this.ListView.commandService.ExecuteCommand(CommandId.ItemSwipeActionComplete, swipeContext);

                    if (isExecuted)
                    {
                        this.UpdateActionContentClipping(swipeContext.FinalDragOffset);
                        this.isDraggedForAction  = true;
                        this.ListView.swipedItem = this;
                    }
                    else
                    {
                        this.ClearActionContent();
                    }
                }
                else
                {
                    this.ClearActionContent();
                    this.ListView.CleanupSwipedItem();
                }
            }
            this.Opacity = 1;

            DragDrop.SetDragPositionMode(this, DragPositionMode.Free);
            this.ListView.InvalidatePanelArrange();
        }
        void IDragDropElement.OnDragDropComplete(DragCompleteContext context)
        {
            var data = context.PayloadData as ReorderItemsDragOperation;

            if (data != null)
            {
                this.FinalizeReorder(context);

                var                  isExecuted      = false;
                RadListViewItem      destinationItem = null;
                ItemReorderPlacement placement       = 0;

                if (data.InitialSourceIndex < data.CurrentSourceReorderIndex)
                {
                    destinationItem = this.reorderCoordinator.Host.ElementAt(data.CurrentSourceReorderIndex - 1) as RadListViewItem;
                    placement       = ItemReorderPlacement.After;

                    if (destinationItem == null)
                    {
                        destinationItem = this.reorderCoordinator.Host.ElementAt(data.CurrentSourceReorderIndex + 1) as RadListViewItem;
                        placement       = ItemReorderPlacement.Before;
                    }
                }
                else if (data.InitialSourceIndex > data.CurrentSourceReorderIndex)
                {
                    destinationItem = this.reorderCoordinator.Host.ElementAt(data.CurrentSourceReorderIndex + 1) as RadListViewItem;
                    placement       = ItemReorderPlacement.Before;

                    if (destinationItem == null)
                    {
                        destinationItem = this.reorderCoordinator.Host.ElementAt(data.CurrentSourceReorderIndex - 1) as RadListViewItem;
                        placement       = ItemReorderPlacement.After;
                    }
                }

                if (destinationItem != null)
                {
                    var dataItem            = data.Data;
                    var destinationDataItem = destinationItem.DataContext;

                    IDataGroup dataGroup            = null;
                    IDataGroup destinationDataGroup = null;

                    if (this.listView.GroupDescriptors.Count > 0)
                    {
                        dataGroup            = this.listView.Model.FindItemParentGroup(dataItem);
                        destinationDataGroup = this.listView.Model.FindItemParentGroup(destinationDataItem);
                    }

                    var commandContext = new ItemReorderCompleteContext(dataItem, dataGroup, destinationDataItem, destinationDataGroup, placement);

                    isExecuted = this.ListView.commandService.ExecuteCommand(CommandId.ItemReorderComplete, commandContext);
                }

                if (isExecuted)
                {
                    // TODO: Data provider does not handle well reordering of items in groups.
                    // Remove this workaround once we fix the reordering in the data provider.
                    if (this.listView.GroupDescriptors.Count > 0)
                    {
                        this.listView.updateService.RegisterUpdate((int)UpdateFlags.AffectsData);
                    }
                }
                else
                {
                    this.reorderCoordinator.CancelReorderOperation(this, data.InitialSourceIndex);
                }
            }
            else
            {
                if (context.DragSuccessful)
                {
                    double offset   = 0;
                    var    dragMode = DragDrop.GetDragPositionMode(this);

                    if (this.ListView.Orientation == Orientation.Horizontal)
                    {
                        switch (dragMode)
                        {
                        case DragPositionMode.RailXForward:
                            offset = Math.Max(0, this.dragY);
                            break;

                        case DragPositionMode.RailXBackwards:
                            offset = Math.Min(0, this.dragY);
                            break;

                        case DragPositionMode.RailX:
                            offset = this.dragY;
                            break;

                        default:
                            break;
                        }
                    }
                    else
                    {
                        switch (dragMode)
                        {
                        case DragPositionMode.RailXForward:
                            offset = Math.Max(0, this.dragX);
                            break;

                        case DragPositionMode.RailXBackwards:
                            offset = Math.Min(0, this.dragX);
                            break;

                        case DragPositionMode.RailX:
                            offset = this.dragX;
                            break;

                        default:
                            break;
                        }
                    }
                    var swipeContext = new ItemSwipeActionCompleteContext(this.DataContext, this, offset);

                    bool isExecuted = this.ListView.commandService.ExecuteCommand(CommandId.ItemSwipeActionComplete, swipeContext);

                    if (isExecuted)
                    {
                        this.UpdateActionContentClipping(swipeContext.FinalDragOffset);
                        this.isDraggedForAction  = true;
                        this.ListView.swipedItem = this;
                    }
                    else
                    {
                        this.ClearActionContent();
                    }
                }
                else
                {
                    this.ClearActionContent();
                    this.ListView.CleanupSwipedItem();
                }
            }
            this.Opacity = 1;

            DragDrop.SetDragPositionMode(this, DragPositionMode.Free);
            this.ListView.InvalidatePanelArrange();
        }