partial void OnButtonCopy(Foundation.NSObject sender) { NSPasteboard pb = NSPasteboard.GeneralPasteboard; pb.DeclareTypes(new string [] { NSPasteboard.NSStringType }, null); pb.SetStringForType(GuiGeneratedEmailField.StringValue, NSPasteboard.NSStringType); }
// 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) { pboard.DeclareTypes(new string[] { NSPasteboard.NSFilesPromiseType }, this); NSArray a = NSArray.FromStrings(new string[] { "" }); pboard.SetPropertyListForType(a, NSPasteboard.NSFilesPromiseType); 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); }
// copy a string to the pasteboard public static void CopyString(string text) { if (text != null) { NSPasteboard clipboard = NSPasteboard.GeneralPasteboard; string[] types = { "NSStringPboardType" }; clipboard.DeclareTypes(types, null); clipboard.SetStringForType(text, types[0]); } }
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 override bool OutlineViewwriteItemstoPasteboard(NSOutlineView outlineView, NSArray items, NSPasteboard pboard) { if (outlineView.SelectedRow < 0 || outlineView.SelectedRowCount <= 0) { return(false); } pboard.DeclareTypes(new string[] { NSPasteboard.NSFilesPromiseType }, this); pboard.SetPropertyListForType(NSArray.FromStrings(new string[] { "" }), NSPasteboard.NSFilesPromiseType); return(true); }
/// <summary> /// Copies to clipboard selected item password. /// </summary> private void CopyToClipboardSelectedItemPassword() { EntriesDataSource ds = (EntriesTableView.DataSource as EntriesDataSource); EntryModel selected = ds.Items[EntriesTableView.SelectedRow]; string passwordToCopy = selected.Password; NSPasteboard pasteBoard = NSPasteboard.GeneralPasteboard; pasteBoard.DeclareTypes(new string[] { NSPasteboard.NSStringType }, null); pasteBoard.SetStringForType(passwordToCopy, NSPasteboard.NSStringType); //Console.WriteLine("Pasted: " + pasteBoard.GetStringForType(NSPasteboard.NSStringType)); }
partial void OnCopy(Foundation.NSObject sender) { int row = (int)GuiTableEmails.SelectedRow; if (row < 0) { return; } PrivateEmailInfo email = __Model.PrivateEmails [row]; NSPasteboard pb = NSPasteboard.GeneralPasteboard; pb.DeclareTypes(new string [] { NSPasteboard.NSStringType }, null); pb.SetStringForType(email.Email, NSPasteboard.NSStringType); }
private void CreateShare(Account account, string path) { GettProvider.Instance.CreateShare( "test1", account.AccessToken, path, (url) => { BeginInvokeOnMainThread(() => { // placing link into clipboard NSPasteboard pb = NSPasteboard.GeneralPasteboard; pb.DeclareTypes(new string[] { NSPasteboard.NSStringType }, null); pb.SetStringForType(url, NSPasteboard.NSStringType); Console.WriteLine("File will be available for download from {0}", url); }); } ); }
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]); }
private static async Task SetToNativeAsync(DataPackage content, NSPasteboard pasteboard) { if (pasteboard is null) { throw new ArgumentException(nameof(pasteboard)); } var data = content?.GetView(); var declaredTypes = new List <string>(); string?uri = null; /* Note that order is somewhat important here. * * According to the docs: * "types should be ordered according to the preference of the source application, * with the most preferred type coming first" * https://developer.apple.com/documentation/appkit/nspasteboard/1533561-declaretypes?language=objc * * This means we want to process certain types like HTML/RTF before general plain text * as they are more specific. * * Types are also declared before setting */ // Declare types if (data?.Contains(StandardDataFormats.Html) ?? false) { declaredTypes.Add(NSPasteboard.NSPasteboardTypeHTML); } if (data?.Contains(StandardDataFormats.Rtf) ?? false) { // Use `NSPasteboardTypeRTF` instead of `NSPasteboardTypeRTFD` for max compatibility declaredTypes.Add(NSPasteboard.NSPasteboardTypeRTF); } if (data?.Contains(StandardDataFormats.Text) ?? false) { declaredTypes.Add(NSPasteboard.NSPasteboardTypeString); } if (data != null) { uri = DataPackage.CombineUri( data.Contains(StandardDataFormats.WebLink) ? (await data.GetWebLinkAsync()).ToString() : null, data.Contains(StandardDataFormats.ApplicationLink) ? (await data.GetApplicationLinkAsync()).ToString() : null, data.Contains(StandardDataFormats.Uri) ? (await data.GetUriAsync()).ToString() : null); if (string.IsNullOrEmpty(uri) == false) { declaredTypes.Add(NSPasteboard.NSPasteboardTypeUrl); } } pasteboard.DeclareTypes(declaredTypes.ToArray(), null); // Set content if (data?.Contains(StandardDataFormats.Html) ?? false) { var html = await data.GetHtmlFormatAsync(); pasteboard.SetStringForType(html ?? string.Empty, NSPasteboard.NSPasteboardTypeHTML); } if (data?.Contains(StandardDataFormats.Rtf) ?? false) { var rtf = await data.GetRtfAsync(); pasteboard.SetStringForType(rtf ?? string.Empty, NSPasteboard.NSPasteboardTypeRTF); } if (data?.Contains(StandardDataFormats.Text) ?? false) { var text = await data.GetTextAsync(); pasteboard.SetStringForType(text ?? string.Empty, NSPasteboard.NSPasteboardTypeString); } if (string.IsNullOrEmpty(uri) == false) { pasteboard.SetStringForType(uri !.ToString(), NSPasteboard.NSPasteboardTypeUrl); } return; }
void ItemDropped(string item) { Console.WriteLine("Item dropped: {0}", item); //var provider = ProviderFactory.GetInstance(); //if (provider.IsAuthenticated) { //} var provider = new FtpProvider(); if (provider.Authenticated) { Console.WriteLine("Uploading..."); provider.Upload(item, "asdf", (url) => { Console.WriteLine("very nice => " + url); }); } else { Console.WriteLine("authenticating..."); var username = ConfigurationSettings.AppSettings["FtpUsername"]; var password = ConfigurationSettings.AppSettings["FtpPassword"]; provider.Authenticate(username, password, account => { Console.WriteLine("cool. got: " + account); var fileInfo = new System.IO.FileInfo(item); provider.Upload(item, fileInfo.Name, (url) => { Console.WriteLine("very nice => " + url); BeginInvokeOnMainThread(() => { // placing link into clipboard NSPasteboard pb = NSPasteboard.GeneralPasteboard; pb.DeclareTypes(new string[] { NSPasteboard.NSStringType }, null); pb.SetStringForType(url, NSPasteboard.NSStringType); Console.WriteLine("File will be available for download from {0}", url); var sound = NSSound.FromName("Pop"); sound.Play(); }); }); }, err => { Console.WriteLine("not cool -- failed with: " + err); }); } //if (Account.IsAuthenticated) { // CreateShare(Account, item.Replace("file://localhost", "").Replace("%20", " ")); //} //else { // GettProvider.Instance.Authenticate(Account.Email, Account.Password, (account) => { // // user is logged in // // store retrieved access token for future requests // Account.AccessToken = account.AccessToken; // CreateShare(account, item.Replace("file://localhost", "").Replace("%20", " ")); // }, (error) => { // // TODO: handle error message when uploading // Console.WriteLine("Got an error: {0}", error); // }); //} }
private static async Task SetToNativeAsync(DataPackage content, NSPasteboard pasteboard) { if (pasteboard is null) { throw new ArgumentException(nameof(pasteboard)); } var data = content?.GetView(); var declaredTypes = new List <string>(); // Note that order is somewhat important here. // // According to the docs: // "types should be ordered according to the preference of the source application, // with the most preferred type coming first" // https://developer.apple.com/documentation/appkit/nspasteboard/1533561-declaretypes?language=objc // // This means we want to process certain types like HTML/RTF before general plain text // as they are more specific. // Types are also declared before setting // Declare types if (data?.Contains(StandardDataFormats.Html) ?? false) { declaredTypes.Add(NSPasteboard.NSPasteboardTypeHTML); } if (data?.Contains(StandardDataFormats.Rtf) ?? false) { // Use `NSPasteboardTypeRTF` instead of `NSPasteboardTypeRTFD` for max compatiblity declaredTypes.Add(NSPasteboard.NSPasteboardTypeRTF); } if (data?.Contains(StandardDataFormats.Text) ?? false) { declaredTypes.Add(NSPasteboard.NSPasteboardTypeString); } pasteboard.DeclareTypes(declaredTypes.ToArray(), null); // Set content if (data?.Contains(StandardDataFormats.Html) ?? false) { var html = await data.GetHtmlFormatAsync(); pasteboard.SetStringForType(html ?? string.Empty, NSPasteboard.NSPasteboardTypeHTML); } if (data?.Contains(StandardDataFormats.Rtf) ?? false) { var rtf = await data.GetRtfAsync(); pasteboard.SetStringForType(rtf ?? string.Empty, NSPasteboard.NSPasteboardTypeRTF); } if (data?.Contains(StandardDataFormats.Text) ?? false) { var text = await data.GetTextAsync(); pasteboard.SetStringForType(text ?? string.Empty, NSPasteboard.NSPasteboardTypeString); } }
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; }