summaryrefslogtreecommitdiff
path: root/Juick/Converters/UriToImageSourceConverter.cs
blob: 4c262549c8f9fd1445c29b65f11c8dd7257ea6f0 (plain) (blame)
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
30
31
using System;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Ink;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using System.Windows.Data;
using System.Globalization;
using Kawagoe.Storage;

namespace Juick.Converters
{
    public class UriToImageSourceConverter : IValueConverter
    {
        static ImageCache _cache = new PersistentImageCache("avatarsCache");
        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            Uri avatarUri = (Uri)value;
            return _cache.Get(avatarUri);
        }

        public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
        {
            return null;
        }
    }
}