initial commit

This commit is contained in:
2026-04-11 12:45:18 +02:00
commit 6e1b929e2f
1246 changed files with 177580 additions and 0 deletions

View File

@@ -0,0 +1,32 @@
using System;
using System.Globalization;
using System.Windows.Data;
using System.Windows.Media;
namespace HC_APTBS.Converters
{
/// <summary>
/// Converts a CSS-style hex colour string (e.g. "#26C200") to a
/// <see cref="SolidColorBrush"/> for use in WPF bindings.
/// Returns <see cref="Brushes.Transparent"/> for null or invalid input.
/// </summary>
[ValueConversion(typeof(string), typeof(SolidColorBrush))]
public sealed class HexColorToBrushConverter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
if (value is string hex && !string.IsNullOrWhiteSpace(hex))
{
try
{
return new SolidColorBrush((Color)ColorConverter.ConvertFromString(hex));
}
catch { /* fall through */ }
}
return Brushes.Transparent;
}
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
=> throw new NotSupportedException();
}
}