当前位置: 首页>>代码示例>>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;未经允许,请勿转载。