public async Task SetupShareDataAsync(ShareOperation share)
{
// store the share operation - we need to do this to hold a
// reference otherwise the sharing subsystem will assume
// that we've finished...
this.ShareOperation = share;
// get the properties out...
var data = share.Data;
var props = data.Properties;
this.Title = props.Title;
this.Description = props.Description;
// now the text...
if(data.Contains(StandardDataFormats.Text))
this.SharedText = await data.GetTextAsync();
// do we have an image? if so, load it...
if (data.Contains(StandardDataFormats.StorageItems) || data.Contains(StandardDataFormats.Bitmap))
{
IRandomAccessStreamReference reference = null;
// load the first one...
if (data.Contains(StandardDataFormats.StorageItems))
{
var file = (IStorageFile)(await data.GetStorageItemsAsync()).FirstOrDefault();
reference = RandomAccessStreamReference.CreateFromFile(file);
}
else
reference = await data.GetBitmapAsync();
// load it into an image...
var image = new BitmapImage();
using(var stream = await reference.OpenReadAsync())
image.SetSource(stream);
// set...
this.SharedImage = image;
this.ShowImage = true;
}
// tell the OS that we have the data...
share.ReportDataRetrieved();
}
}