當前位置: 首頁>>代碼示例>>C#>>正文


C# DataPackage.SetText方法代碼示例

本文整理匯總了C#中Windows.ApplicationModel.DataTransfer.DataPackage.SetText方法的典型用法代碼示例。如果您正苦於以下問題:C# DataPackage.SetText方法的具體用法?C# DataPackage.SetText怎麽用?C# DataPackage.SetText使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Windows.ApplicationModel.DataTransfer.DataPackage的用法示例。


在下文中一共展示了DataPackage.SetText方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: Transfer_DataRequested

 private void Transfer_DataRequested(DataTransferManager sender, DataRequestedEventArgs args)
 {
     if (!Equals(null, VM))
     {
         DataPackage dp = new DataPackage();
         switch (VM.GetType().Name)
         {
             case "PictureViewModel":
                 dp.Properties.Title = "分享圖片";
                 dp.SetText( $"一張圖片,千言萬語[來自ONE-UWP的分享]:{(VM as PictureViewModel).Picture.WebLk}");
                 break;
             case "ArticleViewModel":
                 dp.Properties.Title = "分享文章";
                 dp.SetText($"世間風情,字裏行間[來自ONE-UWP的分享]:{(VM as ArticleViewModel).Article.WebLk}");
                 break;
             case "QuestionViewModel":
                 dp.Properties.Title = "分享問題";
                 dp.SetText($"每天一問,有問必答[來自ONE-UWP的分享]:{(VM as QuestionViewModel).Question.WebLk}");
                 break;
             case "ThingViewModel":
                 dp.Properties.Title = "分享東西";
                 dp.SetText($"友好世界,有好東西[來自ONE-UWP的分享]:{(VM as ThingViewModel).Thing.Wu}");
                 break;
         }
         args.Request.Data = dp;
     }
     else
     {
         return;
     }
 }
開發者ID:hippieZhou,項目名稱:OneUWP,代碼行數:31,代碼來源:ShareManager.cs

示例2: MenuFlyoutItem_Click

 private void MenuFlyoutItem_Click(object sender, RoutedEventArgs e)
 {
     var item = sender as MenuFlyoutItem;
     var User = item.DataContext as VipUser;
     var dp = new DataPackage();
     if (item.Name == "Account")
     {
         dp.SetText(User.Account);
     }
     else if (item.Name=="Password")
     {
         dp.SetText(User.Password);
     }
     Clipboard.SetContent(dp);
 }
開發者ID:MikyWang,項目名稱:code-land,代碼行數:15,代碼來源:VipPage.xaml.cs

示例3: Grid_DoubleTapped

        private async void Grid_DoubleTapped(object sender, DoubleTappedRoutedEventArgs e)
        {
            Grid grid = (Grid)sender;
            Records.Items items = (Records.Items)grid.DataContext;
            String Data = String.Empty;
            ResourceLoader resourceLoader = new ResourceLoader();

            Data += String.Format(resourceLoader.GetString("pageResult_Assignment") + Environment.NewLine, items.Oid);
            Data += String.Format(resourceLoader.GetString("pageResult_Registry") + Environment.NewLine, items.RegistryID);
            Data += String.Format(resourceLoader.GetString("pageResult_OrganizationName") + Environment.NewLine, items.Name);
            Data += String.Format(resourceLoader.GetString("pageResult_OrganizationAddress") + Environment.NewLine, items.Address);

            if ( (items.Protocol != String.Empty) && (items.Protocol != null))
            {
                Data += String.Format(resourceLoader.GetString("pageResult_Protocol") + Environment.NewLine, items.Protocol);
            }

            DataPackage dataPackage = new DataPackage();

            dataPackage.SetText(Data);
            Clipboard.SetContent(dataPackage);

            MessageDialog msgbox = new MessageDialog(Data, resourceLoader.GetString("pageResult_DialogCopied"));

            msgbox.Commands.Clear();
            msgbox.Commands.Add(new UICommand { Label = resourceLoader.GetString("pageResult_DialogClose"), Id = 0 });
 
            var res = await msgbox.ShowAsync();
        }
