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

            b.WriteObjects(new INSPasteboardWriting [] { (NSString)"asfd" });
            b.WriteObjects(new NSPasteboardWriting [] { new MyPasteboard() });
        }
        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
        }
Exemple #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);
        }
Exemple #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();
        }