-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSafetyColorConverter.cs
More file actions
25 lines (23 loc) · 891 Bytes
/
SafetyColorConverter.cs
File metadata and controls
25 lines (23 loc) · 891 Bytes
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
using Avalonia.Data.Converters;
using Avalonia.Media;
using ReWindows.ViewModels;
using System;
using System.Globalization;
namespace ReWindows
{
public class SafetyColorConverter : IValueConverter
{
public object Convert(object? value, Type targetType, object? parameter, CultureInfo culture)
{
return value is TweakSafety safety ? safety switch
{
TweakSafety.Safe => new SolidColorBrush(Color.Parse("#3a9e5f")),
TweakSafety.Moderate => new SolidColorBrush(Color.Parse("#d4812a")),
TweakSafety.Dangerous => new SolidColorBrush(Color.Parse("#c0392b")),
_ => Brushes.Gray
} : Brushes.Gray;
}
public object ConvertBack(object? value, Type targetType, object? parameter, CultureInfo culture)
=> throw new NotSupportedException();
}
}