d85f2e0fb3
Bootstraper läd jetzt die farbeinstellung sofort und nicht nachträglich cleanup and rework PDF switch to HTML export fix Colorsystem Farben für knöpfe hinzugefügt als anpassung button color button color primary and secondary change
47 lines
972 B
C#
47 lines
972 B
C#
using Microsoft.Maui.Graphics;
|
|
|
|
namespace cfs_tracker.Helpers;
|
|
|
|
public static class ColorUtility
|
|
{
|
|
public static bool IsHexColor(string? value)
|
|
{
|
|
if (string.IsNullOrWhiteSpace(value))
|
|
return false;
|
|
|
|
try
|
|
{
|
|
_ = Color.FromArgb(NormalizeHex(value));
|
|
return true;
|
|
}
|
|
catch
|
|
{
|
|
return false;
|
|
}
|
|
}
|
|
|
|
public static Color ParseColor(string? value, string fallbackHex)
|
|
{
|
|
try
|
|
{
|
|
return Color.FromArgb(NormalizeHex(value));
|
|
}
|
|
catch
|
|
{
|
|
return Color.FromArgb(NormalizeHex(fallbackHex));
|
|
}
|
|
}
|
|
|
|
public static string NormalizeHex(string? value)
|
|
{
|
|
var text = (value ?? string.Empty).Trim();
|
|
if (string.IsNullOrWhiteSpace(text))
|
|
return "#000000";
|
|
|
|
if (!text.StartsWith('#'))
|
|
text = "#" + text;
|
|
|
|
return text.ToUpperInvariant();
|
|
}
|
|
}
|