public void CopyImage(NSObject sender) { // Grab the current image var image = ImageView.Image; // Anything to process? if (image != null) { // Get the standard pasteboard var pasteboard = NSPasteboard.GeneralPasteboard; // Empty the current contents pasteboard.ClearContents(); // Add the current image to the pasteboard pasteboard.WriteObjects(new NSImage[] { image }); // Save the custom data class to the pastebaord pasteboard.WriteObjects(new ImageInfo[] { Info }); // Using a Pasteboard Item NSPasteboardItem item = new NSPasteboardItem(); string[] writableTypes = { "public.text" }; // Add a data provier to the item ImageInfoDataProvider dataProvider = new ImageInfoDataProvider(Info.Name, Info.ImageType); var ok = item.SetDataProviderForTypes(dataProvider, writableTypes); // Save to pasteboard if (ok) { pasteboard.WriteObjects(new NSPasteboardItem[] { item }); } } }
public void CopyImage(NSObject sender) { // Grab the current image var image = ImageView.Image; // Anything to process? if (image != null) { // Get the standard pasteboard var pasteboard = NSPasteboard.GeneralPasteboard; // Empty the current contents pasteboard.ClearContents(); // Add the current image to the pasteboard pasteboard.WriteObjects (new NSImage[] {image}); // Save the custom data class to the pastebaord pasteboard.WriteObjects (new ImageInfo[] { Info }); // Using a Pasteboard Item NSPasteboardItem item = new NSPasteboardItem(); string[] writableTypes = {"public.text"}; // Add a data provier to the item ImageInfoDataProvider dataProvider = new ImageInfoDataProvider (Info.Name, Info.ImageType); var ok = item.SetDataProviderForTypes (dataProvider, writableTypes); // Save to pasteboard if (ok) { pasteboard.WriteObjects (new NSPasteboardItem[] { item }); } } }