annotate MetroWpf/Stocks.UI/Converters/DeltaToIconConverter.cs @ 100:9b6855dc165e

Updated System.Windows into Libs
author stevenhollidge <stevenhollidge@hotmail.com>
date Sat, 05 May 2012 23:04:16 +0100
parents 399398841fd0
children
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 {
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
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 }