Mercurial > silverbladetech
comparison MetroWpf/MetroWpf.Xaml/Converters/NumberPositiveToNegativeConverter.cs @ 15:060f02cd4591
Initial commit, pre airport work
author | stevenh7776 stevenhollidge@hotmail.com |
---|---|
date | Mon, 12 Mar 2012 23:05:21 +0800 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
14:741981715d94 | 15:060f02cd4591 |
---|---|
1 using System; | |
2 using System.Globalization; | |
3 using System.Windows; | |
4 using System.Windows.Data; | |
5 | |
6 namespace MetroWpf.Xaml.Converters | |
7 { | |
8 public sealed class NumberPositiveToNegativeConverter : IValueConverter | |
9 { | |
10 public object Convert(object value, Type targetType, object parameter, CultureInfo culture) | |
11 { | |
12 if (value is Byte) | |
13 return (Byte)((Byte)value * -1); | |
14 if (value is Int16) | |
15 return (Int16)((Int16)value * -1); | |
16 if (value is Int32) | |
17 return (Int32)value * -1; | |
18 if (value is Int64) | |
19 return (Int64)value * -1; | |
20 if (value is Single) | |
21 return (Single)value * -1f; | |
22 if (value is Double) | |
23 return (Double)value * -1d; | |
24 if (value is Decimal) | |
25 return (Decimal)value * -1m; | |
26 return DependencyProperty.UnsetValue; | |
27 } | |
28 | |
29 public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) | |
30 { | |
31 return Convert(value, targetType, parameter, culture); | |
32 } | |
33 } | |
34 } ; |