Пример #1
0
        private static void OnIsSelectedChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
        {
            RadListViewItem item = d as RadListViewItem;

            item.isSelectedCache = (bool)e.NewValue;
            item.ChangeVisualState(true);
        }
Пример #2
0
        private static void OnIsHandleEnabled(DependencyObject d, DependencyPropertyChangedEventArgs e)
        {
            RadListViewItem item = d as RadListViewItem;

            item.IsHandleEnabled = (bool)e.NewValue;
            item.ChangeVisualState(true);
        }
Пример #3
0
        private static bool CanCapturePointer(RadListViewItem listViewItem, Pointer pointer)
        {
            if (listViewItem.CapturePointer(pointer))
            {
                listViewItem.ReleasePointerCapture(pointer);
                return(true);
            }

            return(false);
        }
Пример #4
0
 /// <summary>
 /// Determines whether drag operation can star with the specified item.
 /// </summary>
 /// <param name="item">The item.</param>
 /// <returns>Whether drag operation can start.</returns>
 public virtual bool CanStartDrag(RadListViewItem item)
 {
     if (item == null || this.Owner == null)
     {
         return(false);
     }
     else
     {
         return(true);
     }
 }
Пример #5
0
        /// <inheritdoc/>
        protected override void OnPointerMoved(PointerRoutedEventArgs e)
        {
            base.OnPointerMoved(e);

            Pointer      pointer      = e.Pointer;
            PointerPoint pointerPoint = e.GetCurrentPoint(this);

            if (!this.isReordering && pointerPoint.Properties.IsLeftButtonPressed && pointer.PointerDeviceType == PointerDeviceType.Mouse &&
                RadListViewItem.CanCapturePointer(this, pointer))
            {
                var source = e.OriginalSource;
                if (source != this.firstHandle && source != this.secondHandle)
                {
                    this.listView.OnItemReorderHandlePressed(this, e, DragDropTrigger.MouseDrag, null);
                }
            }
        }
Пример #6
0
        internal void PrepareDragVisual(DragAction action)
        {
            var owner       = this.ListView;
            var dragContent = owner.DragBehavior.GetDragVisual(this);

            this.dragVisual = this.ListView.GetContainerForItem();

            this.dragVisual.Orientation  = this.Orientation;
            this.dragVisual.Width        = this.ActualWidth;
            this.dragVisual.Height       = this.ActualHeight;
            this.dragVisual.ListView     = this.ListView;
            this.dragVisual.isReordering = true;
            this.dragVisual.IsSelected   = this.IsSelected;
            this.ListView.PrepareContainerForItem(this.dragVisual, this.DataContext);

            this.Opacity = 0;
            if (action == DragAction.ItemAction)
            {
                this.PrepareActionContent();
            }
        }
Пример #7
0
 internal FrameworkElement GetReorderVisual(RadListViewItem radListViewItem)
 {
     return(radListViewItem.dragVisual);
 }
Пример #8
0
 internal void OnDragStarted(RadListViewItem item)
 {
 }
Пример #9
0
 /// <summary>
 /// Called when drag drop operation completed.
 /// </summary>
 /// <param name="item">The source item being dragged.</param>
 /// <param name="dragSuccessful">Determines whether current drag operation completed successfully.</param>
 public virtual void OnDragDropCompleted(RadListViewItem item, bool dragSuccessful)
 {
 }
Пример #10
0
 /// <summary>
 /// Gets the drag visual for specified item.
 /// </summary>
 /// <param name="item">The item.</param>
 public virtual FrameworkElement GetDragVisual(RadListViewItem item)
 {
     return(item);
 }
        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();
        }