예제 #1
0
        public UIDropProposal SessionDidUpdate(UIDropInteraction interaction, IUIDropSession session)
        {
            UIDropOperation operation = UIDropOperation.Cancel;

            if (session.LocalDragSession == null)
            {
                return(new UIDropProposal(operation));
            }

            if (interaction.View is IVisualElementRenderer renderer)
            {
                DataPackage package = null;

                if (session.LocalDragSession.Items.Length > 0 &&
                    session.LocalDragSession.Items[0].LocalObject is CustomLocalStateData cdi)
                {
                    package = cdi.DataPackage;
                }

                if (HandleDragOver((View)renderer.Element, package))
                {
                    operation = UIDropOperation.Copy;
                }
            }

            return(new UIDropProposal(operation));
        }
예제 #2
0
            public override void SessionDidEnter(UIDropInteraction interaction, IUIDropSession session)
            {
                Console.WriteLine($"SessionDidEnter ({interaction}, {session})");

                BeginInvokeOnMainThread(() => {
                    dropView.BackgroundColor = UIColor.Yellow;
                });
            }
예제 #3
0
            public override void SessionDidExit(UIDropInteraction interaction, IUIDropSession session)
            {
                Console.WriteLine($"SessionDidExit ({interaction}, {session})");

                BeginInvokeOnMainThread(() => {
                    dropView.BackgroundColor = dropView.defaultColor;
                });
            }
예제 #4
0
 public UIDropProposal SessionDidUpdate(UIDropInteraction interaction, IUIDropSession session)
 {
     if (session.LocalDragSession == null)
     {
         return(new UIDropProposal(UIDropOperation.Forbidden));
     }
     return(new UIDropProposal(UIDropOperation.Move));
 }
 public bool CanHandleDropSession(UICollectionView collectionView, IUIDropSession session)
 {
     if (album == null)
     {
         return(false);
     }
     return(session.HasConformingItems(UIImage.ReadableTypeIdentifiers));
 }
 public virtual void PerformDrop(UIDropInteraction interaction, IUIDropSession session)
 {
     if (PerformDropOperation == null)
     {
         throw new NullReferenceException("The PerformDropOperation delegate must be defined before calling the 'PerformDrop' method");
     }
     PerformDropOperation(interaction, session);
 }
예제 #7
0
        public void PerformDrop(UIDropInteraction interaction, IUIDropSession session)
        {
            // Get the drag items (UIImage in this case).
            session.LoadObjects <UIImage> (images => {
                ImageView.Image = images?.First();
            });

            var dropLocation = session.LocationInView(View);

            UpdateLayers(dropLocation);
        }
예제 #8
0
            public override void PerformDrop(UIDropInteraction interaction, IUIDropSession session)
            {
                Console.WriteLine($"PerformDrop ({interaction}, {session})");

                INSItemProviderReading objectType = new StringReader();

                session.Completion(objectType, (objects) => {
                    Console.WriteLine($"PerformDropCompletion ({objects.Length})");

                    dropView.BackgroundColor = UIColor.Green;
                });
            }
예제 #9
0
        public UIDropProposal SessionDidUpdate(UIDropInteraction interaction, IUIDropSession session)
        {
            UIDropOperation operation;

            if (session.LocalDragSession == null)
            {
                operation = UIDropOperation.Copy;
            }
            else
            {
                operation = UIDropOperation.Move;
            }
            return(new UIDropProposal(operation));
        }
예제 #10
0
        public void SessionDidExit(UIDropInteraction interaction, IUIDropSession session)
        {
            DataPackage package = null;

            if (session.LocalDragSession.Items.Length > 0 &&
                session.LocalDragSession.Items[0].LocalObject is CustomLocalStateData cdi)
            {
                package = cdi.DataPackage;
            }

            if (HandleDragLeave((View)_viewHandler.VirtualView, package))
            {
            }
        }
예제 #11
0
 public void PerformDrop(UIDropInteraction interaction, IUIDropSession session)
 {
     if (session.LocalDragSession == null)
     {
         DropPoint = session.LocationInView(interaction.View);
         foreach (var dragItem in session.Items)
         {
             LoadImage(dragItem.ItemProvider, DropPoint);
         }
     }
     else
     {
         MovePoint = session.LocationInView(interaction.View);
     }
 }
예제 #12
0
        public void PerformDrop(UIDropInteraction interaction, IUIDropSession session)
        {
            if (session.LocalDragSession == null)
            {
                return;
            }

            if (session.LocalDragSession.Items.Length > 0 &&
                session.LocalDragSession.Items[0].LocalObject is CustomLocalStateData cdi &&
                _viewHandler.VirtualView is View view)
            {
                HandleDrop(view, cdi.DataPackage);
                HandleDropCompleted(cdi.View);
            }
        }
