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