開發者ID:EddyBeaupre,項目名稱:searchIEEE,代碼行數:29,代碼來源:pageResults.xaml.cs

示例4: OnNavigatedTo

        /// <summary>
        /// Invoked when this page is about to be displayed in a Frame.
        /// </summary>
        /// <param name="e">Event data that describes how this page was reached.  The Parameter
        /// property is typically used to configure the page.</param>
        protected override void OnNavigatedTo(NavigationEventArgs e)
        {
            XNamespace p_ns = "http://schemas.microsoft.com/winfx/2006/xaml/presentation";
            XNamespace xaml_ns = "http://schemas.microsoft.com/winfx/2006/xaml";

            var doc = XDocument.Load(@"Common\StandardStyles.xaml");
            foreach (var style in doc.Descendants(p_ns + "Style"))
            {
                var key = style.Attribute(xaml_ns + "Key");
                if (key != null && key.Value != null)
                {
                    var basedOn = style.Attribute("BasedOn");
                    if (basedOn != null && basedOn.Value == @"{StaticResource AppBarButtonStyle}")
                    {
                        var button = new Button();
                        button.Style = App.Current.Resources[key.Value] as Style;
                        ToolTipService.SetToolTip(button, key.Value);
                        button.Click += (sender, args) =>
                        {
                            string styleName = ToolTipService.GetToolTip(sender as Button) as string;
                            DataPackage clipboardData = new DataPackage();
                            clipboardData.SetText(styleName);
                            Clipboard.SetContent(clipboardData);
                        };
                        AppBarButtonListView.Items.Add(button);
                    }
                }
            }
        }
開發者ID:pixeltucker,項目名稱:MetroAppBarSample,代碼行數:34,代碼來源:MainPage.xaml.cs

示例5: CopyButton_Click

        void CopyButton_Click(object sender, RoutedEventArgs e)
        {
            OutputText.Text = "";
            OutputResourceMapKeys.Text = "";
            OutputHtml.NavigateToString("<HTML></HTML>");

            // Set the content to DataPackage as html format
            string htmlFormat = HtmlFormatHelper.CreateHtmlFormat(this.htmlFragment);
            var dataPackage = new DataPackage();
            dataPackage.SetHtmlFormat(htmlFormat);

            // Set the content to DataPackage as (plain) text format
            string plainText = HtmlUtilities.ConvertToText(this.htmlFragment);
            dataPackage.SetText(plainText);

            // Populate resourceMap with StreamReference objects corresponding to local image files embedded in HTML
            var imgUri = new Uri(imgSrc);
            var imgRef = RandomAccessStreamReference.CreateFromUri(imgUri);
            dataPackage.ResourceMap[imgSrc] = imgRef;

            try
            {
                // Set the DataPackage to clipboard.
                Windows.ApplicationModel.DataTransfer.Clipboard.SetContent(dataPackage);
                OutputText.Text = "Text and HTML formats have been copied to clipboard. ";
            }
            catch (Exception ex)
            {
                // Copying data to Clipboard can potentially fail - for example, if another application is holding Clipboard open
                rootPage.NotifyUser("Error copying content to Clipboard: " + ex.Message + ". Try again", NotifyType.ErrorMessage);
            }
        }
開發者ID:COMIsLove,項目名稱:Windows-universal-samples,代碼行數:32,代碼來源:CopyText.xaml.cs

示例6: CopyLink

 private void CopyLink()
 {
     DataPackage dataPackage = new DataPackage();
     dataPackage.RequestedOperation = DataPackageOperation.Copy;
     dataPackage.SetText(GetLinkToShare());
     Clipboard.SetContent(dataPackage);
 }
開發者ID:nilsbenson,項目名稱:MonocleGiraffe,代碼行數:7,代碼來源:AlbumPage.xaml.cs

示例7: Clipboard_Click

        private void Clipboard_Click(object sender, RoutedEventArgs e)
        {
            var dataPackage = new DataPackage();

            dataPackage.SetText(Match.AudioUrl);
            Clipboard.SetContent(dataPackage);
        }
