public static DataPackageView GetContent() { var manager = ContextHelper.Current.GetSystemService(Context.ClipboardService) as ClipboardManager; if (manager is null) { return(null); } var clipData = manager.PrimaryClip; string clipText = null; Uri clipUri = null; string clipHtml = null; for (int itemIndex = 0; itemIndex < clipData.ItemCount; itemIndex++) { var itemText = clipData.GetItemAt(itemIndex).Text; if (itemText != null) { clipText = itemText; } var itemUri = clipData.GetItemAt(itemIndex).Uri; if (itemUri != null) { clipUri = new Uri(itemUri.ToString()); } var itemHtml = clipData.GetItemAt(itemIndex).HtmlText; if (itemText != null) { clipHtml = itemHtml; } } var clipView = new DataPackageView(); if (clipText != null) { clipView.SetFormatTask(StandardDataFormats.Text, Task.FromResult(clipText)); } if (clipHtml != null) { clipView.SetFormatTask(StandardDataFormats.Html, Task.FromResult(clipHtml)); } if (clipUri != null) { clipView.SetFormatTask(StandardDataFormats.Uri, Task.FromResult(clipUri)); clipView.SetFormatTask(StandardDataFormats.WebLink, Task.FromResult(clipUri)); } return(clipView); }
public static DataPackageView GetContent() { var dataPackageView = new DataPackageView(); if (UIPasteboard.General.String != null) { dataPackageView.SetFormatTask(StandardDataFormats.Text, Task.FromResult(UIPasteboard.General.String)); } return(dataPackageView); }
public static DataPackageView GetContent() { var dataPackageView = new DataPackageView(); var command = $"{JsType}.getText()"; var getTextTask = WebAssemblyRuntime.InvokeAsync(command); dataPackageView.SetFormatTask(StandardDataFormats.Text, getTextTask); return(dataPackageView); }
public static DataPackageView GetContent() { var dataPackageView = new DataPackageView(); var pasteboard = NSPasteboard.GeneralPasteboard; var clipboardText = pasteboard.GetStringForType(NSPasteboard.NSPasteboardTypeString); if (clipboardText != null) { dataPackageView.SetFormatTask(StandardDataFormats.Text, Task.FromResult(clipboardText)); } return(dataPackageView); }
public DataPackageView GetView() { var clipView = new DataPackageView(); if (Text != null) { clipView.SetFormatTask(StandardDataFormats.Text, Task.FromResult(Text)); } if (Html != null) { clipView.SetFormatTask(StandardDataFormats.Html, Task.FromResult(Html)); } if (Uri != null) { clipView.SetFormatTask(StandardDataFormats.Uri, Task.FromResult(Uri)); clipView.SetFormatTask(StandardDataFormats.WebLink, Task.FromResult(Uri)); } return(clipView); }