コード例 #1
0
        protected void ApplyDragAndDropUI(ListViewDragger.DragPosition dragPosition)
        {
            bool flag = this.m_LastDragPosition.Equals(dragPosition);

            if (!flag)
            {
                this.ClearDragAndDropUI();
                this.m_LastDragPosition = dragPosition;
                switch (dragPosition.dragAndDropPosition)
                {
                case DragAndDropPosition.OverItem:
                    dragPosition.recycledItem.element.AddToClassList(ListView.itemDragHoverUssClassName);
                    break;

                case DragAndDropPosition.BetweenItems:
                {
                    bool flag2 = dragPosition.insertAtIndex == 0;
                    if (flag2)
                    {
                        this.PlaceHoverBarAt(0f);
                    }
                    else
                    {
                        this.PlaceHoverBarAtElement(this.targetListView.GetRecycledItemFromIndex(dragPosition.insertAtIndex - 1).element);
                    }
                    break;
                }

                case DragAndDropPosition.OutsideItems:
                {
                    ListView.RecycledItem recycledItemFromIndex = this.targetListView.GetRecycledItemFromIndex(this.targetListView.itemsSource.Count - 1);
                    bool flag3 = recycledItemFromIndex != null;
                    if (flag3)
                    {
                        this.PlaceHoverBarAtElement(recycledItemFromIndex.element);
                    }
                    else
                    {
                        this.PlaceHoverBarAt(0f);
                    }
                    break;
                }

                default:
                    throw new ArgumentOutOfRangeException("dragAndDropPosition", dragPosition.dragAndDropPosition, "Unsupported dragAndDropPosition value");
                }
            }
        }
コード例 #2
0
        private ListDragAndDropArgs MakeDragAndDropArgs(ListViewDragger.DragPosition dragPosition)
        {
            object target = null;

            ListView.RecycledItem recycledItem = dragPosition.recycledItem;
            bool flag = recycledItem != null;

            if (flag)
            {
                target = this.targetListView.itemsSource[recycledItem.index];
            }
            return(new ListDragAndDropArgs
            {
                target = target,
                insertAtIndex = dragPosition.insertAtIndex,
                dragAndDropPosition = dragPosition.dragAndDropPosition
            });
        }
コード例 #3
0
        protected bool TryGetDragPosition(Vector2 pointerPosition, ref ListViewDragger.DragPosition dragPosition)
        {
            ListView.RecycledItem recycledItem = this.GetRecycledItem(pointerPosition);
            bool flag = recycledItem != null;
            bool result;

            if (flag)
            {
                bool flag2 = recycledItem.element.worldBound.yMax - pointerPosition.y < 5f;
                if (flag2)
                {
                    dragPosition.insertAtIndex       = recycledItem.index + 1;
                    dragPosition.dragAndDropPosition = DragAndDropPosition.BetweenItems;
                    result = true;
                }
                else
                {
                    bool flag3 = pointerPosition.y - recycledItem.element.worldBound.yMin > 5f;
                    if (flag3)
                    {
                        Vector2 scrollOffset = this.targetScrollView.scrollOffset;
                        this.targetScrollView.ScrollTo(recycledItem.element);
                        bool flag4 = scrollOffset != this.targetScrollView.scrollOffset;
                        if (flag4)
                        {
                            result = this.TryGetDragPosition(pointerPosition, ref dragPosition);
                        }
                        else
                        {
                            dragPosition.recycledItem        = recycledItem;
                            dragPosition.insertAtIndex       = -1;
                            dragPosition.dragAndDropPosition = DragAndDropPosition.OverItem;
                            result = true;
                        }
                    }
                    else
                    {
                        dragPosition.insertAtIndex       = recycledItem.index;
                        dragPosition.dragAndDropPosition = DragAndDropPosition.BetweenItems;
                        result = true;
                    }
                }
            }
            else
            {
                bool flag5 = !this.targetListView.worldBound.Contains(pointerPosition);
                if (flag5)
                {
                    result = false;
                }
                else
                {
                    dragPosition.dragAndDropPosition = DragAndDropPosition.OutsideItems;
                    bool flag6 = pointerPosition.y >= this.targetScrollView.contentContainer.worldBound.yMax;
                    if (flag6)
                    {
                        dragPosition.insertAtIndex = this.targetListView.itemsSource.Count;
                    }
                    else
                    {
                        dragPosition.insertAtIndex = 0;
                    }
                    result = true;
                }
            }
            return(result);
        }