開發者ID:haroldma,項目名稱:Audiotica,代碼行數:7,代碼來源:MatchViewer.xaml.cs

示例8: Copy_Click

        private void Copy_Click(object sender, RoutedEventArgs e)
        {
            DataPackage data = new DataPackage();
            data.SetText(tbInput.Text);
            Clipboard.SetContent(data);

        }
開發者ID:JamborYao,項目名稱:UwpStart,代碼行數:7,代碼來源:CopyPast.xaml.cs

示例9: SetText

 public void SetText(string text)
 {
     var dp = new DataPackage();
     dp.SetText(text);
     Clipboard.SetContent(dp);
     UWPUtilities.GiveStatusBarFeedback("Copied to clipboard...");
 }
開發者ID:Mordonus,項目名稱:MALClient,代碼行數:7,代碼來源:ClipboardProvider.cs

示例10: CopyButtonTapped

 private void CopyButtonTapped(object sender, TappedRoutedEventArgs e)
 {
     var dataPackage = new DataPackage();
     dataPackage.SetText(this.tbCurrent.Text);
     Clipboard.SetContent(dataPackage);
     this.tbCopyed.Visibility = Visibility.Visible;
 }
開發者ID:feong,項目名稱:CC,代碼行數:7,代碼來源:SettingsPage.xaml.cs

示例11: TextBlock_Tapped1

 private static void TextBlock_Tapped1(object sender, TappedRoutedEventArgs e)
 {
     // Use this to copy field value to Clipboard, if using TextBlock
     var textb = sender as TextBlock;
     var dataPackage = new DataPackage();
     dataPackage.SetText(textb.Text);
     Clipboard.SetContent(dataPackage);
 }
開發者ID:agangal,項目名稱:EmojiTable,代碼行數:8,代碼來源:Library.cs

示例12: Button_Click_1

        private void Button_Click_1(object sender, RoutedEventArgs e)
        {
            DataPackage dataPackage = new DataPackage();
            dataPackage.RequestedOperation = DataPackageOperation.Copy;
            dataPackage.SetText("クリップボードに文字列を渡します!!");

            Clipboard.SetContent(dataPackage);
        }
開發者ID:coelacanth77,項目名稱:ClipboardSample,代碼行數:8,代碼來源:MainPage.xaml.cs

示例13: ContentDialog_PrimaryButtonClick

 private void ContentDialog_PrimaryButtonClick(ContentDialog sender, ContentDialogButtonClickEventArgs args)
 {
     var dataPackage = new DataPackage();
     dataPackage.SetText(Result);
     Clipboard.SetContent(dataPackage);
     MessageHelper.ShowToastNotification("StoreLogo.png", "已複製到粘貼板!", NotificationAudioNames.Default);
     args.Cancel = true;
 }
開發者ID:zx648383079,項目名稱:WPF-Regex,代碼行數:8,代碼來源:ResultDialog.xaml.cs

示例14: Copybutton_Tapped

		private void Copybutton_Tapped(object sender, TappedRoutedEventArgs e)
		{
			var dataPackage = new DataPackage();			
			string plainText = HtmlUtilities.ConvertToText(output.Text);
			dataPackage.SetText(plainText);

			Windows.ApplicationModel.DataTransfer.Clipboard.SetContent(dataPackage);
        }
開發者ID:extrememedicine,項目名稱:smseys,代碼行數:8,代碼來源:MainPage.xaml.cs

示例15: CopyToClipBoard

        private void CopyToClipBoard(object sender, RoutedEventArgs e)
        {
            var content = new DataPackage();
            content.SetUri(new Uri(textboxLink.Text));
            content.SetText(textboxLink.Text);

            Clipboard.SetContent(content);
        }
開發者ID:tallichet,項目名稱:ShareIt,代碼行數:8,代碼來源:ShareTarget.xaml.cs


注:本文中的Windows.ApplicationModel.DataTransfer.DataPackage.SetText方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。