1
0
forked from s434786/DINO_SCRUM
DINO_SCRUM/Magazyn_Client/Magazyn/Tools/CacheImage.cs
2019-01-23 23:10:44 +01:00

30 lines
853 B
C#

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Media.Imaging;
namespace Magazyn.Tools
{
class CacheImage
{
static Dictionary<Uri, BitmapImage> dic = new Dictionary<Uri, BitmapImage>();
static public BitmapImage GetImageSource( Uri url )
{
if (dic.Keys.Contains<Uri>(url)) return dic[url];
else
{
BitmapImage imageSource = new BitmapImage();
imageSource.BeginInit();
imageSource.UriSource = url;
imageSource.CacheOption = BitmapCacheOption.OnLoad;
imageSource.EndInit();
dic.Add(url, imageSource);
return imageSource;
}
}
}
}