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


C# DataPackage.SetWebLink方法代碼示例

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


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

示例1: OnDataRequested

        private void OnDataRequested(DataTransferManager sender, DataRequestedEventArgs e)
        {
            _requestData = e.Request.Data;

            _requestData.Properties.Title = _title;
            _requestData.Properties.Description = _description;
            _requestData.SetWebLink(new Uri(_imageUrl));
        }
開發者ID:oferhaze,項目名稱:Ferrari,代碼行數:8,代碼來源:SharingService.cs

示例2: HandleShareRequested

		partial void HandleShareRequested(string shareLink)
		{
			var dataPackage = new DataPackage();
			dataPackage.SetText(shareLink);
            dataPackage.SetWebLink(new Uri(shareLink));
			Clipboard.SetContent(dataPackage);

			var notificationService = SimpleIoc.Default.GetInstance<NotificationService>();
			notificationService.ShowToast("File shared", "A link has been copied to the clipboard", "Assets/Logo.scale-100.png");

			this.Complete();
		}
開發者ID:viciousviper,項目名稱:pCloud.NET,代碼行數:12,代碼來源:ShareViewModel.cs

示例3: CopyLink

        private async Task CopyLink(File file)
        {
            this.IsLoading = true;
            try
            {
                var link = await this.client.GetPublicFileLinkAsync(file.FileId, null);
                var dataPackage = new DataPackage();
                dataPackage.SetText(link);
                dataPackage.SetWebLink(new Uri(link));
                Clipboard.SetContent(dataPackage);

                var notificationService = SimpleIoc.Default.GetInstance<NotificationService>();
                notificationService.ShowToast("File(s) shared", "A link has been copied to the clipboard", "Assets/Logo.scale-100.png");
            }
            finally
            {
                this.IsLoading = false;
            }
        }
開發者ID:viciousviper,項目名稱:pCloud.NET,代碼行數:19,代碼來源:FolderViewModel.cs

示例4: dataTransferManager_DataRequested

 async   void dataTransferManager_DataRequested(DataTransferManager sender, DataRequestedEventArgs args)
    {
        DataRequest request = args.Request;
        //We are going to use an async API to talk to the webview, so get a deferral for the results
        DataRequestDeferral deferral = args.Request.GetDeferral();
        DataPackage dp = await homewebview.CaptureSelectedContentToDataPackageAsync();
        if (dp != null && dp.GetView().AvailableFormats.Count >0)
        { // Webview has a selection, so we'll share its data package
            dp.Properties.Title = "來自多彩瀏覽器的分享";
            request.Data = dp;
        }
        else { 
            // No selection, so we'll share the url of the webview
            DataPackage myData = new DataPackage();
            myData.SetWebLink(homewebview.Source);
            myData.Properties.Title = "來自多彩瀏覽器的分享";
            myData.Properties.Description = homewebview.Source.ToString();
            request.Data = myData; }
        deferral.Complete();
    }
開發者ID:gisdaodao,項目名稱:ii,代碼行數:20,代碼來源:HomePage.xaml.cs

示例5: SetWebLink

        /// <summary>
        /// Sets the current web link content that is stored in the clipboard.
        /// </summary>
        /// <param name="content">The web link content that is stored in the clipboard.</param>
        public virtual void SetWebLink(Uri content)
        {
            var package = new DataPackage();

            package.SetWebLink(content);

            Clipboard.SetContent(package);
        }
開發者ID:Cimbalino,項目名稱:Cimbalino-Toolkit,代碼行數:12,代碼來源:ClipboardService.cs

示例6: DataTransferManager_DataRequested

        /// <summary>
        /// Raised when the user initiates a Share operation.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="args"></param>
        async void DataTransferManager_DataRequested(DataTransferManager sender, DataRequestedEventArgs args)
        {
            DataRequest request = args.Request;
            // We are going to use an async API to talk to the webview, so get a deferral to give
            // us time to generate the results.
            DataRequestDeferral deferral = request.GetDeferral();
            DataPackage dp = await WebViewControl.CaptureSelectedContentToDataPackageAsync();

            // Determine whether there was any selected content.
            bool hasSelection = false;
            try
            {
                hasSelection = (dp != null) && (dp.GetView().AvailableFormats.Count > 0);
            }
            catch (Exception ex)
            {
                switch (ex.HResult)
                {
                    case unchecked((int)0x80070490):
                        // Mobile does not generate a data package with AvailableFormats
                        // and results in an exception. Sorry. Handle the case by acting as
                        // if we had no selected content.
                        hasSelection = false;
                        break;

                    default:
                        // All other exceptions are unexpected. Let them propagate.
                        throw;
                }
            }

            if (hasSelection)
            {
                // Webview has a selection, so we'll share its data package.
                dp.Properties.Title = "WebView sample selected content";
            }
            else
            {
                // No selection, so we'll share the url of the webview.
                dp = new DataPackage();
                dp.SetWebLink(WebViewControl.Source);
                dp.Properties.Title = "WebView sample page";
            }
            dp.Properties.Description = WebViewControl.Source.ToString();
            request.Data = dp;

            deferral.Complete();
        }
