blob: 2e1a907a31a985c37f75247d7236a99d6d8d864b (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
|
using System;
using System.Threading;
using System.Threading.Tasks;
using Windows.UI.Xaml.Media.Imaging;
#if WINDOWS_UWP
namespace Xamarin.Forms.Platform.UWP
#else
namespace Xamarin.Forms.Platform.WinRT
#endif
{
public sealed class FileImageSourceHandler : IImageSourceHandler
{
public Task<Windows.UI.Xaml.Media.ImageSource> LoadImageAsync(ImageSource imagesource, CancellationToken cancellationToken = new CancellationToken())
{
Windows.UI.Xaml.Media.ImageSource image = null;
var filesource = imagesource as FileImageSource;
if (filesource != null)
{
string file = filesource.File;
image = new BitmapImage(new Uri("ms-appx:///" + file));
}
return Task.FromResult(image);
}
}
}
|