comparison MetroWpf/Stocks.UI/Converters/DeltaToIconConverter.cs @ 20:6109bc268b90

Latest
author adminsh@apollo
date Tue, 20 Mar 2012 13:37:46 +0000
parents
children 399398841fd0
comparison
equal deleted inserted replaced
19:09d18d6e5f40 20:6109bc268b90
1 using System;
2 using System.Windows.Data;
3 using System.Windows.Media.Imaging;
4
5 namespace Stocks.UI.Converters
6 {
7 public class DeltaToIconConverter : IValueConverter
8 {
9 #region IValueConverter Members
10
11 public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
12 {
13 string uri;
14 BitmapImage image;
15 decimal delta;
16 string file = "UNK";
17
18 try
19 {
20 delta = (decimal) value;
21 {
22 if (delta > 0)
23 file = "UP";
24 else if (delta < 0)
25 file = "DOWN";
26 else
27 file = "LEVEL";
28 }
29 }
30 finally
31 {
32 uri = string.Format("../Images/{0}.png", file);
33 image = new BitmapImage(new Uri(uri, UriKind.Relative));
34 }
35
36 return image;
37 }
38
39 public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
40 {
41 throw new NotImplementedException();
42 }
43
44 #endregion
45 }
46 }