예제 #13
0
        public bool CanHandleSession(UIDropInteraction interaction, IUIDropSession session)
        {
            if (session.LocalDragSession == null)
            {
                return(false);
            }

            if (session.LocalDragSession.Items.Length > 0 &&
                session.LocalDragSession.Items[0].LocalObject is CustomLocalStateData)
            {
                return(true);
            }

            return(false);
        }
예제 #14
0
        public void PerformDrop(UIDropInteraction interaction, IUIDropSession session)
        {
            var label = interaction == oddDropInteraction ? OddNumbersLabel : EvenNumbersLabel;

            session.LoadObjects <NSString>(strings =>
            {
                if (String.IsNullOrEmpty(label.Text))
                {
                    label.Text = strings[0];
                }
                else
                {
                    label.Text = $"{strings[0]}, {label.Text}";
                }
            });
            GenerateNumber();
        }
예제 #15
0
        public void SessionDidExit(UIDropInteraction interaction, IUIDropSession session)
        {
            if (interaction.View is IVisualElementRenderer renderer)
            {
                DataPackage package = null;

                if (session.LocalDragSession.Items.Length > 0 &&
                    session.LocalDragSession.Items[0].LocalObject is CustomLocalStateData cdi)
                {
                    package = cdi.DataPackage;
                }

                if (HandleDragLeave((View)renderer.Element, package))
                {
                }
            }
        }
예제 #16
0
        public List <UIView> LocalViewsForSession(IUIDropSession session)
        {
            var views = new List <UIView>();

            if (session.LocalDragSession != null)
            {
                foreach (UIDragItem item in session.Items)
                {
                    var view = item.LocalObject as UIView;
                    if (view != null)
                    {
                        views.Add(view);
                    }
                }
            }

            return(views);
        }
예제 #17
0
        public UIDropProposal SessionDidUpdate(UIDropInteraction interaction, IUIDropSession session)
        {
            UIDropProposal proposal;
            var            isEven = (session.Items[0].LocalObject as NSNumber).BoolValue;

            if (interaction == oddDropInteraction && !isEven)
            {
                proposal = new UIDropProposal(UIDropOperation.Copy);
            }
            else if (interaction == evenDropInteraction && isEven)
            {
                proposal = new UIDropProposal(UIDropOperation.Copy);
            }
            else
            {
                proposal = new UIDropProposal(UIDropOperation.Forbidden);
            }
            return(proposal);
        }
 public UITableViewDropProposal DropSessionDidUpdate(UITableView tableView, IUIDropSession session, NSIndexPath destinationIndexPath)
 {
     // The .move operation is available only for dragging within a single app.
     if (tableView.HasActiveDrag)
     {
         if (session.Items.Length > 1)
         {
             return(new UITableViewDropProposal(UIDropOperation.Cancel));
         }
         else
         {
             return(new UITableViewDropProposal(UIDropOperation.Move, UITableViewDropIntent.InsertAtDestinationIndexPath));
         }
     }
     else
     {
         return(new UITableViewDropProposal(UIDropOperation.Copy, UITableViewDropIntent.InsertAtDestinationIndexPath));
     }
 }
 /// <summary>
 /// A drop proposal from a table view includes two items: a drop operation,
 /// typically Move or Copy; and an intent, which declares the action the
 /// table view will take upon receiving the items. (A drop proposal from a
 /// custom view does includes only a drop operation, not an intent.)
 /// </summary>
 public UITableViewDropProposal DropSessionDidUpdate(UITableView tableView, IUIDropSession session, NSIndexPath destinationIndexPath)
 {
     // The Move operation is available only for dragging within a single app.
     if (tableView.HasActiveDrag)
     {
         if (session.Items.Length > 1)
         {
             return(new UITableViewDropProposal(UIDropOperation.Cancel));
         }
         else
         {   // allow reordering (doesn't call PerformDrop for single rows, instead calls MoveRow)
             return(new UITableViewDropProposal(UIDropOperation.Move, UITableViewDropIntent.InsertAtDestinationIndexPath));
         }
     }
     else
     {
         return(new UITableViewDropProposal(UIDropOperation.Copy, UITableViewDropIntent.InsertAtDestinationIndexPath));
     }
 }
        public static NSProgress LoadObjects <T> (this IUIDropSession session, Action <T []> completion) where T : NSObject, INSItemProviderReading
        {
            return(session.LoadObjects(new Class(typeof(T)), (v) =>
            {
                var arr = v as T[];
                if (arr == null && v != null)
                {
                    arr = new T [v.Length];
                    for (int i = 0; i < arr.Length; i++)
                    {
                        if (v [i] != null)
                        {
                            arr [i] = Runtime.ConstructNSObject <T> (v [i].Handle);
                        }
                    }
                }

                completion(arr);
            }));
        }
