コード例 #1
0
        /// <summary>
        /// Run when an item is dropped on a category
        /// </summary>
        /// <param name="target">The category component that the item was dropped onto</param>
        public async Task OnItemDropOnCategory(ChannelListCategoryComponent target)
        {
            // Insert item into the next slot in the category
            if (target == null)
            {
                return;
            }

            // Already parent
            if (target.Category.Id == currentDragItem.Parent_Id)
            {
                return;
            }

            // Same item
            if (target.Category.Id == currentDragItem.Id)
            {
                return;
            }

            ushort position = (ushort)target.ItemList.Count();

            currentDragItem.Parent_Id = target.Category.Id;
            currentDragItem.Position  = position;

            JsonContent content = JsonContent.Create(currentDragItem);

            // Add current item to target category
            var response = await ClientUserManager.Http.PostAsync($"/api/category/{target.Category.Id}/children", content);

            Console.WriteLine($"Inserting {currentDragItem.Id} into {target.Category.Id} at position {position}");

            Console.WriteLine(await response.Content.ReadAsStringAsync());
        }
コード例 #2
0
        /// <summary>
        /// Prepares drag system by setting initial drag object values
        /// </summary>
        /// <param name="item">The item</param>
        /// <param name="parent">The parent category</param>
        public void SetTargetInCategory(IClientPlanetListItem item,
                                        ChannelListCategoryComponent parent)
        {
            currentDragIndex = 0;

            if (parent != null)
            {
                currentDragIndex = parent.GetIndex(item);
            }

            currentDragParentPlanet   = null;
            currentDragParentCategory = parent;
            currentDragItem           = item;
        }
コード例 #3
0
 /// <summary>
 /// Run when an item is dragged within a category
 /// </summary>
 /// <param name="item">The item that was clicked</param>
 /// <param name="parent">The parent category of the item that was clicked</param>
 public void OnItemStartDragInCategory(IClientPlanetListItem item,
                                       ChannelListCategoryComponent parent)
 {
     SetTargetInCategory(item, parent);
     Console.WriteLine($"Starting drag for {item.GetItemTypeName()} {item.Name} at position {currentDragIndex}");
 }