public UIDragItem[] GetItemsForBeginningSession(UIDragInteraction interaction, IUIDragSession session)
        {
            var results = new List <UIDragItem>();

            if (MapItem == null)
            {
                return(results.ToArray());
            }

            var itemProvider = new NSItemProvider(MapItem);

            itemProvider.RegisterObject(Image, NSItemProviderRepresentationVisibility.All);
            results.Add(new UIDragItem(itemProvider));

            return(results.ToArray());
        }
        public UIDragItem [] GetItemsForBeginningDragSession(UICollectionView collectionView, IUIDragSession session, NSIndexPath indexPath)
        {
            var selectedPhoto = GetPhoto(indexPath);

            var userActivity = selectedPhoto.OpenDetailUserActivity();
            var itemProvider = new NSItemProvider(UIImage.FromFile(selectedPhoto.Name));

            itemProvider.RegisterObject(userActivity, NSItemProviderRepresentationVisibility.All);

            var dragItem = new UIDragItem(itemProvider)
            {
                LocalObject = selectedPhoto
            };

            return(new [] { dragItem });
        }
Beispiel #3
0
        UIDragItem[] IUIDragInteractionDelegate.GetItemsForBeginningSession(UIDragInteraction interaction, IUIDragSession session)
        {
            var results = new List <UIDragItem>();

            foreach (QRDetectionResult qrCode in QRCodes)
            {
                var itemProvider = new NSItemProvider((NSString)qrCode.Message);
                itemProvider.RegisterObject(qrCode.CroppedImage, NSItemProviderRepresentationVisibility.All);
                var item = new UIDragItem(itemProvider)
                {
                    LocalObject = qrCode
                };
                results.Add(item);
            }

            return(results.ToArray());
        }
        public UIDragItem[] GetItemsForBeginningSession(UIDragInteraction interaction, IUIDragSession session)
        {
            Console.WriteLine(interaction);
            Console.WriteLine(session);

            var scene    = Scenes[1];
            var activity = new NSUserActivity("IOS13DemoScene")
            {
                Title = scene.Type.AssemblyQualifiedName
            };
            var itemProvider = new NSItemProvider(activity);

            itemProvider.RegisterObject(activity, NSItemProviderRepresentationVisibility.All);

            return(new[] { new UIDragItem(itemProvider)
                           {
                               LocalObject = activity
                           } });
        }
        private void SetupTableView()
        {
            var selectedIndexPath = NSIndexPath.FromItemSection(0, 0);

            MenuTableView.Source = new InlineTableViewSourceWithoutRowHeight
            {
                _RowsInSection = (tv, section) => Scenes.Count,
                _GetCell       = (tv, indexPath) =>
                {
                    var scene = Scenes[indexPath.Row];

                    var cell = new UITableViewCell(UITableViewCellStyle.Subtitle, "abc")
                    {
                        BackgroundColor = UIColor.Clear
                    };

                    cell.SelectionStyle      = UITableViewCellSelectionStyle.None;
                    cell.TextLabel.Text      = scene.Title;
                    cell.TextLabel.Lines     = 0;
                    cell.TextLabel.TextColor = UIColor.White;
                    cell.TextLabel.Font      = UIFont.SystemFontOfSize(36);

                    cell.DetailTextLabel.Text      = scene.Description;
                    cell.DetailTextLabel.TextColor = UIColor.White.ColorWithAlpha(.75f);
                    cell.DetailTextLabel.Font      = UIFont.SystemFontOfSize(20);
                    cell.DetailTextLabel.Lines     = 0;

                    cell.SeparatorInset = UIEdgeInsets.Zero;

                    cell.BackgroundColor = UIColor.Black.ColorWithAlpha(.35f);

                    cell.ImageView.Image = selectedIndexPath == indexPath
                        ? UIImage.FromFile("selection.png")
                        : UIImage.FromFile("noselection.png");

                    cell.ImageView.Transform = CGAffineTransform.MakeTranslation(-4, 0);

                    return(cell);
                },
                _RowSelected = (tv, indexPath) =>
                {
                    var behaviour = (PresentationBehaviour)(int)PresentationKindSegmentedControl.SelectedSegment;

                    switch (behaviour)
                    {
                    case PresentationBehaviour.Present:

                        TransitionToScene(indexPath.Row);
                        break;

                    case PresentationBehaviour.New:
                    case PresentationBehaviour.Reuse:

                        var scene    = Scenes[indexPath.Row];
                        var userInfo = new[] { "openScene", scene.Type.AssemblyQualifiedName }
                        .ToNSDictionary();

                        var userActivity =
                            new NSUserActivity(scene.Type.AssemblyQualifiedName)
                        {
                            UserInfo = userInfo
                        };

                        UIApplication.SharedApplication.RequestSceneSessionActivation(
                            sceneSession: behaviour == PresentationBehaviour.Reuse
                                                ? SceneDelegate.DetailSceneSession
                                                : null,
                            userActivity: userActivity,
                            options: null,
                            errorHandler: null
                            );

                        break;
                    }
                }
            };

            MenuTableView.DragDelegate = new InlineUITableViewDragDelegate
            {
                _GetItemsForBeginningDragSession = (tv, session, indexPath) =>
                {
                    var scene        = Scenes[indexPath.Row];
                    var userActivity = new NSUserActivity("IOS13DemoScene")
                    {
                        Title = scene.Type.AssemblyQualifiedName
                    };
                    var itemProvider = new NSItemProvider(userActivity);

                    itemProvider.RegisterObject(userActivity,
                                                NSItemProviderRepresentationVisibility.All);

                    return(new[] { new UIDragItem(itemProvider)
                                   {
                                       LocalObject = userActivity
                                   } });
                },

                _DragSessionIsRestrictedToDraggingApplication = (tv, session) => false
            };
        }