本文整理汇总了C#中Windows.ApplicationModel.DataTransfer.DataPackage.SetBitmap方法的典型用法代码示例。如果您正苦于以下问题:C# DataPackage.SetBitmap方法的具体用法?C# DataPackage.SetBitmap怎么用?C# DataPackage.SetBitmap使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Windows.ApplicationModel.DataTransfer.DataPackage
的用法示例。
在下文中一共展示了DataPackage.SetBitmap方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: 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);
}
示例2: SetBitmap
/// <summary>
/// Sets the current bitmap content that is stored in the clipboard.
/// </summary>
/// <param name="content">The bitmap content that is stored in the clipboard.</param>
public virtual void SetBitmap(Stream content)
{
var package = new DataPackage();
var random = content.AsRandomAccessStream();
var reference = RandomAccessStreamReference.CreateFromStream(random);
package.SetBitmap(reference);
}
示例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;
}
}
}
示例4: GetShareContent
private bool GetShareContent(DataRequest request)
{
bool succeeded = false;
if (this.flipView.SelectedItem != null)
{
var item = (Item)this.flipView.SelectedItem;
// string customData = @"{
// ""type"" : ""http://schema.org/Product"",
// ""properties"" :
// {
// ""url"" : ""#URL#"",
// ""description"" : ""#DESC#"",
// ""name"" : ""#NAME#"",
// ""model"" : ""#MODEL#"",
// ""price"" : ""#PRICE#""
// }
// }";
// customData = customData.Replace("#URL#", item.Uri).Replace("#DESC#", item.Descricao).Replace("#NAME#", item.Nome).Replace("#MODEL#", item.Categoria.Nome).Replace("#PRICE#", "R$ " + item.Valor);
requestData = request.Data;
//requestData.SetData("http://schema.org/Product", customData);
requestData.Properties.Title = item.Nome == null ? "Imagem compartilhada" : item.Nome;
requestData.Properties.Description = item.Descricao;
RandomAccessStreamReference imageStreamRef = null;
imageStreamRef = RandomAccessStreamReference.CreateFromUri(new Uri(_baseUri, item.ImageUrl));
if (imageStreamRef != null)
{
requestData.SetUri(new Uri(_baseUri, item.ImageUrl));
requestData.Properties.Title = string.Format("{0} - {1}", Win8CatalogApplication.Instance.Empresa.Nome, item.Nome);
requestData.Properties.Description = item.Descricao;
requestData.SetText(item.Descricao);
requestData.Properties.Thumbnail = imageStreamRef;
requestData.SetBitmap(imageStreamRef);
succeeded = true;
}
}
else
{
request.FailWithDisplayText("Selecione a imagem que deseja compartilhar e tente novamente.");
}
return succeeded;
}
示例5: CopyBitmap
async private void CopyBitmap(bool isDelayRendered)
{
var imagePicker = new FileOpenPicker
{
ViewMode = PickerViewMode.Thumbnail,
SuggestedStartLocation = PickerLocationId.PicturesLibrary,
FileTypeFilter = { ".jpg", ".png", ".bmp", ".gif", ".tif" }
};
var imageFile = await imagePicker.PickSingleFileAsync();
if (imageFile != null)
{
var dataPackage = new DataPackage();
// Use one click handler for two operations: regular copy and copy using delayed rendering
// Differentiate the case by the button name
if (isDelayRendered)
{
dataPackage.SetDataProvider(StandardDataFormats.Bitmap, request => OnDeferredImageRequestedHandler(request, imageFile));
OutputText.Text = "Image has been copied using delayed rendering";
}
else
{
dataPackage.SetBitmap(RandomAccessStreamReference.CreateFromFile(imageFile));
OutputText.Text = "Image has been copied";
}
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 image was selected.";
}
}
示例6: CopyToClipboard
/// <summary>
/// Скопировать в клипоборд.
/// </summary>
public async Task CopyToClipboard()
{
var dp = new DataPackage();
var storage = ServiceLocator.Current.GetServiceOrThrow<IStorageService>();
var f = await storage.FullSizeMediaFiles.GetFromMediaStorage(link);
dp.SetBitmap(RandomAccessStreamReference.CreateFromFile(f));
Clipboard.SetContent(dp);
Clipboard.Flush();
}
示例7: CopyCommands
private async void CopyCommands(object sender, TappedRoutedEventArgs e)
{
var dataPackage = new DataPackage();
dataPackage.RequestedOperation = DataPackageOperation.Copy;
var image = SelectedPod.CurrentImage;
var uri = await Q42.WinRT.Data.WebDataCache.GetLocalUriAsync(new Uri(image.URL));
var m = sender as MenuItem;
switch (m.Text)
{
case COPY_IMAGE:
dataPackage.SetBitmap(RandomAccessStreamReference.CreateFromUri(uri));
break;
case COPY_PLAIN:
dataPackage.SetText(image.Alt);
break;
case COPY_URL:
dataPackage.SetText(image.URL);
break;
}
Clipboard.SetContent(dataPackage);
}