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


C# DataPackage.SetApplicationLink方法代碼示例

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


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

示例1: Build

		public static void Build(SharedPoll poll, DataPackage dataPackage)
		{
			if (poll == null)
			{
				throw new ArgumentNullException("poll");
			}
			if (dataPackage == null)
			{
				throw new ArgumentNullException("dataPackage");
			}

			var url = string.Format("myvote://poll/{0}", poll.PollId);

			// Set as many data types as we can.
			dataPackage.Properties.Title = string.Format("MyVote Poll: {0}", poll.Question);

			// Add an HTML version.
			var htmlBuilder = new StringBuilder();
			htmlBuilder.AppendFormat("<h1>{0}</h1>", poll.Question);
			htmlBuilder.AppendFormat("<p>{0}</p>", poll.Description);
			htmlBuilder.Append("<ol>");
			foreach (var option in poll.Options)
			{
				htmlBuilder.AppendFormat("<li>{0}</li>", option);
			}
			htmlBuilder.Append("</ol>");
			htmlBuilder.AppendFormat("<p><a href='{0}'>Cast your vote!</a></p>", url);
			var html = HtmlFormatHelper.CreateHtmlFormat(htmlBuilder.ToString());
			dataPackage.SetHtmlFormat(html);

			// Add a text only version
			var text = string.Format("{0} Cast your vote! {1}", poll.Question, url);
			dataPackage.SetText(text);

			// Add a Uri
			dataPackage.SetApplicationLink(new Uri(url, UriKind.Absolute));
		}
開發者ID:JacobAtchley,項目名稱:MyVote,代碼行數:37,代碼來源:SharedPollPackageBuilder.cs

示例2: SetApplicationLink

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

            package.SetApplicationLink(content);

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

示例3: 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


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