-
Notifications
You must be signed in to change notification settings - Fork 204
/
Copy pathIntConverters.cs
43 lines (34 loc) · 1.75 KB
/
IntConverters.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
using Avalonia;
using Avalonia.Controls;
using Avalonia.Data.Converters;
using Avalonia.Media;
namespace SourceGit.Converters
{
public static class IntConverters
{
public static readonly FuncValueConverter<int, bool> IsGreaterThanZero =
new FuncValueConverter<int, bool>(v => v > 0);
public static readonly FuncValueConverter<int, bool> IsGreaterThanFour =
new FuncValueConverter<int, bool>(v => v > 4);
public static readonly FuncValueConverter<int, bool> IsZero =
new FuncValueConverter<int, bool>(v => v == 0);
public static readonly FuncValueConverter<int, bool> IsOne =
new FuncValueConverter<int, bool>(v => v == 1);
public static readonly FuncValueConverter<int, bool> IsNotOne =
new FuncValueConverter<int, bool>(v => v != 1);
public static readonly FuncValueConverter<int, bool> IsSubjectLengthBad =
new FuncValueConverter<int, bool>(v => v > ViewModels.Preferences.Instance.SubjectGuideLength);
public static readonly FuncValueConverter<int, bool> IsSubjectLengthGood =
new FuncValueConverter<int, bool>(v => v <= ViewModels.Preferences.Instance.SubjectGuideLength);
public static readonly FuncValueConverter<int, Thickness> ToTreeMargin =
new FuncValueConverter<int, Thickness>(v => new Thickness(v * 16, 0, 0, 0));
public static readonly FuncValueConverter<int, IBrush> ToBookmarkBrush =
new FuncValueConverter<int, IBrush>(bookmark =>
{
if (bookmark == 0)
return Application.Current?.FindResource("Brush.FG1") as IBrush;
else
return Models.Bookmarks.Brushes[bookmark];
});
}
}