-
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathConverters.cs
75 lines (70 loc) · 2.25 KB
/
Converters.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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Controls;
using System.Windows.Data;
namespace HtmlExporterPlugin
{
public class BooleanConverter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
if (value is bool boolvalue)
{
return boolvalue ? Constants.HTMLExporterTrue : Constants.HTMLExporterFalse;
}
return "";
}
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
{
if (value is string stringvalue)
{
if (stringvalue == Constants.HTMLExporterTrue)
{
return true;
}
else
{
return false;
}
}
return null;
}
}
public class FieldToFieldTextConverter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
if (value is string stringvalue)
{
return Constants.GetNameFromField(stringvalue, false);
}
return "";
}
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
{
if (value is string stringvalue)
{
return Constants.GetFieldFromName(stringvalue, false);
}
return "";
}
}
public class RowNumberConverter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
DataGridRow row = (DataGridRow)value;
if (row == null)
throw new InvalidOperationException("This converter class can only be used with DataGridRow elements.");
return row.GetIndex() + 1;
}
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
{
throw new NotSupportedException();
}
}
}