Files
cfs-Tracker/Helpers/ColorUtility.cs
T
Djagor d85f2e0fb3 Farbpalette vorladen lassen
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
2026-03-24 21:59:59 +01:00

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();
}
}