Revision b449fa49
b/trunk/Pithos.Client.WPF/Shell/BalloonIconConverter.cs | ||
---|---|---|
1 |
using System; |
|
2 |
using System.Collections.Generic; |
|
3 |
using System.Globalization; |
|
4 |
using System.Windows.Data; |
|
5 |
using System.Windows.Media.Imaging; |
|
6 |
using Hardcodet.Wpf.TaskbarNotification; |
|
7 |
|
|
8 |
namespace Pithos.Client.WPF.Shell |
|
9 |
{ |
|
10 |
class BalloonIconConverter:IValueConverter |
|
11 |
{ |
|
12 |
|
|
13 |
Dictionary<BalloonIcon,BitmapImage> _iconCache=new Dictionary<BalloonIcon,BitmapImage>(); |
|
14 |
|
|
15 |
public object Convert(object value, Type targetType, object parameter, CultureInfo culture) |
|
16 |
{ |
|
17 |
BitmapImage image; |
|
18 |
|
|
19 |
var icon = (BalloonIcon) value; |
|
20 |
if (icon == BalloonIcon.None) |
|
21 |
return null; |
|
22 |
|
|
23 |
if (!_iconCache.TryGetValue(icon, out image)) |
|
24 |
{ |
|
25 |
var imagePath = String.Format("/Pithos.Client.WPF;component/Images/{0}.png", Enum.GetName(typeof(BalloonIcon), value)); |
|
26 |
var uri = new Uri(imagePath, UriKind.Relative); |
|
27 |
image=new BitmapImage(uri); |
|
28 |
_iconCache[icon] = image; |
|
29 |
} |
|
30 |
return image; |
|
31 |
|
|
32 |
} |
|
33 |
|
|
34 |
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) |
|
35 |
{ |
|
36 |
throw new NotImplementedException(); |
|
37 |
} |
|
38 |
} |
|
39 |
} |
Also available in: Unified diff