Mercurial > silverbladetech
annotate MetroWpf/Stocks.UI/Converters/DeltaToIconConverter.cs @ 23:399398841fd0
Working version for Stocks (including loosely coupled components
author | adminsh@apollo |
---|---|
date | Tue, 20 Mar 2012 16:53:29 +0000 |
parents | 6109bc268b90 |
children |
rev | line source |
---|---|
20 | 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 { | |
23
399398841fd0
Working version for Stocks (including loosely coupled components
adminsh@apollo
parents:
20
diff
changeset
|
20 delta = (decimal) value; |
399398841fd0
Working version for Stocks (including loosely coupled components
adminsh@apollo
parents:
20
diff
changeset
|
21 { |
399398841fd0
Working version for Stocks (including loosely coupled components
adminsh@apollo
parents:
20
diff
changeset
|
22 if (delta > 0) |
399398841fd0
Working version for Stocks (including loosely coupled components
adminsh@apollo
parents:
20
diff
changeset
|
23 file = "UP"; |
399398841fd0
Working version for Stocks (including loosely coupled components
adminsh@apollo
parents:
20
diff
changeset
|
24 else if (delta < 0) |
399398841fd0
Working version for Stocks (including loosely coupled components
adminsh@apollo
parents:
20
diff
changeset
|
25 file = "DOWN"; |
399398841fd0
Working version for Stocks (including loosely coupled components
adminsh@apollo
parents:
20
diff
changeset
|
26 else |
399398841fd0
Working version for Stocks (including loosely coupled components
adminsh@apollo
parents:
20
diff
changeset
|
27 file = "LEVEL"; |
399398841fd0
Working version for Stocks (including loosely coupled components
adminsh@apollo
parents:
20
diff
changeset
|
28 } |
20 | 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 } |