public override bool PerformDragOperation(NSDraggingInfo sender) { NSPasteboard pb = sender.DraggingPasteboard; NSArray data = null; if (pb.Types.Contains(NSPasteboard.NSFilenamesType)) { data = pb.GetPropertyListForType(NSPasteboard.NSFilenamesType) as NSArray; } if (data != null) { for (int i = 0; i < data.Count; i++) { string path = (string)NSString.FromHandle(data.ValueAt((uint)i)); Console.WriteLine("From pasteboard Item {0} = {1}", i, path); var url = NSUrl.FromFilename(path); var baseDir = url.Path; var rootDir = baseDir.Substring(0, baseDir.LastIndexOf('/')); var d = new Directory(baseDir); ScanDirectories(rootDir, baseDir, d); var outlineView = Subviews [0].Subviews [0] as NSOutlineView; ((TreeDataSource)outlineView.DataSource).Directories.Add(d); outlineView.ReloadData(); return(true); } } return(false); }
public override bool AcceptDrop(NSTableView tableView, NSDraggingInfo info, int row, NSTableViewDropOperation dropOperation) { NSPasteboard pboard = info.DraggingPasteboard; NSArray files = (NSArray)pboard.GetPropertyListForType(NSPasteboard.NSFilenamesType); return(true); }
private static string GetFilePathFromPasteboard(NSPasteboard draggingPasteboard) { var filenames = NSArray.FromArrayNative <NSString>(draggingPasteboard .GetPropertyListForType(NSPasteboard.NSFilenamesType) as NSArray); return(filenames.FirstOrDefault()); }
public override void UpdateDraggingItems(NSTableView tableView, NSDraggingInfo draggingInfo) { if (_openSubtitleAction == null) { return; } NSPasteboard pboard = draggingInfo.DraggingPasteboard; NSArray files = (NSArray)pboard.GetPropertyListForType(NSPasteboard.NSFilenamesType); if (files.Count == 1) { _openSubtitleAction.OpenSubtitlePromptForChanges((string)files.GetItem <NSString>(0), false); } }
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); }
static string[] GetItemsForType(NSPasteboard pboard, NSString type) { var items = NSArray.FromArray <NSString>((NSArray)pboard.GetPropertyListForType(type.ToString())); return(items.Select(i => i.ToString()).ToArray()); }