d11f0e46c0
clean up and fixes - Heute gefixt - Code Cleanup NotificationScheduleItemViewModel -fixed NotificationScheduleItemViewModel for Windows compat push implementation Push fixes Push benachrichtungen eingebaut - Status bei push - Push auch in background - Toggle für symtome angepasst push system change exporter update Optionen fix - Optionen aufgeteilt auf 3 tabs - Anpassungen haben jetzt Farbslider Optimierung fix
45 lines
940 B
C#
45 lines
940 B
C#
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();
|
|
}
|
|
}
|