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
This commit is contained in:
@@ -0,0 +1,46 @@
|
||||
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();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user