Creating a new desktop app with avaloniaui
This commit is contained in:
26
v2rayN/v2rayN.Desktop/Converters/DelayColorConverter.cs
Normal file
26
v2rayN/v2rayN.Desktop/Converters/DelayColorConverter.cs
Normal file
@@ -0,0 +1,26 @@
|
||||
using Avalonia.Data.Converters;
|
||||
using Avalonia.Media;
|
||||
using System.Globalization;
|
||||
|
||||
namespace v2rayN.Desktop.Converters
|
||||
{
|
||||
public class DelayColorConverter : IValueConverter
|
||||
{
|
||||
public object? Convert(object? value, Type targetType, object? parameter, CultureInfo culture)
|
||||
{
|
||||
int.TryParse(value?.ToString(), out var delay);
|
||||
|
||||
if (delay <= 0)
|
||||
return new SolidColorBrush(Colors.Red);
|
||||
if (delay <= 500)
|
||||
return new SolidColorBrush(Colors.Green);
|
||||
else
|
||||
return new SolidColorBrush(Colors.IndianRed);
|
||||
}
|
||||
|
||||
public object? ConvertBack(object? value, Type targetType, object? parameter, CultureInfo culture)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user