コード例 #1
0
        void MoveItems(NSIndexPath destinationIndexPath, IUITableViewDropCoordinator coordinator)
        {
            var destinationAlbum = Album(destinationIndexPath);

            foreach (var item in coordinator.Items)
            {
                var dragItem = item.DragItem;

                var photo = dragItem.LocalObject as Photo;
                if (photo is null)
                {
                    return;
                }

                UpdatePhotoLibrary((photoLibrary) =>
                {
                    photoLibrary.MovePhoto(photo, destinationAlbum);
                });

                var cell = TableView.CellAt(destinationIndexPath) as AlbumTableViewCell;
                if (cell != null)
                {
                    var rect = cell.RectForAlbumThumbnail;
                    if (!rect.HasValue)
                    {
                        rect = new CGRect(cell.ContentView.Center, CGSize.Empty);
                    }
                    coordinator.DropItemIntoRow(dragItem, destinationIndexPath, rect.Value);
                }
                UpdateVisibleAlbumsAndPhotos();
            }
        }
コード例 #2
0
        void LoadAndInsertItems(NSIndexPath destinationIndexPath, IUITableViewDropCoordinator coordinator)
        {
            var destinationAlbum = Album(destinationIndexPath);

            foreach (var item in coordinator.Items)
            {
                var dragItem = item.DragItem;
                if (dragItem.ItemProvider.CanLoadObject(typeof(UIImage)))
                {
                    dragItem.ItemProvider.LoadObject <UIImage>((droppedImage, err) => {
                        var image = droppedImage as UIImage;
                        if (image != null)
                        {
                            var photo = new Photo(image);
                            UpdatePhotoLibrary((photoLibrary) => {
                                photoLibrary.Add(photo, destinationAlbum);
                            });

                            UpdateVisibleAlbumsAndPhotos();
                        }
                    });

                    var cell = TableView.CellAt(destinationIndexPath) as AlbumTableViewCell;
                    if (cell != null)
                    {
                        var rect = cell.RectForAlbumThumbnail;
                        if (!rect.HasValue)
                        {
                            rect = new CGRect(cell.ContentView.Center, CGSize.Empty);                 //??
                        }
                        coordinator.DropItemIntoRow(dragItem, destinationIndexPath, rect.Value);
                    }
                }
            }
        }