switched to new way

This commit is contained in:
Boki 2026-02-13 01:12:51 -05:00
parent f22d182c8f
commit 4a65c8e17b
96 changed files with 4991 additions and 10025 deletions

View file

@ -0,0 +1,99 @@
using System.Globalization;
using Avalonia;
using Avalonia.Data.Converters;
using Avalonia.Media;
using Poe2Trade.Core;
using Poe2Trade.Ui.ViewModels;
namespace Poe2Trade.Ui.Converters;
public class LogLevelToBrushConverter : IValueConverter
{
public object? Convert(object? value, Type targetType, object? parameter, CultureInfo culture)
{
return value?.ToString()?.ToUpperInvariant() switch
{
"INFO" => new SolidColorBrush(Color.Parse("#58a6ff")),
"WARN" or "WARNING" => new SolidColorBrush(Color.Parse("#d29922")),
"ERROR" => new SolidColorBrush(Color.Parse("#f85149")),
"DEBUG" => new SolidColorBrush(Color.Parse("#8b949e")),
_ => new SolidColorBrush(Color.Parse("#e6edf3")),
};
}
public object? ConvertBack(object? value, Type targetType, object? parameter, CultureInfo culture)
=> throw new NotSupportedException();
}
public class BoolToOccupiedBrushConverter : IValueConverter
{
public object? Convert(object? value, Type targetType, object? parameter, CultureInfo culture)
{
var occupied = value is true;
return new SolidColorBrush(occupied ? Color.Parse("#238636") : Color.Parse("#161b22"));
}
public object? ConvertBack(object? value, Type targetType, object? parameter, CultureInfo culture)
=> throw new NotSupportedException();
}
public class LinkModeToColorConverter : IValueConverter
{
public object? Convert(object? value, Type targetType, object? parameter, CultureInfo culture)
{
return value switch
{
LinkMode.Live => new SolidColorBrush(Color.Parse("#1f6feb")),
LinkMode.Scrap => new SolidColorBrush(Color.Parse("#9e6a03")),
_ => new SolidColorBrush(Color.Parse("#30363d")),
};
}
public object? ConvertBack(object? value, Type targetType, object? parameter, CultureInfo culture)
=> throw new NotSupportedException();
}
public class StatusDotBrushConverter : IValueConverter
{
public object? Convert(object? value, Type targetType, object? parameter, CultureInfo culture)
{
var state = value?.ToString() ?? "Idle";
return state switch
{
"Idle" => new SolidColorBrush(Color.Parse("#8b949e")),
"Paused" => new SolidColorBrush(Color.Parse("#d29922")),
_ => new SolidColorBrush(Color.Parse("#3fb950")),
};
}
public object? ConvertBack(object? value, Type targetType, object? parameter, CultureInfo culture)
=> throw new NotSupportedException();
}
public class ActiveOpacityConverter : IValueConverter
{
public object? Convert(object? value, Type targetType, object? parameter, CultureInfo culture)
=> value is true ? 1.0 : 0.5;
public object? ConvertBack(object? value, Type targetType, object? parameter, CultureInfo culture)
=> throw new NotSupportedException();
}
public class CellBorderConverter : IValueConverter
{
public object? Convert(object? value, Type targetType, object? parameter, CultureInfo culture)
{
if (value is CellState cell)
{
return new Thickness(
cell.BorderLeft ? 2 : 0,
cell.BorderTop ? 2 : 0,
cell.BorderRight ? 2 : 0,
cell.BorderBottom ? 2 : 0);
}
return new Thickness(0);
}
public object? ConvertBack(object? value, Type targetType, object? parameter, CultureInfo culture)
=> throw new NotSupportedException();
}