本文整理汇总了C#中Windows.ApplicationModel.DataTransfer.DataPackage类的典型用法代码示例。如果您正苦于以下问题:C# DataPackage类的具体用法?C# DataPackage怎么用?C# DataPackage使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
DataPackage类属于Windows.ApplicationModel.DataTransfer命名空间,在下文中一共展示了DataPackage类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: Transfer_DataRequested
private void Transfer_DataRequested(DataTransferManager sender, DataRequestedEventArgs args)
{
if (!Equals(null, VM))
{
DataPackage dp = new DataPackage();
switch (VM.GetType().Name)
{
case "PictureViewModel":
dp.Properties.Title = "分享图片";
dp.SetText( $"一张图片,千言万语[来自ONE-UWP的分享]:{(VM as PictureViewModel).Picture.WebLk}");
break;
case "ArticleViewModel":
dp.Properties.Title = "分享文章";
dp.SetText($"世间风情,字里行间[来自ONE-UWP的分享]:{(VM as ArticleViewModel).Article.WebLk}");
break;
case "QuestionViewModel":
dp.Properties.Title = "分享问题";
dp.SetText($"每天一问,有问必答[来自ONE-UWP的分享]:{(VM as QuestionViewModel).Question.WebLk}");
break;
case "ThingViewModel":
dp.Properties.Title = "分享东西";
dp.SetText($"友好世界,有好东西[来自ONE-UWP的分享]:{(VM as ThingViewModel).Thing.Wu}");
break;
}
args.Request.Data = dp;
}
else
{
return;
}
}
开发者ID:hippieZhou,项目名称:OneUWP,代码行数:31,代码来源:ShareManager.cs
示例2: OnNavigatedTo
/// <summary>
/// Invoked when this page is about to be displayed in a Frame.
/// </summary>
/// <param name="e">Event data that describes how this page was reached. The Parameter
/// property is typically used to configure the page.</param>
protected override void OnNavigatedTo(NavigationEventArgs e)
{
XNamespace p_ns = "http://schemas.microsoft.com/winfx/2006/xaml/presentation";
XNamespace xaml_ns = "http://schemas.microsoft.com/winfx/2006/xaml";
var doc = XDocument.Load(@"Common\StandardStyles.xaml");
foreach (var style in doc.Descendants(p_ns + "Style"))
{
var key = style.Attribute(xaml_ns + "Key");
if (key != null && key.Value != null)
{
var basedOn = style.Attribute("BasedOn");
if (basedOn != null && basedOn.Value == @"{StaticResource AppBarButtonStyle}")
{
var button = new Button();
button.Style = App.Current.Resources[key.Value] as Style;
ToolTipService.SetToolTip(button, key.Value);
button.Click += (sender, args) =>
{
string styleName = ToolTipService.GetToolTip(sender as Button) as string;
DataPackage clipboardData = new DataPackage();
clipboardData.SetText(styleName);
Clipboard.SetContent(clipboardData);
};
AppBarButtonListView.Items.Add(button);
}
}
}
}
开发者ID:pixeltucker,项目名称:MetroAppBarSample,代码行数:34,代码来源:MainPage.xaml.cs
示例3: CopyButtonTapped
private void CopyButtonTapped(object sender, TappedRoutedEventArgs e)
{
var dataPackage = new DataPackage();
dataPackage.SetText(this.tbCurrent.Text);
Clipboard.SetContent(dataPackage);
this.tbCopyed.Visibility = Visibility.Visible;
}
开发者ID:feong,项目名称:CC,代码行数:7,代码来源:SettingsPage.xaml.cs
示例4: Copy_Click
private void Copy_Click(object sender, RoutedEventArgs e)
{
DataPackage data = new DataPackage();
data.SetText(tbInput.Text);
Clipboard.SetContent(data);
}
开发者ID:JamborYao,项目名称:UwpStart,代码行数:7,代码来源:CopyPast.xaml.cs
示例5: CopyButton_Click
void CopyButton_Click(object sender, RoutedEventArgs e)
{
OutputText.Text = "";
OutputResourceMapKeys.Text = "";
OutputHtml.NavigateToString("<HTML></HTML>");
// Set the content to DataPackage as html format
string htmlFormat = HtmlFormatHelper.CreateHtmlFormat(this.htmlFragment);
var dataPackage = new DataPackage();
dataPackage.SetHtmlFormat(htmlFormat);
// Set the content to DataPackage as (plain) text format
string plainText = HtmlUtilities.ConvertToText(this.htmlFragment);
dataPackage.SetText(plainText);
// Populate resourceMap with StreamReference objects corresponding to local image files embedded in HTML
var imgUri = new Uri(imgSrc);
var imgRef = RandomAccessStreamReference.CreateFromUri(imgUri);
dataPackage.ResourceMap[imgSrc] = imgRef;
try
{
// Set the DataPackage to clipboard.
Windows.ApplicationModel.DataTransfer.Clipboard.SetContent(dataPackage);
OutputText.Text = "Text and HTML formats have been copied to clipboard. ";
}
catch (Exception ex)
{
// Copying data to Clipboard can potentially fail - for example, if another application is holding Clipboard open
rootPage.NotifyUser("Error copying content to Clipboard: " + ex.Message + ". Try again", NotifyType.ErrorMessage);
}
}
开发者ID:COMIsLove,项目名称:Windows-universal-samples,代码行数:32,代码来源:CopyText.xaml.cs
示例6: Grid_DoubleTapped
private async void Grid_DoubleTapped(object sender, DoubleTappedRoutedEventArgs e)
{
Grid grid = (Grid)sender;
Records.Items items = (Records.Items)grid.DataContext;
String Data = String.Empty;
ResourceLoader resourceLoader = new ResourceLoader();
Data += String.Format(resourceLoader.GetString("pageResult_Assignment") + Environment.NewLine, items.Oid);
Data += String.Format(resourceLoader.GetString("pageResult_Registry") + Environment.NewLine, items.RegistryID);
Data += String.Format(resourceLoader.GetString("pageResult_OrganizationName") + Environment.NewLine, items.Name);
Data += String.Format(resourceLoader.GetString("pageResult_OrganizationAddress") + Environment.NewLine, items.Address);
if ( (items.Protocol != String.Empty) && (items.Protocol != null))
{
Data += String.Format(resourceLoader.GetString("pageResult_Protocol") + Environment.NewLine, items.Protocol);
}
DataPackage dataPackage = new DataPackage();
dataPackage.SetText(Data);
Clipboard.SetContent(dataPackage);
MessageDialog msgbox = new MessageDialog(Data, resourceLoader.GetString("pageResult_DialogCopied"));
msgbox.Commands.Clear();
msgbox.Commands.Add(new UICommand { Label = resourceLoader.GetString("pageResult_DialogClose"), Id = 0 });
var res = await msgbox.ShowAsync();
}
开发者ID:EddyBeaupre,项目名称:searchIEEE,代码行数:29,代码来源:pageResults.xaml.cs
示例7: CopyLink
private void CopyLink()
{
DataPackage dataPackage = new DataPackage();
dataPackage.RequestedOperation = DataPackageOperation.Copy;
dataPackage.SetText(GetLinkToShare());
Clipboard.SetContent(dataPackage);
}
开发者ID:nilsbenson,项目名称:MonocleGiraffe,代码行数:7,代码来源:AlbumPage.xaml.cs
示例8: SetText
public void SetText(string text)
{
var dp = new DataPackage();
dp.SetText(text);
Clipboard.SetContent(dp);
UWPUtilities.GiveStatusBarFeedback("Copied to clipboard...");
}
开发者ID:Mordonus,项目名称:MALClient,代码行数:7,代码来源:ClipboardProvider.cs
示例9: Copy
public void Copy()
{
try
{
if (_share.Data.Properties.ApplicationName != Constants.ApplicationName)
{
_share.ReportSubmittedBackgroundTask();
var content = new DataPackage();
_values.CopyTo(content);
Windows.ApplicationModel.DataTransfer.Clipboard.SetContent(content);
Windows.ApplicationModel.DataTransfer.Clipboard.Flush();
Windows.ApplicationModel.DataTransfer.Clipboard.ContentChanged += OnClipboardContentChanged;
_share.DismissUI();
}
else
{
_share.ReportCompleted();
}
}
catch (Exception ex)
{
_share.ReportError(ex.Message);
}
}
开发者ID:justinmchase,项目名称:Clipboard,代码行数:27,代码来源:ShareTargetViewModel.cs
示例10: CopyButton_Click
async void CopyButton_Click(object sender, RoutedEventArgs e)
{
OutputText.Text = "Storage Items: ";
var filePicker = new FileOpenPicker
{
ViewMode = PickerViewMode.List,
FileTypeFilter = { "*" }
};
var storageItems = await filePicker.PickMultipleFilesAsync();
if (storageItems.Count > 0)
{
OutputText.Text += storageItems.Count + " file(s) are copied into clipboard";
var dataPackage = new DataPackage();
dataPackage.SetStorageItems(storageItems);
// Request a copy operation from targets that support different file operations, like File Explorer
dataPackage.RequestedOperation = DataPackageOperation.Copy;
try
{
Windows.ApplicationModel.DataTransfer.Clipboard.SetContent(dataPackage);
}
catch (Exception ex)
{
// Copying data to Clipboard can potentially fail - for example, if another application is holding Clipboard open
rootPage.NotifyUser("Error copying content to Clipboard: " + ex.Message + ". Try again", NotifyType.ErrorMessage);
}
}
else
{
OutputText.Text += "No file was selected.";
}
}
开发者ID:mbin,项目名称:Win81App,代码行数:33,代码来源:CopyFile.xaml.cs
示例11: Clipboard_Click
private void Clipboard_Click(object sender, RoutedEventArgs e)
{
var dataPackage = new DataPackage();
dataPackage.SetText(Match.AudioUrl);
Clipboard.SetContent(dataPackage);
}
开发者ID:haroldma,项目名称:Audiotica,代码行数:7,代码来源:MatchViewer.xaml.cs
示例12: Button_Click_1
private void Button_Click_1(object sender, RoutedEventArgs e)
{
DataPackage dataPackage = new DataPackage();
dataPackage.RequestedOperation = DataPackageOperation.Copy;
dataPackage.SetText("クリップボードに文字列を渡します!!");
Clipboard.SetContent(dataPackage);
}
开发者ID:coelacanth77,项目名称:ClipboardSample,代码行数:8,代码来源:MainPage.xaml.cs
示例13: ContentDialog_PrimaryButtonClick
private void ContentDialog_PrimaryButtonClick(ContentDialog sender, ContentDialogButtonClickEventArgs args)
{
var dataPackage = new DataPackage();
dataPackage.SetText(Result);
Clipboard.SetContent(dataPackage);
MessageHelper.ShowToastNotification("StoreLogo.png", "已复制到粘贴板!", NotificationAudioNames.Default);
args.Cancel = true;
}
开发者ID:zx648383079,项目名称:WPF-Regex,代码行数:8,代码来源:ResultDialog.xaml.cs
示例14: Copybutton_Tapped
private void Copybutton_Tapped(object sender, TappedRoutedEventArgs e)
{
var dataPackage = new DataPackage();
string plainText = HtmlUtilities.ConvertToText(output.Text);
dataPackage.SetText(plainText);
Windows.ApplicationModel.DataTransfer.Clipboard.SetContent(dataPackage);
}
开发者ID:extrememedicine,项目名称:smseys,代码行数:8,代码来源:MainPage.xaml.cs
示例15: CopyToClipBoard
private void CopyToClipBoard(object sender, RoutedEventArgs e)
{
var content = new DataPackage();
content.SetUri(new Uri(textboxLink.Text));
content.SetText(textboxLink.Text);
Clipboard.SetContent(content);
}
开发者ID:tallichet,项目名称:ShareIt,代码行数:8,代码来源:ShareTarget.xaml.cs
示例16: CopyImage_Click
private void CopyImage_Click(object sender, RoutedEventArgs e)
{
var data = new DataPackage();
var bi = FirstImage.Source as BitmapImage;
var uri = bi.UriSource;
data.SetBitmap(RandomAccessStreamReference.CreateFromUri(uri));
Clipboard.SetContent(data);
}
开发者ID:caschw,项目名称:WelcomingWindows10,代码行数:8,代码来源:MainPage.xaml.cs
示例17: TextBlock_Tapped1
private static void TextBlock_Tapped1(object sender, TappedRoutedEventArgs e)
{
// Use this to copy field value to Clipboard, if using TextBlock
var textb = sender as TextBlock;
var dataPackage = new DataPackage();
dataPackage.SetText(textb.Text);
Clipboard.SetContent(dataPackage);
}
开发者ID:agangal,项目名称:EmojiTable,代码行数:8,代码来源:Library.cs
示例18: Properties_Title_SettingValueThrowsException
public void Properties_Title_SettingValueThrowsException()
{
DataPackage dataPackage = new DataPackage();
SharePackageView sharePackage = new SharePackageView(dataPackage.GetView());
var e = Assert.Throws<InvalidOperationException>(() => sharePackage.Properties.Description = "Test Value");
Assert.Equal("Cannot modify share properties as a share target.", e.Message);
}
开发者ID:deepakpal9046,项目名称:Okra.Core,代码行数:9,代码来源:SharePackageViewFixture.cs
示例19: ShareByCopyUriAppBarButton_Tapped
/// <summary>
/// 复制链接
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private async void ShareByCopyUriAppBarButton_Tapped(object sender, TappedRoutedEventArgs e)
{
DataPackage dataPackage = new DataPackage();
dataPackage.SetText(this._url);
Clipboard.SetContent(dataPackage);
MessageDialog messageDialog = new MessageDialog("复制成功");
IUICommand uiCommand = await messageDialog.ShowAsync();
this.Hide();
}
开发者ID:GuojieLin,项目名称:CnBlogs,代码行数:14,代码来源:ShareDialog.xaml.cs
示例20: CharButton_Click
private void CharButton_Click(object sender, RoutedEventArgs e)
{
if (FontChar != null)
{
var dataPackage = new DataPackage();
dataPackage.SetText(FontChar.Char.ToString());
Clipboard.SetContent(dataPackage);
}
}
开发者ID:WaltRitscher,项目名称:CharMap-Plus,代码行数:9,代码来源:CharDetail.xaml.cs
注:本文中的Windows.ApplicationModel.DataTransfer.DataPackage类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论