本文整理汇总了C#中Windows.ApplicationModel.DataTransfer.DataRequestedEventArgs类的典型用法代码示例。如果您正苦于以下问题:C# DataRequestedEventArgs类的具体用法?C# DataRequestedEventArgs怎么用?C# DataRequestedEventArgs使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
DataRequestedEventArgs类属于Windows.ApplicationModel.DataTransfer命名空间,在下文中一共展示了DataRequestedEventArgs类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: OnDataRequested
private void OnDataRequested(DataTransferManager sender, DataRequestedEventArgs e)
{
// Get the user's selection from the WebView.
DataPackage requestData = ShareWebView.DataTransferPackage;
DataPackageView dataPackageView = requestData.GetView();
if ((dataPackageView != null) && (dataPackageView.AvailableFormats.Count > 0))
{
string dataPackageTitle = TitleInputBox.Text;
// The title is required.
if (!String.IsNullOrEmpty(dataPackageTitle))
{
requestData.Properties.Title = dataPackageTitle;
// The description is optional.
string dataPackageDescription = DescriptionInputBox.Text;
if (dataPackageDescription != null)
{
requestData.Properties.Description = dataPackageDescription;
}
e.Request.Data = requestData;
}
else
{
e.Request.FailWithDisplayText(MainPage.MissingTitleError);
}
}
else
{
e.Request.FailWithDisplayText("Make a selection in the HTML fragment and try again.");
}
}
示例2: ShareTextHandler
private void ShareTextHandler(DataTransferManager sender, DataRequestedEventArgs e)
{
try
{
DataRequest request = e.Request;
// The Title is mandatory
#if WINDOWS_UWP
request.Data.Properties.Title = title ?? Windows.ApplicationModel.Package.Current.DisplayName;
#elif WINDOWS_APP
request.Data.Properties.Title = title ?? Windows.ApplicationModel.Package.Current.DisplayName;
#else
request.Data.Properties.Title = title ?? string.Empty;
#endif
if (!string.IsNullOrWhiteSpace(url))
{
request.Data.SetWebLink(new Uri(url));
}
request.Data.SetText(text ?? string.Empty);
}
catch(Exception ex)
{
Debug.WriteLine("Unable to share text: " + ex);
}
}
示例3: OnDataRequested
private void OnDataRequested(DataTransferManager sender, DataRequestedEventArgs args)
{
var loader = new Windows.ApplicationModel.Resources.ResourceLoader();
args.Request.Data.SetText(
$"{loader.GetString("SendMeFriendRequest/Text")} {_link} {Environment.NewLine} {loader.GetString("SentFromPlayStationApp/Text")}");
args.Request.Data.Properties.Title = loader.GetString("InviteFriendsToPsn/Text");
}
示例4: OnDataRequested
private async void OnDataRequested(DataTransferManager sender, DataRequestedEventArgs args)
{
var vm = ((DashboardViewModel) DataContext);
if ( vm.SelectedItem == null)
{
args.Request.FailWithDisplayText("You have not selected an item to share");
}
else
{
var deferral = args.Request.GetDeferral();
var dataPackage = args.Request.Data;
var propertySet = dataPackage.Properties;
propertySet.Title = vm.SelectedItem.Name;
propertySet.Description = vm.SelectedItem.ShortDescription;
//ShareText(dataPackage, vm.SelectedItem.Name);
//ShareUrl(dataPackage, "http://www.espn.com");
await ShareFileAsync(vm, dataPackage, propertySet);
deferral.Complete();
}
}
示例5: ShareStorageItemsHandler
private async void ShareStorageItemsHandler(DataTransferManager sender,
DataRequestedEventArgs e)
{
var request = e.Request;
request.Data.Properties.Title = AppResourcesHelper.Get("Export_FileTitle");
request.Data.Properties.Description = ApplicationResourcesHelper.Get("CATROBAT_URL");
var deferral = request.GetDeferral();
try
{
var rootFolder = ApplicationData.Current.LocalFolder;
var fileToShare = await rootFolder.GetFileAsync(_pathToShareFile);
var storageItems = new List<IStorageItem> { fileToShare };
request.Data.SetStorageItems(storageItems);
}
catch
{
if (Debugger.IsAttached)
Debugger.Break();
}
finally
{
deferral.Complete();
}
}
示例6: ShareLinkHandler
private void ShareLinkHandler(DataTransferManager sender, DataRequestedEventArgs e)
{
DataRequest request = e.Request;
request.Data.Properties.Title = "Title";
request.Data.Properties.Description = "Description";
request.Data.SetWebLink(new Uri(""+ Windows.ApplicationModel.Store.CurrentApp.LinkUri));
}
示例7: BlankPage_DataRequested
void BlankPage_DataRequested(DataTransferManager sender, DataRequestedEventArgs args)
{
var request = args.Request;
request.Data.Properties.Title = App.ViewModel.SelectedDocument.GetDisplayName();
request.Data.Properties.Description = string.Format("Created {0}", App.ViewModel.SelectedDocument.GetCreatedDate().ToString("g"));
request.Data.SetText(_GetCurrentDocumentText());
}
示例8: DataRequested
private void DataRequested(DataTransferManager sender, DataRequestedEventArgs e)
{
DataRequest request = e.Request;
request.Data.Properties.Title = "كلام جرايد";
request.Data.SetText("يقوم هذا البرنامج بتجميع الأخبار من مصادر متنوعة و تقسيمه حسب نوعه ويقوم بعرض العناوين الأخبار فى الصفحة الرئيسية و يقوم ايضا بعرض الخبر كامل من مصدره" + "\n" + (new Uri("ms-windows-store:navigate?appid=" + CurrentApp.AppId)).ToString());
}
示例9: dataTransferManager_DataRequested
private void dataTransferManager_DataRequested(DataTransferManager sender, DataRequestedEventArgs args)
{
if (OnShareRequested != null)
{
OnShareRequested(args.Request.Data);
}
}
示例10: PageExplorerDataRequested
private void PageExplorerDataRequested(DataTransferManager sender,
DataRequestedEventArgs args)
{
DataPackage data = args.Request.Data;
DataRequestDeferral waiter = args.Request.GetDeferral();
try
{
List<IStorageItem> files = new List<IStorageItem>();
int index = 0;
foreach (var item in itemGridView.SelectedItems)
{
ExplorerItem explorerItem = (ExplorerItem)item;
if (explorerItem != null)
{
if (index == 0)
{
data.Properties.Title = explorerItem.Name;
RandomAccessStreamReference image = RandomAccessStreamReference.CreateFromFile(explorerItem.StorageFile);
data.Properties.Thumbnail = image;
data.SetBitmap(image);
}
files.Add(explorerItem.StorageFile);
}
index++;
}
data.SetStorageItems(files);
data.SetText("\n");
}
finally
{
waiter.Complete();
}
}
示例11: DataTransferManager_DataRequested
private void DataTransferManager_DataRequested(DataTransferManager sender, DataRequestedEventArgs args)
{
DataRequest request = args.Request;
var currentImage = dataContext.AlbumItem.AlbumImages[dataContext.SelectedIndex];
request.Data.Properties.Title = currentImage.Title ?? dataContext.AlbumItem.Title;
request.Data.SetWebLink(new Uri(currentImage.Link));
}
示例12: ShareTextHandler
/// <summary>
/// This is the text handler for the sharing purposes.
/// </summary>
/// <param name="sender">Object Sender is a parameter called Sender that contains a reference to the control/object that raised the event.</param>
/// <param name="e">DataRequestedEventArgs e is a parameter called e that contains the event data, see the DataRequestedEventArgs MSDN page for more information.</param>
public static void ShareTextHandler(DataTransferManager sender, DataRequestedEventArgs e)
{
DataRequest request = e.Request;
request.Data.Properties.Title = "BuildmLearn Store";
request.Data.Properties.Description = "BuildmLearn Store Share";
request.Data.SetText("Share Text");
}
示例13: DataTransferManager_DataRequested
// *** Private Methods ***
private async void DataTransferManager_DataRequested(DataTransferManager sender, DataRequestedEventArgs args)
{
DataRequestDeferral deferral = args.Request.GetDeferral();
IShareRequest shareRequest = new ShareRequest(args.Request);
await ShareRequested(shareRequest);
deferral.Complete();
}
示例14: DataRequested
protected override void DataRequested(DataTransferManager sender, DataRequestedEventArgs args)
{
VideoItem vi = (this.DataContext as VideoItem);
args.Request.Data.Properties.Title = vi.Name;
args.Request.Data.Properties.Description = vi.Description;
args.Request.Data.SetUri(vi.KhanPath);
}
示例15: DataTransferManager_DataRequested
void DataTransferManager_DataRequested(DataTransferManager sender, DataRequestedEventArgs e)
{
if (_dataRequested != null)
{
_dataRequested((DataTransferManager)sender, new SettableDataRequestedEventArgs(e));
}
}