예제 #21
0
        public UIDropProposal SessionDidUpdate(UIDropInteraction interaction, IUIDropSession session)
        {
            var dropLocation = session.LocationInView(View);

            UpdateLayers(dropLocation);

            var operation = new UIDropOperation();

            if (ImageView.Frame.Contains(dropLocation))
            {
                operation = session.LocalDragSession == null ? UIDropOperation.Copy : UIDropOperation.Move;
            }
            else
            {
                // Cancel dropping if it's not inside the image view.
                operation = UIDropOperation.Cancel;
            }

            return(new UIDropProposal(operation));
        }
        public UITableViewDropProposal DropSessionDidUpdate(UITableView tableView, IUIDropSession session, NSIndexPath destinationIndexPath)
        {
            if (destinationIndexPath == null)
            {
                return(new UITableViewDropProposal(UIDropOperation.Cancel));
            }

            // this dragging is from UITableView.
            if (tableView.HasActiveDrag)
            {
                if (session.Items.Length > 1)
                {
                    return(new UITableViewDropProposal(UIDropOperation.Cancel));
                }
                else
                {
                    return(new UITableViewDropProposal(UIDropOperation.Move, UITableViewDropIntent.InsertAtDestinationIndexPath));
                }
            }

            return(new UITableViewDropProposal(UIDropOperation.Cancel));
        }
 public UITableViewDropProposal DropSessionDidUpdate(UITableView tableView, IUIDropSession session, Foundation.NSIndexPath destinationIndexPath)
 {
     if (tableView.Editing && tableView.HasActiveDrag)
     {
         return(new UITableViewDropProposal(UIDropOperation.Move, UITableViewDropIntent.InsertAtDestinationIndexPath));
     }
     else if (tableView.Editing || tableView.HasActiveDrag)
     {
         return(new UITableViewDropProposal(UIDropOperation.Forbidden));
     }
     else if (destinationIndexPath != null && destinationIndexPath.Row < albums.Count)
     {
         if (session.LocalDragSession != null)
         {
             return(new UITableViewDropProposal(UIDropOperation.Move, UITableViewDropIntent.InsertIntoDestinationIndexPath));
         }
         else
         {
             return(new UITableViewDropProposal(UIDropOperation.Copy, UITableViewDropIntent.InsertIntoDestinationIndexPath));
         }
     }
     return(new UITableViewDropProposal(UIDropOperation.Cancel));
 }
예제 #24
0
        public UIDropProposal SessionDidUpdate(UIDropInteraction interaction, IUIDropSession session)
        {
            UIDropOperation operation = UIDropOperation.Cancel;

            if (session.LocalDragSession == null)
            {
                return(new UIDropProposal(operation));
            }

            DataPackage package = null;

            if (session.LocalDragSession.Items.Length > 0 &&
                session.LocalDragSession.Items[0].LocalObject is CustomLocalStateData cdi)
            {
                package = cdi.DataPackage;
            }

            if (HandleDragOver((View)_viewHandler.VirtualView, package))
            {
                operation = UIDropOperation.Copy;
            }

            return(new UIDropProposal(operation));
        }
 public bool CanHandleDropSession(UITableView tableView, IUIDropSession session)
 {
     return(session.CanLoadObjects(typeof(NSString)));
 }
예제 #26
0
            public override UIDropProposal SessionDidUpdate(UIDropInteraction interaction, IUIDropSession session)
            {
                Console.WriteLine($"SessionDidUpdate ({interaction}, {session})");

                return(new UIDropProposal(UIDropOperation.Copy));
            }
예제 #27
0
 /// <summary>
 /// A helper function that serves as an interface to the data model,
 /// called by the implementation of the `tableView(_ canHandle:)` method.
 /// </summary>
 public bool CanHandle(IUIDropSession session)
 {
     return(session.CanLoadObjects(typeof(NSString)));
 }
예제 #28
0
        public virtual UIDropProposal SessionDidUpdate(UIDropInteraction interaction, IUIDropSession session)
        {
            if (ResolveDropOperation == null)
            {
                throw new NullReferenceException("The ResolveDropOperation delegate must be defined before calling the 'SessionDidUpdate' method");
            }



            return(new UIDropProposal(ResolveDropOperation(this, interaction, session)));
        }
예제 #29
0
            public override bool CanHandleSession(UIDropInteraction interaction, IUIDropSession session)
            {
                Console.WriteLine($"CanHandleSession ({interaction}, {session})");

                return(session.CanLoadObjectsOfClass(new Class(typeof(NSString))));
            }
예제 #30
0
 public void DropSessionDidExit(UITableView tableView, IUIDropSession session)
 {
 }