예제 #1
0
        public void NSPasteboardTests_WriteObjectTests()
        {
            NSPasteboard b = NSPasteboard.CreateWithUniqueName();

            b.WriteObjects(new INSPasteboardWriting [] { (NSString)"asfd" });
            b.WriteObjects(new NSPasteboardWriting [] { new MyPasteboard() });
        }
예제 #2
0
        public void NSPasteboardTests_WriteObjectTests()
        {
            NSPasteboard b = NSPasteboard.CreateWithUniqueName();

            b.WriteObjects(new INSPasteboardWriting [] { (NSString)"asfd" });
            b.WriteObjects(new NSPasteboardWriting [] { new MyPasteboard() });
#if !XAMCORE_2_0
            // Awesome backwards compat API
            b.WriteObjects(new NSPasteboardReading [] { new MyPasteboard2() });
#endif
        }
예제 #3
0
        public void DragFiles(string[] filenames)
        {
            // See Dragging File Paths:
            // https://developer.apple.com/library/archive/documentation/Cocoa/Conceptual/DragandDrop/Tasks/DraggingFiles.html
            var pboard = NSPasteboard.CreateWithUniqueName();

            pboard.DeclareTypes(new string [] { NSPasteboard.NSFilenamesType }, null);
            pboard.SetPropertyListForType(NSArray.FromObjects(filenames), NSPasteboard.NSFilenamesType);
            var dragImage = NSWorkspace.SharedWorkspace.IconForFiles(filenames);

            View.DragImage(dragImage, new CGPoint(), new CGSize(), new NSEvent(), pboard, View, false);
        }
예제 #4
0
        public void NSPasteboardTests_WriteObjectTests()
        {
            NSPasteboard b = NSPasteboard.CreateWithUniqueName();

            if (b == null)
            {
                Assert.Inconclusive("NSPasteboard could not be provided by the OS.");
            }
            b.WriteObjects(new INSPasteboardWriting [] { (NSString)"asfd" });
            b.WriteObjects(new NSPasteboardWriting [] { new MyPasteboard() });
            // from the docs: the lifetime of a unique pasteboard is not related to the lifetime of the creating app,
            // you must release a unique pasteboard by calling releaseGlobally to avoid possible leaks.
            b.ReleaseGlobally();
        }