2 /* -----------------------------------------------------------------------
\r
3 * <copyright file="BalloonIconConverter.cs" company="GRNet">
\r
5 * Copyright 2011-2012 GRNET S.A. All rights reserved.
\r
7 * Redistribution and use in source and binary forms, with or
\r
8 * without modification, are permitted provided that the following
\r
9 * conditions are met:
\r
11 * 1. Redistributions of source code must retain the above
\r
12 * copyright notice, this list of conditions and the following
\r
15 * 2. Redistributions in binary form must reproduce the above
\r
16 * copyright notice, this list of conditions and the following
\r
17 * disclaimer in the documentation and/or other materials
\r
18 * provided with the distribution.
\r
21 * THIS SOFTWARE IS PROVIDED BY GRNET S.A. ``AS IS'' AND ANY EXPRESS
\r
22 * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
\r
23 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
\r
24 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL GRNET S.A OR
\r
25 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
\r
26 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
\r
27 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
\r
28 * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
\r
29 * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
\r
30 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
\r
31 * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
\r
32 * POSSIBILITY OF SUCH DAMAGE.
\r
34 * The views and conclusions contained in the software and
\r
35 * documentation are those of the authors and should not be
\r
36 * interpreted as representing official policies, either expressed
\r
37 * or implied, of GRNET S.A.
\r
39 * -----------------------------------------------------------------------
\r
43 using System.Collections.Generic;
\r
44 using System.Globalization;
\r
45 using System.Windows.Data;
\r
46 using System.Windows.Media.Imaging;
\r
47 using Hardcodet.Wpf.TaskbarNotification;
\r
49 namespace Pithos.Client.WPF.Shell
\r
51 class BalloonIconConverter:IValueConverter
\r
54 Dictionary<BalloonIcon,BitmapImage> _iconCache=new Dictionary<BalloonIcon,BitmapImage>();
\r
56 public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
\r
60 var icon = (BalloonIcon) value;
\r
61 if (icon == BalloonIcon.None)
\r
64 if (!_iconCache.TryGetValue(icon, out image))
\r
66 var imagePath = String.Format("/Pithos;component/Images/{0}.png", Enum.GetName(typeof(BalloonIcon), value));
\r
67 var uri = new Uri(imagePath, UriKind.Relative);
\r
68 image=new BitmapImage(uri);
\r
69 _iconCache[icon] = image;
\r
74 public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
\r
76 throw new NotImplementedException();
\r