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

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