-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathBindingConverters.cs
49 lines (45 loc) · 1.49 KB
/
BindingConverters.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
using System.Windows;
using System.Windows.Data;
namespace PlazaConnectivityChecker
{
public class StarWidthConverter : IValueConverter
{
public object Convert(object value, System.Type targetType, object parameter, System.Globalization.CultureInfo culture)
{
try
{
var stars = (decimal)value;
var width = (double)(80 / 5 * stars);
return new Rect(0, 0, width, 16);
}
catch
{
return new Rect(0, 0, 80, 16);
}
}
public object ConvertBack(object value, System.Type targetType, object parameter, System.Globalization.CultureInfo culture)
{
throw new System.NotImplementedException();
}
}
public class StarHeightConverter : IValueConverter
{
public object Convert(object value, System.Type targetType, object parameter, System.Globalization.CultureInfo culture)
{
try
{
var stars = (decimal)value;
var height = (double)(200 / 5 * stars);
return height;
}
catch
{
return 200d;
}
}
public object ConvertBack(object value, System.Type targetType, object parameter, System.Globalization.CultureInfo culture)
{
throw new System.NotImplementedException();
}
}
}