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)); }
public override void SessionDidEnter(UIDropInteraction interaction, IUIDropSession session) { Console.WriteLine($"SessionDidEnter ({interaction}, {session})"); BeginInvokeOnMainThread(() => { dropView.BackgroundColor = UIColor.Yellow; }); }
public override void SessionDidExit(UIDropInteraction interaction, IUIDropSession session) { Console.WriteLine($"SessionDidExit ({interaction}, {session})"); BeginInvokeOnMainThread(() => { dropView.BackgroundColor = dropView.defaultColor; }); }
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); }
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); }
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; }); }
public UIDropProposal SessionDidUpdate(UIDropInteraction interaction, IUIDropSession session) { UIDropOperation operation; if (session.LocalDragSession == null) { operation = UIDropOperation.Copy; } else { operation = UIDropOperation.Move; } return(new UIDropProposal(operation)); }
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)) { } }
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); } }
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); } }
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); }
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(); }
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)) { } } }
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); }
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); })); }
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)); }
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))); }
public override UIDropProposal SessionDidUpdate(UIDropInteraction interaction, IUIDropSession session) { Console.WriteLine($"SessionDidUpdate ({interaction}, {session})"); return(new UIDropProposal(UIDropOperation.Copy)); }
/// <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))); }
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))); }
public override bool CanHandleSession(UIDropInteraction interaction, IUIDropSession session) { Console.WriteLine($"CanHandleSession ({interaction}, {session})"); return(session.CanLoadObjectsOfClass(new Class(typeof(NSString)))); }
public void DropSessionDidExit(UITableView tableView, IUIDropSession session) { }