コード例 #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));
 }
コード例 #5
0
 public bool CanHandleDropSession(UICollectionView collectionView, IUIDropSession session)
 {
     if (album == null)
     {
         return(false);
     }
     return(session.HasConformingItems(UIImage.ReadableTypeIdentifiers));
 }
コード例 #6
0
 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
ファイル: ViewController.cs プロジェクト: MIliev11/Samples
        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
ファイル: DragAndDropDelegate.cs プロジェクト: sung-su/maui
        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
ファイル: DragAndDropDelegate.cs プロジェクト: sung-su/maui
        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
ファイル: DragAndDropDelegate.cs プロジェクト: sung-su/maui
        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);
        }
コード例 #18
0
 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));
     }
 }
コード例 #19
0
 /// <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));
     }
 }
コード例 #20
0
        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
ファイル: ViewController.cs プロジェクト: MIliev11/Samples
        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));
        }
コード例 #22
0
        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));
        }
コード例 #23
0
 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
ファイル: DragAndDropDelegate.cs プロジェクト: sung-su/maui
        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));
        }
コード例 #25
0
 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)
 {
 }