public DragEventSource(long pointerId, NSDraggingInfo draggingInfo, NSWindow window) { Id = pointerId; _macOSDraggingInfo = draggingInfo; _window = window; }
static bool PerformDragOperation(IntPtr sender, IntPtr sel, IntPtr dragInfo) { IViewObject <T> ob = Runtime.GetNSObject(sender) as IViewObject <T>; if (ob == null) { return(false); } var backend = (ViewBackend <T, S>)WidgetRegistry.GetBackend(ob.Frontend); NSDraggingInfo di = new NSDraggingInfo(dragInfo); var pos = new Point(di.DraggingLocation.X, di.DraggingLocation.Y); if ((backend.currentEvents & WidgetEvent.DragDrop) != 0) { TransferDataStore store = new TransferDataStore(); FillDataStore(store, di.DraggingPasteboard, ob.View.RegisteredDragTypes()); var args = new DragEventArgs(pos, store, ConvertAction(di.DraggingSourceOperationMask)); backend.eventSink.OnDragDrop(args); return(args.Success); } else { return(false); } }
public override bool PerformDragOperation(NSDraggingInfo sender) { NSPasteboard pb = sender.DraggingPasteboard; foreach (var x in pb.PasteboardItems) { Console.WriteLine("x => {0}", x.Types); foreach (var y in x.Types) { Console.WriteLine("{0} => {1}", y, pb.GetStringForType(y)); } } var file = pb.GetStringForType("public.file-url"); if (!string.IsNullOrEmpty(file)) { if (dropped != null) { file = HttpUtility.UrlDecode(file); dropped.Invoke(file); } return(true); } Console.WriteLine("Got no string"); 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); }
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 && IsDroppable == true) { WorkFiles = new WorkFile[(int)data.Count]; for (int i = 0; i < (int)data.Count; i++) { // make workfile array from pasteboard string tempString = (string)NSString.FromHandle(data.ValueAt((uint)i)); NSUrl tempNSUrl = NSUrl.FromFilename(tempString); WorkFiles[i] = new WorkFile(); WorkFiles[i].Init(tempNSUrl); Console.WriteLine("Loaded file: {0}", WorkFiles[i].fileName); } CreateWorkManager(); } return true; }
public override NSDragOperation ValidateDrop(NSOutlineView outlineView, NSDraggingInfo info, NSObject item, nint index) { var h = Handler; if (h == null) { return(NSDragOperation.None); } var etoInfo = GetDragInfo(info, item, index); var e = h.GetDragEventArgs(info, etoInfo); h.Callback.OnDragOver(h.Widget, e); if (e.AllowedEffects.HasFlag(e.Effects)) { if (etoInfo.Position == GridDragPosition.Over) { outlineView.SetDropItem(h.GetCachedItem(etoInfo.Item), -1); } else { outlineView.SetDropItem(h.GetCachedItem(etoInfo.Parent), etoInfo.InsertIndex); } return(e.Effects.ToNS()); } else { return(NSDragOperation.None); } }
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 (nuint i = 0; i < data.Count; i++) { var url = data.ValueAt(i).ToFileUrl(); if (url.IsFileUrl && File.Exists(url.Path)) { if (url.Path.HasNibExtension()) { url.Path.AddXtcIdsToiOS(); } else if (url.Path.HasAndroidExtension()) { url.Path.AddXtcIdsToAndroid(); } else { throw new NotSupportedException ("File extension must be .storyboard, .xib, or .axml"); } } } } 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; }
public override NSDragOperation DraggingEntered(NSDraggingInfo sender) { var pasteboard = sender.DraggingPasteboard; if (pasteboard.Types.Contains(NSPasteboard.NSFilenamesType)) { var filenames = pasteboard.GetPropertyListForType(NSPasteboard.NSFilenamesType) as NSArray; if (filenames != null) { _firstPageController = Superview as UView; if (_firstPageController != null) { _list.Clear(); for (uint i = 0; i < filenames.Count; i++) { _list.Add((string)NSString.FromHandle(filenames.ValueAt(i))); } if (_firstPageController.Controller.CanDropFiles(_list)) { _dragOperation = NSDragOperation.Copy; return(NSDragOperation.Copy); } } } } _dragOperation = NSDragOperation.None; return(NSDragOperation.None); }
DragEventArgs ToDragEventArgs(NSDraggingInfo sender, DragDropEffects effect = UnusedDndEffect) { var q = ToMonoScreen(sender.DraggingLocation, null); var allowed = XplatUICocoa.DraggingAllowedEffects; var modifiers = NSEvent.CurrentModifierFlags; // translate mac modifiers to win modifiers // 1(bit 0) - The left mouse button. // 2(bit 1) - The right mouse button. // 4(bit 2) - The SHIFT key. // 8(bit 3) - The CTRL key. // 16(bit 4) - The middle mouse button. // 32(bit 5) - The ALT key. int keystate = 0; if (0 != (modifiers & NSEventModifierMask.ShiftKeyMask)) { keystate |= 4; } if (0 != (modifiers & NSEventModifierMask.AlternateKeyMask)) // alt (mac) => ctrl (win) { keystate |= 8; } var idata = XplatUICocoa.DraggedData as IDataObject ?? (IDataObject)(XplatUICocoa.DraggedData = ToIDataObject(sender.DraggingPasteboard)); return(new DragEventArgs(idata, keystate, q.X, q.Y, allowed, effect)); }
public override bool PerformDragOperation(NSDraggingInfo dragInfo) { if (CompleteDropAction == null) { return false; } // Convert point to be relative to the map from window coordinates. Invert Y because the mapping // library is expecting 0 to be at the top, not the bottom var pt = ConvertPointFromView(new PointF(dragInfo.DraggingLocation.X, dragInfo.DraggingLocation.Y), null); pt.Y = Frame.Height - pt.Y; var ret = InvokeMapScript("pointToLatLng([{0}, {1}])", pt.X, pt.Y) as NSString; if (ret != null) { var json = JObject.Parse((string) ret); var lat = (double) json["lat"]; var lng = (double) json["lng"]; CompleteDropAction(lat, lng, FilePaths(dragInfo)); return true; } logger.Error("pointToLatLng returned unexpected value: {0}", ret); return false; }
static bool PrepareForDragOperation(IntPtr sender, IntPtr sel, IntPtr dragInfo) { IViewObject <T> ob = Runtime.GetNSObject(sender) as IViewObject <T>; if (ob == null) { return(false); } var backend = (ViewBackend <T, S>)WidgetRegistry.GetBackend(ob.Frontend); NSDraggingInfo di = new NSDraggingInfo(dragInfo); var types = di.DraggingPasteboard.Types.Select(t => ToXwtDragType(t)).ToArray(); var pos = new Point(di.DraggingLocation.X, di.DraggingLocation.Y); if ((backend.currentEvents & WidgetEvent.DragDropCheck) != 0) { var args = new DragCheckEventArgs(pos, types, ConvertAction(di.DraggingSourceOperationMask)); backend.eventSink.OnDragDropCheck(args); if (args.Result == DragDropResult.Canceled) { return(false); } } return(true); }
public override void UpdateDraggingItems(NSTableView tableView, NSDraggingInfo draggingInfo) { if (UpdateDraggingItemsAction != null) { UpdateDraggingItemsAction(tableView, draggingInfo); } }
public override bool AcceptDrop(NSTableView tableView, NSDraggingInfo info, int row, NSTableViewDropOperation dropOperation) { if (AcceptDropFunc != null) { return(AcceptDropFunc(tableView, info, row, dropOperation)); } return(default(bool)); }
public override NSDragOperation ValidateDrop(NSTableView tableView, NSDraggingInfo info, int row, NSTableViewDropOperation dropOperation) { if (ValidateDropFunc != null) { return(ValidateDropFunc(tableView, info, row, dropOperation)); } return(default(NSDragOperation)); }
public override NSDragOperation ValidateDrop(NSTableView tableView, NSDraggingInfo info, nint row, NSTableViewDropOperation dropOperation) { if (_openSubtitleAction != null) { return NSDragOperation.Copy; } return NSDragOperation.None; }
NSDragOperation DraggingEntered(NSDraggingInfo info) { if (owner.DraggingEntered(info)) { return(NSDragOperation.Copy); } return(NSDragOperation.None); }
public override NSDragOperation DraggingUpdated(NSDraggingInfo sender) { if (CompleteDropAction == null) { return NSDragOperation.None; } return NSDragOperation.Copy; }
public override NSDragOperation ValidateDrop(NSTableView tableView, NSDraggingInfo info, nint row, NSTableViewDropOperation dropOperation) { if (_openSubtitleAction != null) { return(NSDragOperation.Copy); } return(NSDragOperation.None); }
public override NSDragOperation DraggingEntered(NSDraggingInfo sender) { if (sender.DraggingPasteboard.Types.Any(t => t == NSPasteboard.NSFilenamesType.ToString())) { return(NSDragOperation.Copy); } return(NSDragOperation.None); }
public override NSDragOperation ValidateDrop(NSTableView tableView, NSDraggingInfo info, nint row, NSTableViewDropOperation dropOperation) { if (info.DraggingPasteboard.GetDataForType(DataTypeName) != null) { return(NSDragOperation.Move); } return(NSDragOperation.None); }
public override NSDragOperation DraggingUpdated(NSDraggingInfo sender) { NSObject obj = sender.DraggingSource; if (obj != null && obj.Equals(Self)) { return NSDragOperation.Move; } return NSDragOperation.Copy; }
public override NSDragOperation DraggingEntered(NSDraggingInfo sender) { if (AcceptDragSource(sender)) { return(NSDragOperation.Generic); } return(NSDragOperation.None); }
public override NSDragOperation DraggingEntered(NSDraggingInfo dragInfo) { if (CompleteDropAction == null) { return NSDragOperation.None; } var list = FilePaths(dragInfo); return list.Count > 0 ? NSDragOperation.Copy : NSDragOperation.None; }
public override NSDragOperation DraggingEntered(NSDraggingInfo sender) { if (IsCSharpFilePathUrl(GetFilePathUrl(sender))) { return(NSDragOperation.Copy); } return(NSDragOperation.None); }
DragEventArgs ToDragEventArgs(NSDraggingInfo sender, DragDropEffects effect = UnusedDndEffect) { var q = ToMonoScreen(sender.DraggingLocation, null); var allowed = XplatUICocoa.DraggingAllowedEffects; var modifiers = NSEvent.CurrentModifierFlags.ToKeys(); var idata = XplatUICocoa.DraggedData as IDataObject ?? (IDataObject)(XplatUICocoa.DraggedData = ToIDataObject(sender.DraggingPasteboard)); return(new DragEventArgs(idata, (int)modifiers, q.X, q.Y, allowed, effect)); }
public override NSDragOperation ValidateDrop(NSTableView tableView, NSDraggingInfo info, nint row, NSTableViewDropOperation dropOperation) { tableView.SetDropRowDropOperation(row, dropOperation); if (dropOperation == NSTableViewDropOperation.On) { return(NSDragOperation.None); } return(NSDragOperation.Move); }
/// <inheritdoc /> public override bool AcceptDrop(NSOutlineView outlineView, NSDraggingInfo info, NSObject item, nint index) { DebugDragDropPrint("***** OutlineView.AcceptDrop, index: " + index); var dropLocationTreeNode = item as NSTreeNode; bool acceptedDrop = dropLocationTreeNode != null; var viewModel = outlineView.GetInheritedValue <MenuLayoutViewModel>(IFakeDependencyObjectHelpers.DataContextPropertyName); IEnumerable <FileNodeViewModel> draggedItems = null; if (acceptedDrop) { var newParent = dropLocationTreeNode.GetRepresentedObject() as FolderViewModel; var pasteboard = info.DraggingPasteboard; acceptedDrop = newParent != null; if (acceptedDrop && pasteboard.CanReadItemWithDataConformingToTypes(MenuLayoutPasteboardDataTypeArray)) { draggedItems = DragDropHelpers.GetDataForType <IEnumerable <FileNodeViewModel> >(pasteboard, MenuLayoutPasteboardDataTypeArray); if (acceptedDrop) { acceptedDrop = newParent.ShouldAcceptDraggedItems(draggedItems.Select(draggedItem => draggedItem.Model)); } if (acceptedDrop) { var firstDraggedItem = draggedItems.First(); var parent = firstDraggedItem.Parent; var parentViewModel = viewModel.FindViewModelForModel(parent); if (parentViewModel == newParent) { var currentIndex = parent.IndexOfChild(firstDraggedItem.Model); if (currentIndex < index) { --index; } } acceptedDrop = newParent.MoveItems(viewModel, newParent, (int)index, draggedItems); } } else if (acceptedDrop && pasteboard.CanReadItemWithDataConformingToTypes(ProgramDescriptionPasteboardDataTypeArray)) { var droppedItems = DragDropHelpers.GetDataForType <IEnumerable <ProgramDescriptionViewModel> >(pasteboard, ProgramDescriptionPasteboardDataTypeArray).Select(draggedItem => draggedItem.Model); newParent.AddItems(viewModel, (int)index, droppedItems); } else { acceptedDrop = false; } DebugDragDropPrint("*** OutlineView drop into: " + newParent); } if (acceptedDrop) { TreeData.RearrangeObjects(); if ((draggedItems != null) && draggedItems.Any()) { viewModel.CurrentSelection = draggedItems.FirstOrDefault(i => i.Model != null); } } return(acceptedDrop); }
/// <summary> /// Gets the drag enter effects. /// </summary> /// <param name="dragArgs">Drag information used to determine drag-drop effects.</param> /// <returns>The drag-drop effects to apply when a drag operation enters the ROM list.</returns> internal NSDragOperation GetDragEnterEffects(NSDraggingInfo dragArgs) { var effects = NSDragOperation.None; if (dragArgs.DraggingPasteboard.CanReadItemWithDataConformingToTypes(new string[] { DragDropFilesDataFormat }) && !dragArgs.DraggingPasteboard.CanReadItemWithDataConformingToTypes(new string[] { ProgramDescriptionViewModel.DragDataFormat })) { effects = NSDragOperation.Link; } return(effects); }
public override NSDragOperation DraggingUpdated(NSDraggingInfo sender) { NSDragOperation op = sender.DraggingSourceOperationMask; if (sender.DraggingSource == this) { return(NSDragOperation.None); } return(NSDragOperation.Copy); }
bool PerformDragOperation(NSDraggingInfo sender) { if (DropAction != null) { var list = FilePaths(sender); DropAction(list); return true; } return false; }
public override void DraggingExited(NSDraggingInfo sender) { var control = Control.FromHandle(Handle); if (null != control && control.AllowDrop) { var e = ToDragEventArgs(sender); control.DndLeave(e); } }
public override bool AcceptDrop(NSTableView tableView, NSDraggingInfo info, nint row, NSTableViewDropOperation dropOperation) { NSPasteboard pboard = info.DraggingPasteboard; NSArray files = (NSArray)pboard.GetPropertyListForType(NSPasteboard.NSFilenamesType); if (files.Count == 1) { return true; } return false; }
public override NSDragOperation DraggingEntered(NSDraggingInfo sender) { if (sender.DraggingSource == this) { return(NSDragOperation.None); } Highlighted = true; NeedsDisplay = true; return(NSDragOperation.Copy); }
public override NSDragOperation DraggingEntered(NSDraggingInfo sender) { if (sender.DraggingPasteboard.Types.Contains("ObjectName")) { return(NSDragOperation.Generic); } else { return(NSDragOperation.None); } }
[Export("draggingUpdated:")] // Do not remove internal virtual NSDragOperation DraggingUpdated(NSDraggingInfo draggingInfo) { try { return(DraggingUpdatedAction.Invoke(draggingInfo)); } catch { return(NSDragOperation.None); } }
[Export("performDragOperation:")] // Do not remove internal virtual bool PerformDragOperation(NSDraggingInfo draggingInfo) { try { return(PerformDragOperationAction.Invoke(draggingInfo)); } catch { return(false); } }
public override NSDragOperation DraggingUpdated(NSDraggingInfo sender) { base.DraggingUpdated(sender); if (sender.DraggingLocation.X < LeftMargin) { SetPositionOfDivider(LeftMargin, 0); } Console.WriteLine(sender.DraggingLocation.X); return(NSDragOperation.Move); }
public override bool PerformDragOperation(NSDraggingInfo sender) { NSApplication.SharedApplication.ActivateIgnoringOtherApps(true); Window.MakeKeyAndOrderFront(sender); NSApplication.SharedApplication.ActivateIgnoringOtherApps(false); if (_dragOperation == NSDragOperation.Copy) { _firstPageController.Controller.DropFiles(_list); return(true); } return(false); }
public override void DraggingEnded (NSDraggingInfo sender) { // Update the dropped item counter and display dragCount++; UpdateDragCount (); // Pull the individual items from the drag package and write them to the console var i = new NSImage (sender.DraggingPasteboard.GetDataForType (NSPasteboard.NSTiffType)); string s = NSString.FromData (sender.DraggingPasteboard.GetDataForType (NSPasteboard.NSStringType), NSStringEncoding.UTF8); Console.WriteLine ("String Data: {0}", s); Console.WriteLine ("Image Data: {0}", i.Size); }
[Export("draggingExited:")] // Do not remove internal virtual void DraggingExited(NSDraggingInfo draggingInfo) { try { DraggingExitedAction.Invoke(draggingInfo); } catch { // Simply return if an error occurred, it is unrecoverable } return; }
public override NSDragOperation DraggingUpdated (NSDraggingInfo sender) { //The ImageBrowserView uses this method to set the icon during dragging. Regardless //of what we return the view will send a moveitems message to the datasource. //so it is best to not display the copy icon. //Console.WriteLine ("Drag Delegate received 'DraggingUpdated'"); NSObject obj = sender.DraggingSource; if (obj != null && obj.Equals (browserView)) { return NSDragOperation.Move; } return NSDragOperation.Copy; }
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) { var item = sender.DraggingPasteboard.PasteboardItems.First(); if (item.Types.Any(x => x == "public.url")) { var url = new NSString(item.GetStringForType("public.url")); ImageUrlDropped?.Invoke(this, new DropEventArgs(url)); } else if (item.Types.Any(x => x == "public.file-url")) { var url = new NSString(new NSUrl(item.GetStringForType("public.file-url")).Path); FileDropped?.Invoke(this, new DropEventArgs(url)); } else { return false; } return true; }
public override NSDragOperation DraggingEntered(NSDraggingInfo sender) { var item = sender.DraggingPasteboard.PasteboardItems.First(); NSString url; if (item.Types.Any(x => x == "public.url")) { url = new NSString(item.GetStringForType("public.url")); } else if (item.Types.Any(x => x == "public.file-url")) { url = new NSString(new NSUrl(item.GetStringForType("public.file-url")).Path); } else { return NSDragOperation.None; } return CanConformsToImageUTI(url) ? NSDragOperation.Copy : NSDragOperation.None; }
IList<string> FilePaths(NSDraggingInfo dragInfo) { var list = new List<string>(); if (dragInfo.DraggingPasteboard.Types.Contains(NSPasteboard.NSFilenamesType)) { NSArray data = dragInfo.DraggingPasteboard.GetPropertyListForType(NSPasteboard.NSFilenamesType) as NSArray; if (data != null) { for (uint idx = 0; idx < data.Count; ++idx) { string path = NSString.FromHandle(data.ValueAt(idx)); if (Directory.Exists(path)) { list.Add(path); } } } } return list; }
public override bool PrepareForDragOperation(NSDraggingInfo sender) { return true; }
public override bool PerformDragOperation(NSDraggingInfo sender) { NSPasteboard pb = sender.DraggingPasteboard; if (!ReadFromPasteboard(pb)) { Console.WriteLine("Error: could not read from dragging pasteboard"); Highlighted = false; NeedsDisplay = true; return false; } return true; }
public override NSDragOperation DraggingUpdated(NSDraggingInfo sender) { NSDragOperation op = sender.DraggingSourceOperationMask; if (sender.DraggingSource == this) { return NSDragOperation.None; } return NSDragOperation.Copy; }
public override void DraggingExited(NSDraggingInfo sender) { Highlighted = false; NeedsDisplay = true; }
public override NSDragOperation DraggingEntered(NSDraggingInfo sender) { if (sender.DraggingSource == this) { return NSDragOperation.None; } Highlighted = true; NeedsDisplay = true; return NSDragOperation.Copy; }
public override void ConcludeDragOperation(NSDraggingInfo sender) { Highlighted = false; NeedsDisplay = true; }
public override NSDragOperation DraggingEntered(NSDraggingInfo sender) { return NSDragOperation.Copy; }
public override void ConcludeDragOperation (NSDraggingInfo sender) { Console.WriteLine ("Drag Delegate received 'ConcludeDragOperation'"); }
public override bool PrepareForDragOperation (NSDraggingInfo sender) { Console.WriteLine ("Drag Delegate received 'PrepareForDragOperation'"); return true; }
public override NSDragOperation DraggingEntered (NSDraggingInfo sender) { // When we start dragging, inform the system that we will be handling this as // a copy/paste return NSDragOperation.Copy; }
public override NSDragOperation DraggingEntered (NSDraggingInfo sender) { Console.WriteLine ("Drag Delegate received 'DraggingEntered'"); return DraggingUpdated (sender); }
public override void DraggingEnded (NSDraggingInfo sender) { // Update the dropped item counter and display }
public override NSDragOperation DraggingEntered(NSDraggingInfo sender) { return DraggingUpdated(sender); }
public override void DraggingEnded (NSDraggingInfo sender) { Console.WriteLine ("Drag Delegate received 'DraggingEnded'"); }