Esempio n. 1
0
        /// <summary>
        /// Moves the set of supplied sprites to be before (or after) the specified
        /// sprite in the folder. This takes account of the fact that NearestSprite
        /// could be one of the ones being moved.
        /// </summary>
        private List<Sprite> MoveSpritesIntoNewPositionInFolder(int nearestSprite, bool putSpritesBeforeSelection, SpriteManagerDragDropData dragged)
        {
            List<Sprite> newFolderContents = new List<Sprite>();
            foreach (Sprite sprite in _currentFolder.Sprites)
            {
                bool addThisSpriteToNewList = true;

                if (sprite.Number == nearestSprite)
                {
                    if (!putSpritesBeforeSelection)
                    {
                        newFolderContents.Add(sprite);
                        addThisSpriteToNewList = false;
                    }
                    foreach (Sprite draggedSprite in dragged.Sprites)
                    {
                        if ((draggedSprite.Number != sprite.Number) || (putSpritesBeforeSelection))
                        {
                            newFolderContents.Add(draggedSprite);
                        }
                    }
                }
                foreach (Sprite draggedSprite in dragged.Sprites)
                {
                    if (sprite.Number == draggedSprite.Number)
                    {
                        addThisSpriteToNewList = false;
                        break;
                    }
                }
                if (addThisSpriteToNewList)
                {
                    newFolderContents.Add(sprite);
                }
            }
            return newFolderContents;
        }
Esempio n. 2
0
        private void spriteList_ItemDrag(object sender, ItemDragEventArgs e)
        {
            SpriteManagerDragDropData dragDropData = new SpriteManagerDragDropData();

            foreach (ListViewItem selectedItem in spriteList.SelectedItems)
            {
                dragDropData.Sprites.Add(FindSpriteByNumber(Convert.ToInt32(selectedItem.Name)));
            }

            this.DoDragDrop(dragDropData, DragDropEffects.Move);
        }