public override void RemoveItems (IKImageBrowserView aBrowser, NSIndexSet indexes) { //FIXME - add extension for List<T> //images.RemoveAt(indexes) List<BrowseItem> movingImages = new List<BrowseItem> (); foreach (int index in indexes) movingImages.Add (images[index]); foreach (BrowseItem item in movingImages) images.Remove (item); aBrowser.ReloadData(); }
public override void RemoveItems(IKImageBrowserView aBrowser, NSIndexSet indexes) { //FIXME - add extension for List<T> //images.RemoveAt(indexes) List <BrowseItem> movingImages = new List <BrowseItem> (); foreach (int index in indexes) { movingImages.Add(images[index]); } foreach (BrowseItem item in movingImages) { images.Remove(item); } aBrowser.ReloadData(); }
public override bool MoveItems (IKImageBrowserView aBrowser, NSIndexSet indexes, nint destinationIndex) { //indexes are not sequential, and may be on both sides of destinationIndex. //indexes will change, but I will put the items in after the item at destination //FIXME - missing methods on NSIndexSet //FIXME make an extension method on List<> int destination = (int) destinationIndex - (int)indexes.Where (x =>(int) x <(int) destinationIndex).Count (); List<BrowseItem> movingImages = new List<BrowseItem> (); foreach (int index in indexes) movingImages.Add (images[index]); foreach (BrowseItem item in movingImages) images.Remove (item); images.InsertRange (destination, movingImages); aBrowser.ReloadData(); return true; }
public override bool MoveItems(IKImageBrowserView aBrowser, NSIndexSet indexes, nint destinationIndex) { //indexes are not sequential, and may be on both sides of destinationIndex. //indexes will change, but I will put the items in after the item at destination //FIXME - missing methods on NSIndexSet //FIXME make an extension method on List<> int destination = (int)destinationIndex - (int)indexes.Where(x => (int)x < (int)destinationIndex).Count(); List <BrowseItem> movingImages = new List <BrowseItem> (); foreach (int index in indexes) { movingImages.Add(images[index]); } foreach (BrowseItem item in movingImages) { images.Remove(item); } images.InsertRange(destination, movingImages); aBrowser.ReloadData(); return(true); }
public override bool PerformDragOperation(NSDraggingInfo sender) { Console.WriteLine("Drag Delegate received 'PerformDragOperation' sender: {0}", sender); //It seems that browserView does not send this message when it is an internal move. //It does all the work by sending a moveitems message to the datasource, // but I return false here just to be safe. NSObject obj = sender.DraggingSource; if (obj != null && obj.Equals(browserView)) { Console.WriteLine("\tLet the image browser handle it."); return(false); } NSPasteboard pb = sender.DraggingPasteboard; NSArray data = null; // if (pb.Types.Contains (NSPasteboard.NSUrlType)) // data = pb.GetPropertyListForType (NSPasteboard.NSUrlType) as NSArray; if (pb.Types.Contains(NSPasteboard.NSFilenamesType)) { data = pb.GetPropertyListForType(NSPasteboard.NSFilenamesType) as NSArray; } if (data != null) { for (int i = 0; i < (int)data.Count; i++) { string path = (string)NSString.FromHandle(data.ValueAt((uint)i)); Console.WriteLine("From pasteboard Item {0} = {1}", i, path); ((BrowseData)browserView.DataSource).AddImages( NSUrl.FromFilename(path), (int)browserView.GetIndexAtLocationOfDroppedItem()); browserView.ReloadData(); } } return(true); }