예제 #1
0
 public bool WriteObjects(NSPasteboardWriting [] objects)
 {
     var nsa_pasteboardReading = NSArray.FromNSObjects (objects);
     bool result = WriteObjects (nsa_pasteboardReading.Handle);
     nsa_pasteboardReading.Dispose ();
     return result;
 }
예제 #2
0
        private NSDraggingItem CreateDraggingItem(string format, object data)
        {
            var    pasteboardItem = new NSPasteboardItem();
            NSData nsData;

            if (data is string s)
            {
                if (format == DataFormats.FileNames)
                {
                    s = new Uri(s).AbsoluteUri; // Ensure file uris...
                }
                nsData = NSData.FromString(s);
            }
            else if (data is Stream strm)
            {
                nsData = NSData.FromStream(strm);
            }
            else if (data is byte[] bytes)
            {
                nsData = NSData.FromArray(bytes);
            }
            else
            {
                BinaryFormatter bf = new BinaryFormatter();
                using (var ms = new MemoryStream())
                {
                    bf.Serialize(ms, data);
                    ms.Position = 0;
                    nsData      = NSData.FromStream(ms);
                }
            }
            pasteboardItem.SetDataForType(nsData, DataFormatToUTI(format));

            NSPasteboardWriting writing = new NSPasteboardWriting(pasteboardItem.Handle);

            return(new NSDraggingItem(writing));
        }
 CGRect SourceFrameOnScreenForShareItem(NSSharingService sharingService, NSPasteboardWriting item)
 {
     return(SourceFrameOnScreenForShareItem(sharingService, (INSPasteboardWriting)item));
 }
 NSImage TransitionImageForShareItem(NSSharingService sharingService, NSPasteboardWriting item, CGRect contentRect)
 {
     return(TransitionImageForShareItem(sharingService, (INSPasteboardWriting)item, contentRect));
 }
예제 #5
0
 public NSDraggingItem(NSPasteboardWriting pasteboardWriter)
     : this((INSPasteboardWriting)pasteboardWriter)
 {
 }
예제 #6
0
 public NSDraggingItem(NSPasteboardWriting pasteboardWriter) : this((INSPasteboardWriting)pasteboardWriter)
 {
 }
예제 #7
0
 NSImage TransitionImageForShareItem(NSSharingService sharingService, NSPasteboardWriting item, CGRect contentRect)
 {
     return TransitionImageForShareItem (sharingService, (INSPasteboardWriting)item, contentRect);
 }
예제 #8
0
 CGRect SourceFrameOnScreenForShareItem(NSSharingService sharingService, NSPasteboardWriting item)
 {
     return SourceFrameOnScreenForShareItem (sharingService, (INSPasteboardWriting)item);
 }