開發者ID:AJ-COOL,項目名稱:Windows-universal-samples,代碼行數:53,代碼來源:Scenario7_Share.xaml.cs

示例7: FillPackage

		private static void FillPackage(StorageFile[] files, DataPackage package, object subShareItem)
		{
			if (subShareItem != null)
			{
				switch (subShareItem.GetType().Name)
				{
					case nameof(TextShareItem):
						{
							package.SetText((subShareItem as TextShareItem).Text);
						}
						break;
					case nameof(ApplicationLinkShareItem):
						{
							var sitm = subShareItem as ApplicationLinkShareItem;
							package.SetApplicationLink(sitm.ApplicationLink);
						}
						break;

					case nameof(DelayRenderedImageShareItem):
						{
							var sitm = subShareItem as DelayRenderedImageShareItem;
							package.SetBitmap(RandomAccessStreamReference.CreateFromStream(sitm.SelectedImage.GetRandowmAccessStream()));
						}
						break;

					case nameof(FilesShareItem):
						{
							StorageFile[] resultArray = files;
							package.SetStorageItems(resultArray);
						}
						break;
					case nameof(HtmlShareItem):
						{
							var sitm = subShareItem as HtmlShareItem;

							var fmt = HtmlFormatHelper.CreateHtmlFormat(sitm.HtmlFragment);
							package.SetHtmlFormat(fmt);
							package.SetText(sitm.HtmlFragment);

						}
						break;
					case nameof(WebLinkShareItem):
						{
							var sitm = subShareItem as WebLinkShareItem;
							package.SetWebLink(sitm.WebLink);
							package.SetText(sitm.WebLink?.ToString());

						}
						break;

					default:
						break;
				}

			}
		}
開發者ID:waynebaby,項目名稱:GreaterShareUWP,代碼行數:56,代碼來源:DefaultShareService.cs

示例8: CopyLink

 /// <summary>
 /// Копировать ссылку в клипборд.
 /// </summary>
 public async void CopyLink()
 {
     try
     {
         var webLink = link.GetWebLink();
         if (webLink != null)
         {
             var dp = new DataPackage();
             dp.SetText(webLink.ToString());
             dp.SetWebLink(webLink);
             Clipboard.SetContent(dp);
             Clipboard.Flush();
         }
     }
     catch (Exception ex)
     {
         await AppHelpers.ShowError(ex);
     }
 }
開發者ID:Opiumtm,項目名稱:DvachBrowser3,代碼行數:22,代碼來源:FavoriteMainTileViewModel.cs

示例9: CopyMediaLinkFlyoutItem_OnClick

 private async void CopyMediaLinkFlyoutItem_OnClick(object sender, RoutedEventArgs e)
 {
     try
     {
         var f = sender as FrameworkElement;
         var t = f?.Tag as IPostMediaFileViewModel;
         if (t?.WebLink != null)
         {
             var dp = new DataPackage();
             dp.SetText(t.WebLink);
             dp.SetWebLink(new Uri(t.WebLink, UriKind.Absolute));
             Clipboard.SetContent(dp);
             Clipboard.Flush();
         }
     }
     catch (Exception ex)
     {
         await AppHelpers.ShowError(ex);
     }
 }
開發者ID:Opiumtm,項目名稱:DvachBrowser3,代碼行數:20,代碼來源:PostView.xaml.cs

示例10: CopyLinkFlyoutItem_OnClick

 private async void CopyLinkFlyoutItem_OnClick(object sender, RoutedEventArgs e)
 {
     try
     {
         var f = sender as FrameworkElement;
         var t = f?.Tag as IPostViewModel;
         if (t?.Link != null)
         {
             var uri = t.Link.GetWebLink();
             if (uri != null)
             {
                 var dp = new DataPackage();
                 dp.SetText(uri.ToString());
                 dp.SetWebLink(uri);
                 Clipboard.SetContent(dp);
                 Clipboard.Flush();
             }
         }
     }
     catch (Exception ex)
     {
         await AppHelpers.ShowError(ex);
     }
 }
開發者ID:Opiumtm,項目名稱:DvachBrowser3,代碼行數:24,代碼來源:PostCollectionView.xaml.cs


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