本文整理汇总了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));
}
示例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);
}
示例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;
}
}
}