public async void PasteTextToRows() { DataPackageView dataPackage = null; dataPackage = Clipboard.GetContent(); DataPackage package = new DataPackage(); if (dataPackage.AvailableFormats.Count <= 0) { return; } package.SetText(await dataPackage.GetTextAsync()); if (dataPackage.Contains(StandardDataFormats.Text)) { var clipBoardContent = await dataPackage.GetTextAsync(); if (clipBoardContent == null) { return; } // Split the ClipboardConent to number of rows var copiedRecords = Regex.Split(clipBoardContent.ToString(), @"\r\n"); //Considered only ExcludeFirstLine while pasting if (dataGrid.GridPasteOption.HasFlag(GridPasteOption.ExcludeFirstLine)) { copiedRecords = copiedRecords.Skip(1).ToArray(); } PasteToRows(copiedRecords); } }
protected virtual void PasteRowsToClipboard() #endif { if (this.TreeGrid.SelectedItem == null) { return; } var args = this.RaisePasteContentEvent(new GridCopyPasteEventArgs(false, this.TreeGrid)); if (args.Handled) { return; } #if UWP DataPackageView dataPackage = null; dataPackage = Clipboard.GetContent(); DataPackage package = new DataPackage(); if (dataPackage.AvailableFormats.Count <= 0) { return; } package.SetText(await dataPackage.GetTextAsync()); #else IDataObject dataObject = null; dataObject = Clipboard.GetDataObject(); #endif #if UWP if (dataPackage.Contains(StandardDataFormats.Text)) { var clipBoardContent = await dataPackage.GetTextAsync(); #else if (dataObject.GetDataPresent(DataFormats.UnicodeText)) { var clipBoardContent = dataObject.GetData(DataFormats.UnicodeText) as string; #endif if (clipBoardContent == null) { return; } var copiedRecords = Regex.Split(clipBoardContent.ToString(), @"\r\n"); //Considered only ExcludeHeader while pasting if (TreeGrid.GridPasteOption.HasFlag(GridPasteOption.ExcludeFirstLine)) { copiedRecords = copiedRecords.Skip(1).ToArray(); } PasteRows(copiedRecords); } }
public static async Task <IReadOnlyList <string> > GetAsPathListAsync(this DataPackageView View) { List <string> PathList = new List <string>(); if (View.Contains(StandardDataFormats.StorageItems)) { PathList.AddRange((await View.GetStorageItemsAsync()).Select((Item) => Item.Path)); } if (View.Contains(StandardDataFormats.Text)) { string XmlText = await View.GetTextAsync(); if (XmlText.Contains("RX-Explorer")) { XmlDocument Document = new XmlDocument(); Document.LoadXml(XmlText); IXmlNode KindNode = Document.SelectSingleNode("/RX-Explorer/Kind"); if (KindNode?.InnerText == "RX-Explorer-TransferNotStorageItem") { PathList.AddRange(Document.SelectNodes("/RX-Explorer/Item").Select((Node) => Node.InnerText)); } } } return(PathList); }
private static async void Textbox_Paste(object sender, TextControlPasteEventArgs e) { e.Handled = true; DataPackageView dataPackageView = Clipboard.GetContent(); if (!dataPackageView.Contains(StandardDataFormats.Text)) { return; } var pasteText = await dataPackageView.GetTextAsync(); if (string.IsNullOrWhiteSpace(pasteText)) { return; } var textbox = (TextBox)sender; var mask = textbox.GetValue(MaskProperty) as string; var representationDictionary = textbox?.GetValue(RepresentationDictionaryProperty) as Dictionary <char, string>; var placeHolderValue = textbox.GetValue(PlaceHolderProperty) as string; if (string.IsNullOrWhiteSpace(mask) || representationDictionary == null || string.IsNullOrEmpty(placeHolderValue)) { return; } // to update the textbox text without triggering TextChanging text textbox.TextChanging -= Textbox_TextChanging; SetTextBoxValue(pasteText, textbox, mask, representationDictionary, placeHolderValue[0]); textbox.SetValue(OldTextProperty, textbox.Text); textbox.TextChanging += Textbox_TextChanging; }
// 履歴を取得する基本的な流れ(説明用) public static async Task GetClipboardHistoryAsync() { if (!Clipboard.IsHistoryEnabled()) { return; // 設定で履歴が無効にされている } var result = await Clipboard.GetHistoryItemsAsync(); // 履歴の取得に失敗したときは、result.Statusに // Success以外(AccessDeniedまたはClipboardHistoryDisabled)が返される if (result.Status != ClipboardHistoryItemsResultStatus.Success) { return; } // 履歴のリストを取り出す IReadOnlyList <ClipboardHistoryItem> historyList = result.Items; // それぞれの履歴アイテムを処理する foreach (ClipboardHistoryItem item in historyList) { // 履歴アイテムのIDとタイムスタンプ string id = item.Id; DateTimeOffset timestamp = item.Timestamp; // データ(クリップボードのデータと同じ型) DataPackageView content = item.Content; // テキストデータを取り出す例 if (content.Contains(StandardDataFormats.Text)) { string textData = await content.GetTextAsync(); // DataPackageViewに入っているデータは、 // このようにして非同期メソッドを使って取得する } // データとして入っているフォーマットの一覧 List <string> formats = content.AvailableFormats.ToList(); // content.AvailableFormatsはSystem.__ComObjectのリストなので、 // ToList拡張メソッドを使って「こっちの世界に固定する」 // 全てのデータを取りだす例 foreach (string format in formats) { object data = await content.GetDataAsync(format); //Type dataType = data.GetType(); //if (dataType.FullName == "System.__ComObject") //{ // // ただし、GetTypeしてもSystem.__ComObject型が返ってきてしまい、 // // その実体が何であるか不明なデータもある // var types = dataType.GetInterfaces(); //←ITypeInfoを実装していないのでは何だか分からない //} } // ローミングされてクリップボードに入れられたデータかどうか bool isFromRoamingClipboard = content.Properties.IsFromRoamingClipboard; } }
public UwpHalProxy(object context, Windows.UI.Xaml.Controls.Frame act) { this.appContext = context; this.activity = act; //AndroidHalProxy.swipeRecognizer = new DroidSwipeGestureRecognizer(context); try { this.logPath = Path.Combine(appData.Path, "log.txt"); } catch { doLog = false; } Clipboard.ContentChanged += async(s, e) => { DataPackageView dataPackageView = Clipboard.GetContent(); if (dataPackageView.Contains(StandardDataFormats.Text)) { string text = await dataPackageView.GetTextAsync(); // To output the text from this example, you need a TextBlock control this.clipBoardText = text.Split(new char[] { '\r', '\n' }, StringSplitOptions.RemoveEmptyEntries).ToList(); } }; }
private async void ButtonGetHtml_Click(object sender, RoutedEventArgs e) { DataPackageView clipboardContent = Clipboard.GetContent(); if (clipboardContent.Contains(StandardDataFormats.Text)) { rawCode = await clipboardContent.GetTextAsync(); var rawDocument = new HtmlDocument(); rawDocument.LoadHtml(rawCode); var baseNode = rawDocument.DocumentNode.Element("div"); if (baseNode != null && baseNode.GetAttributeValue("class", "").Contains("WB_cardwrap")) { var weiboPost = new WeiboPostParser(baseNode); TextBoxMarkdownCode.Document.SetText(Windows.UI.Text.TextSetOptions.None, weiboPost.GetJekyllCode()); } else { MessageDialog dlgInvalidText = new MessageDialog("The text in system clipboard is invalid.", "Notice"); await dlgInvalidText.ShowAsync(); } } else { MessageDialog dlgNoText = new MessageDialog("No text in system clipboard.", "Notice"); await dlgNoText.ShowAsync(); } }
private async void OnRichEditBoxPaste(object sender, TextControlPasteEventArgs e) { try { DataPackageView dataPackageView = Clipboard.GetContent(); string text = null; string html = null; if (dataPackageView.Contains(StandardDataFormats.Text)) { text = await dataPackageView.GetTextAsync(); } if (dataPackageView.Contains(StandardDataFormats.Html)) { html = await dataPackageView.GetHtmlFormatAsync(); } // lots of hack, but basically, it's just for OneNote... if (this.rtbNotes.Document.Selection != null && html != null && html.Contains("Version:1.0") && !html.Contains("SourceURL") && html.Contains("<meta name=Generator content=\"Microsoft OneNote")) { this.rtbNotes.Document.Selection.TypeText(text); e.Handled = true; } } catch (Exception ex) { TrackingManagerHelper.Exception(ex, "Exception while pasting data: " + ex); e.Handled = false; } }
public async static void Update(int _index) { if (IsClipBoardSenseOn) { DataPackageView dataPackageView = Clipboard.GetContent(); if (dataPackageView.Contains(StandardDataFormats.Text)) { string text = await dataPackageView.GetTextAsync(); if (ClipboardText != text) { if (LanguageHelper.IsValidWord(text)) { ClipboardText = text; if (_index == 0) { UpdateInternalNofinication(); } else { CompactOverlay_UpdateInternalNofinication(); } } } } } }
public async Task <string?> TryGetTextAsync() { try { DataPackageView view = Windows.ApplicationModel.DataTransfer.Clipboard.GetContent(); // Try to extract the requested content string?item; if (view.Contains(StandardDataFormats.Text)) { item = await view.GetTextAsync(); view.ReportOperationCompleted(DataPackageOperation.Copy); } else { item = null; } return(item); } catch { // Y u do dis? return(null); } }
/// <summary> /// 从剪切板获取文字 /// </summary> /// <returns></returns> public static async Task <string> GetTextAsync() { DataPackageView dataPackage = Clipboard.GetContent(); return(dataPackage.Contains(StandardDataFormats.Text) ? await dataPackage.GetTextAsync() : ""); }
private async void SearchButton_Click(object sender, RoutedEventArgs e) { switch (SearchButton.Visibility) { case Visibility.Collapsed: SearchBoxCollapse.Begin(); return; default: break; } SearchBoxShow.Begin(); SearchBox.Focus(FocusState.Programmatic); if (SearchBox.Text.IsNullorEmpty()) { Context.SearchItems.Clear(); // add clipboard text DataPackageView dataPackageView = Clipboard.GetContent(); if (dataPackageView.Contains(StandardDataFormats.Text)) { string text = await dataPackageView.GetTextAsync(); if (!string.IsNullOrWhiteSpace(text)) { Context.SearchItems.Add(new GenericMusicItemViewModel() { Title = text, InnerType = MediaType.Placeholder, Description = "\uE16D", }); } } // add search history var searches = await SQLOperator.Current().GetSearchHistoryAsync(); foreach (var item in searches) { Context.SearchItems.Add(new GenericMusicItemViewModel() { Title = item.Query, InnerType = MediaType.Placeholder, Description = "\uE81C", }); } } if (!SearchBox.Items.IsNullorEmpty()) { SearchBox.IsSuggestionListOpen = true; } else { SearchBox.IsSuggestionListOpen = false; } }
private async void b_pasteflyout_Click(object sender, RoutedEventArgs e) { DataPackageView dataPackageView = Clipboard.GetContent(); if (dataPackageView.Contains(StandardDataFormats.Text)) { t_ipinput.Text = await dataPackageView.GetTextAsync(); } }
private static async Task ProcessComandsAsync(DropConfiguration configuration, DataPackageView dataview) { if (configuration.OnDropDataViewCommand != null) { configuration.OnDropDataViewCommand.Execute(dataview); } if (dataview.Contains(StandardDataFormats.ApplicationLink) && configuration.OnDropApplicationLinkCommand != null) { var uri = await dataview.GetApplicationLinkAsync(); configuration.OnDropApplicationLinkCommand.Execute(uri); } if (dataview.Contains(StandardDataFormats.Bitmap) && configuration.OnDropBitmapCommand != null) { var stream = await dataview.GetBitmapAsync(); configuration.OnDropBitmapCommand.Execute(stream); } if (dataview.Contains(StandardDataFormats.Html) && configuration.OnDropHtmlCommand != null) { var html = await dataview.GetHtmlFormatAsync(); configuration.OnDropHtmlCommand.Execute(html); } if (dataview.Contains(StandardDataFormats.Rtf) && configuration.OnDropRtfCommand != null) { var rtf = await dataview.GetRtfAsync(); configuration.OnDropRtfCommand.Execute(rtf); } if (dataview.Contains(StandardDataFormats.StorageItems) && configuration.OnDropStorageItemsCommand != null) { var storageItems = await dataview.GetStorageItemsAsync(); configuration.OnDropStorageItemsCommand.Execute(storageItems); } if (dataview.Contains(StandardDataFormats.Text) && configuration.OnDropTextCommand != null) { var text = await dataview.GetTextAsync(); configuration.OnDropTextCommand.Execute(text); } if (dataview.Contains(StandardDataFormats.WebLink) && configuration.OnDropWebLinkCommand != null) { var uri = await dataview.GetWebLinkAsync(); configuration.OnDropWebLinkCommand.Execute(uri); } }
private async void Flyout_Opened(object sender, object e) { t_ipinput.Text = ""; b_connectflyout.IsEnabled = false; DataPackageView dataPackageView = Clipboard.GetContent(); b_pasteflyout.IsEnabled = dataPackageView.Contains(StandardDataFormats.Text) && HostNameProvider.IsIPv4(await dataPackageView.GetTextAsync()); }
public async Task ProcessComandsAsync(DataPackageView dataview) { if (DropDataViewAction != null) { DropDataViewAction.Invoke(dataview); } if (dataview.Contains(StandardDataFormats.ApplicationLink) && DropApplicationLinkAction != null) { var uri = await dataview.GetApplicationLinkAsync(); DropApplicationLinkAction.Invoke(uri); } if (dataview.Contains(StandardDataFormats.Bitmap) && DropBitmapAction != null) { var stream = await dataview.GetBitmapAsync(); DropBitmapAction.Invoke(stream); } if (dataview.Contains(StandardDataFormats.Html) && DropHtmlAction != null) { var html = await dataview.GetHtmlFormatAsync(); DropHtmlAction.Invoke(html); } if (dataview.Contains(StandardDataFormats.Rtf) && DropRtfAction != null) { var rtf = await dataview.GetRtfAsync(); DropRtfAction.Invoke(rtf); } if (dataview.Contains(StandardDataFormats.StorageItems) && DropStorageItemsAction != null) { var storageItems = await dataview.GetStorageItemsAsync(); DropStorageItemsAction.Invoke(storageItems); } if (dataview.Contains(StandardDataFormats.Text) && DropTextAction != null) { var text = await dataview.GetTextAsync(); DropTextAction.Invoke(text); } if (dataview.Contains(StandardDataFormats.WebLink) && DropWebLinkAction != null) { var uri = await dataview.GetWebLinkAsync(); DropWebLinkAction.Invoke(uri); } }
public async Task ProcessComandsAsync(DataPackageView dataview) { if (DropDataViewAction != null) { DropDataViewAction.Invoke(dataview); } if (dataview.Contains(StandardDataFormats.ApplicationLink) && DropApplicationLinkAction != null) { Uri uri = await dataview.GetApplicationLinkAsync(); DropApplicationLinkAction.Invoke(uri); } if (dataview.Contains(StandardDataFormats.Bitmap) && DropBitmapAction != null) { RandomAccessStreamReference stream = await dataview.GetBitmapAsync(); DropBitmapAction.Invoke(stream); } if (dataview.Contains(StandardDataFormats.Html) && DropHtmlAction != null) { string html = await dataview.GetHtmlFormatAsync(); DropHtmlAction.Invoke(html); } if (dataview.Contains(StandardDataFormats.Rtf) && DropRtfAction != null) { string rtf = await dataview.GetRtfAsync(); DropRtfAction.Invoke(rtf); } if (dataview.Contains(StandardDataFormats.StorageItems) && DropStorageItemsAction != null) { IReadOnlyList <IStorageItem> storageItems = await dataview.GetStorageItemsAsync(); DropStorageItemsAction.Invoke(storageItems); } if (dataview.Contains(StandardDataFormats.Text) && DropTextAction != null) { string text = await dataview.GetTextAsync(); DropTextAction.Invoke(text); } if (dataview.Contains(StandardDataFormats.WebLink) && DropWebLinkAction != null) { Uri uri = await dataview.GetWebLinkAsync(); DropWebLinkAction.Invoke(uri); } }
public string GetTextData() { DataPackageView dataPackageView = Clipboard.GetContent(); if (dataPackageView.Contains(StandardDataFormats.Text)) { return(dataPackageView.GetTextAsync().GetResults()); } return(null); }
private async void TextBox_KeyUpAsync(object sender, KeyRoutedEventArgs e) { DataPackageView dataPackageView = Clipboard.GetContent(); if (dataPackageView.Contains(StandardDataFormats.Text)) { string text = await dataPackageView.GetTextAsync(); Google.Navigate(new Uri("http://www.google.com/search?q=" + text)); } }
async void OutputClipboardText() { DataPackageView dataPackageView = Clipboard.GetContent(); if (dataPackageView.Contains(StandardDataFormats.Text)) { string text = await dataPackageView.GetTextAsync(); outputtext.Text = "Clipboard now contains:" + text; } }
private async void copy_Click(object sender, Windows.UI.Xaml.RoutedEventArgs e) { DataPackageView dpv = Clipboard.GetContent(); if (dpv.Contains(StandardDataFormats.Text)) { string txt = await dpv.GetTextAsync(); txt2.Text = txt; } }
public async Task <string> GetText() { DataPackageView dataPackageView = Windows.ApplicationModel.DataTransfer.Clipboard.GetContent(); if (dataPackageView.Contains(StandardDataFormats.Text)) { string text = await dataPackageView.GetTextAsync(); return(text); } return(""); }
internal static string GetText() { string toReturn = null; DataPackageView dataPackageView = Windows.ApplicationModel.DataTransfer.Clipboard.GetContent(); if (dataPackageView.Contains(StandardDataFormats.Text)) { toReturn = Task.Run(async() => await dataPackageView.GetTextAsync()).Result; } return(toReturn); }
/// <summary> /// [貼り付け]ボタンを押した時の処理 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private async void btnPaste_Click(object sender, RoutedEventArgs e) { // クリップボードからデータを取得する DataPackageView dataPackageView = Clipboard.GetContent(); string strMemo = await dataPackageView.GetTextAsync(); // 取得した文字をtxtMemoのキャレットの位置に挿入する txtMemo.Text = txtMemo.Text.Insert(txtMemo.SelectionStart, strMemo); // 再度txtMemoにフォーカスを当てる txtMemo.Focus(FocusState.Programmatic); }
public static async Task <string> OutputClipboardText() { DataPackageView dataPackageView = Clipboard.GetContent(); if (dataPackageView.Contains(StandardDataFormats.Text)) { string text = await dataPackageView.GetTextAsync(); return(text); } return(await Task.FromResult(String.Empty)); }
internal static async Task <string> SetData(DataPackageView data) { string type = ""; if (data.Contains(StandardDataFormats.StorageItems)) { var items = await data.GetStorageItemsAsync(); var files = items.Where(x => x is StorageFile).Select(x => x as StorageFile).ToList(); string url = ""; if ((files.Count == 1) && ((files[0].FileType.ToLower() == ".html") /* Edge */ || (files[0].FileType.ToLower() == ".url") /* Chrome + Firefox */) && ((url = await IsALink(files[0])) != "")) { SendDataTemporaryStorage.LaunchUri = new Uri(url); SendDataTemporaryStorage.Text = url; type = StandardDataFormats.WebLink; } else if ((files.Count == 0) && (items.Count == 1) && (items[0] is StorageFolder)) { SendDataTemporaryStorage.Files = new List <IStorageItem>(items); type = StandardDataFormats.StorageItems; } else { SendDataTemporaryStorage.Files = new List <IStorageItem>(files); type = StandardDataFormats.StorageItems; } } else if (data.Contains(StandardDataFormats.WebLink)) { SendDataTemporaryStorage.LaunchUri = await data.GetWebLinkAsync(); SendDataTemporaryStorage.Text = SendDataTemporaryStorage.LaunchUri.OriginalString; type = StandardDataFormats.WebLink; } else if (data.Contains(StandardDataFormats.ApplicationLink)) { SendDataTemporaryStorage.LaunchUri = await data.GetApplicationLinkAsync(); SendDataTemporaryStorage.Text = SendDataTemporaryStorage.LaunchUri.OriginalString; type = StandardDataFormats.ApplicationLink; } else if (data.Contains(StandardDataFormats.Text)) { SendDataTemporaryStorage.Text = await data.GetTextAsync(); type = StandardDataFormats.Text; } return(type); }
public async void Paste() { DataPackageView dataPackageView = Clipboard.GetContent(); if (dataPackageView.Contains(StandardDataFormats.Text)) { string text = await dataPackageView.GetTextAsync(); // To output the text from this example, you need a TextBlock control _core.Document.Selection.SetText(TextSetOptions.None, text); _core.Document.Selection.SetRange(_core.Document.Selection.EndPosition, _core.Document.Selection.EndPosition); } }
private async void Clipboard_ContentChanged(object sender, object e) { DataPackageView dataPackageView = Clipboard.GetContent(); if (dataPackageView.Contains(StandardDataFormats.Text)) { string text = await dataPackageView.GetTextAsync(); Clipboard.Clear(); // To output the text from this example, you need a TextBlock control Debug.WriteLine("Clipboard now contains: " + text); } }
private async void Clipboard_ContentChanged(object sender, object e) { if (isFocused) { DataPackageView dataPackageView = Clipboard.GetContent(); if (dataPackageView.Contains(StandardDataFormats.Text)) { string text = await dataPackageView.GetTextAsync(); currentClipboardValue = text; } } }
private async void OnGetSecondaryItems(DataPackageView dataview) { if (dataview.Contains(StandardDataFormats.StorageItems)) { await InsertItems(dataview, SecondaryItems); } if (dataview.Contains(StandardDataFormats.Text)) { var itemsId = await dataview.GetTextAsync(); MoveItems(itemsId, PrimaryItems, SecondaryItems); } }