public void ProvideData(NSPasteboard pboard, NSString type) { NSData data; var obj = DataSource(); if (obj is Xwt.Drawing.Image) { var bmp = ((Xwt.Drawing.Image)obj).ToBitmap(); data = ((NSImage)Toolkit.GetBackend(bmp)).AsTiff(); } else if (obj is NSImage) { data = ((NSImage)obj).AsTiff(); } else if (obj is Uri) { data = NSData.FromUrl((NSUrl)((Uri)obj)); } else if (obj is string) { data = NSData.FromString((string)obj); } else { data = NSData.FromArray(TransferDataSource.SerializeValue(obj)); } pboard.SetDataForType(data, type); }
public static void SetDataObject(object data, bool copy) { if (data is DataObject dataObject) { pasteboard.ClearContents(); foreach (var item in dataObject.Items) { switch (item.Data) { case string stringData: pasteboard.SetStringForType( stringData, item.Format); break; case bool boolItem: pasteboard.SetDataForType( NSData.FromArray(new byte[] { boolItem ? (byte)1 : (byte)0 }), item.Format); break; } } } }
public int Begin(NSIndexSet aIndices, object aSource, NSPasteboard aPasteboard) { // build list of indices to be dragged List <int> indices = new List <int>(); uint index = aIndices.FirstIndex; while (index != FoundationFramework.NSNotFound) { indices.Add((int)index); index = aIndices.IndexGreaterThanIndex(index); } // set the current data to be dragged DragDropManager.Current = iController.DragBegin(indices, aSource); // add a token to the pasteboard PasteboardViewDragData token = new PasteboardViewDragData(); NSData tokenData = NSKeyedArchiver.ArchivedDataWithRootObject(token); token.Release(); aPasteboard.DeclareTypesOwner(NSArray.ArrayWithObject(PasteboardViewDragData.PboardType), null); aPasteboard.SetDataForType(tokenData, PasteboardViewDragData.PboardType); return(indices.Count); }
public bool TableViewWriteToPasteboard(NSTableView aTableView, NSIndexSet aRows, NSPasteboard aPasteboard) { Console.WriteLine("TableViewWriteToPasteboard::" + aRows.Count); iDraggedBookmarks = new List <Bookmark>(); uint index = aRows.FirstIndex; while (index != FoundationFramework.NSNotFound) { iDraggedBookmarks.Add(iBookmarks[(int)index].CastAs <BookmarkData>().Bookmark); index = aRows.IndexGreaterThanIndex(index); } // add a token to the pasteboard PasteboardViewDragDataBookmarks token = new PasteboardViewDragDataBookmarks(); NSData tokenData = NSKeyedArchiver.ArchivedDataWithRootObject(token); token.Release(); aPasteboard.DeclareTypesOwner(NSArray.ArrayWithObject(PasteboardViewDragDataBookmarks.PboardType), null); aPasteboard.SetDataForType(tokenData, PasteboardViewDragDataBookmarks.PboardType); iDragging = true; return(true); }
// Overrides required for drag and drop public override bool WriteRows(NSTableView tableView, Foundation.NSIndexSet rowIndexes, NSPasteboard pboard) { NSData data = NSKeyedArchiver.ArchivedDataWithRootObject(rowIndexes); pboard.DeclareTypes(new string[] { DungeonToolsConstants.ECOUNTER_INITIATIVE_DRAG_DROP_TYPE }, this); pboard.SetDataForType(data, DungeonToolsConstants.ECOUNTER_INITIATIVE_DRAG_DROP_TYPE); return(true); }
public override bool WriteRows(NSTableView tableView, NSIndexSet rowIndexes, NSPasteboard pboard) { // Copy the row numbers to the pasteboard. NSData zNSIndexSetData = NSKeyedArchiver.ArchivedDataWithRootObject(rowIndexes); string[] typeArray = { "NSStringPboardType" }; pboard.DeclareTypes(typeArray, this); pboard.SetDataForType(zNSIndexSetData, "NSStringPboardType"); return(true); }
public void WriteToPasteBoard(NSPasteboard pb) { // Copy data to the pasteboard pb.ClearContents(); pb.DeclareTypes(pboardTypes, null); pb.SetStringForType(mLetter, pboardTypes[0]); CGRect r = this.Bounds; NSData data = this.DataWithPdfInsideRect(r); pb.SetDataForType(data, pboardTypes[1]); }
public void ProvideData(NSPasteboard pboard, NSString type) { NSData data; var obj = DataSource(); if (obj is NSImage) { data = ((NSImage)obj).AsTiff(); } else if (obj is Uri) { data = NSData.FromUrl((NSUrl)((Uri)obj)); } else if (obj is string) { data = NSData.FromString((string)obj); } else { data = NSData.FromArray(TransferDataSource.SerializeValue(obj)); } pboard.SetDataForType(data, type); }
public void ProvideData(NSPasteboard pboard, NSString type) { NSData data; var obj = DataSource (); if (obj is Xwt.Drawing.Image) { var bmp = ((Xwt.Drawing.Image)obj).ToBitmap (); data = ((NSImage)Toolkit.GetBackend (bmp)).AsTiff (); } else if (obj is NSImage) data = ((NSImage)obj).AsTiff (); else if (obj is Uri) data = NSData.FromUrl ((NSUrl)((Uri)obj)); else if (obj is string) data = NSData.FromString ((string)obj); else data = NSData.FromArray (TransferDataSource.SerializeValue (obj)); pboard.SetDataForType (data, type); }
public void PasteboardProvideDataForType(NSPasteboard sender, NSString type) { // Sender has accepted the drag and now we need to send the data for the type we promised if (type.Compare(NSPasteboard.NSTIFFPboardType) == NSComparisonResult.NSOrderedSame) { sender.SetDataForType(this.Image.TIFFRepresentation, NSPasteboard.NSTIFFPboardType); } else if (type.Compare(NSPasteboard.NSPDFPboardType) == NSComparisonResult.NSOrderedSame) { sender.SetDataForType(this.DataWithPDFInsideRect(this.Bounds), NSPasteboard.NSPDFPboardType); } }
public void ProvideData (NSPasteboard pboard, NSString type) { NSData data; var obj = DataSource (); if (obj is NSImage) data = ((NSImage)obj).AsTiff (); else if (obj is Uri) data = NSData.FromUrl ((NSUrl)((Uri)obj)); else if (obj is string) data = NSData.FromString ((string)obj); else data = NSData.FromArray (TransferDataSource.SerializeValue (obj)); pboard.SetDataForType (data, type); }
public override void Apply(NSPasteboard pasteboard, string type) => pasteboard.SetDataForType(Value, type);
/// <summary> /// Prepares the pasteboard. /// </summary> /// <param name="pasteboard">The pasteboard to use.</param> /// <param name="dataType">The data type to put on the pasteboard.</param> /// <param name="data">The wrapped data to put onto the pasteboard.</param> public static void PreparePasteboard(NSPasteboard pasteboard, string dataType, NSDataWrapper data) { pasteboard.ClearContents(); pasteboard.SetDataForType(data, dataType); PasteboardHelperData[pasteboard] = data; }
public bool WriteRowsWithIndexesToPasteboard(NSTableView tableView, NSIndexSet rowIndexes, NSPasteboard pboard) { //Console.WriteLine(">>> WriteRowsWithIndexesToPasteboard"); string dataType = string.Empty; if (tableView == tableSegments) dataType = "Segment"; else if (tableView == tableMarkers) dataType = "Marker"; pboard.DeclareTypes(new string[1] { dataType }, this); byte index = (byte)rowIndexes.Last(); var data = NSData.FromArray(new byte[1] { index }); pboard.SetDataForType(data, dataType); return true; }