Details ausgearbeitet
Linked colors to options menu Options extension Aussehen aufgebohrt: - erlaubt text von status zu ändern, - bessere beschriftung von Farben desing änderung und bedienung - heute status felder anklickbar, - Farbpalette verdunkelt und kontrast reduziert - Kalender Tage anklickbar gemacht - Optionen überarbeitet
This commit is contained in:
@@ -0,0 +1,48 @@
|
||||
using System.Globalization;
|
||||
using Microsoft.Maui.Controls;
|
||||
using Microsoft.Maui.Graphics;
|
||||
|
||||
namespace cfs_tracker.Converters;
|
||||
|
||||
public class HexToColorConverter : IValueConverter
|
||||
{
|
||||
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
|
||||
{
|
||||
if (value is string hex && !string.IsNullOrWhiteSpace(hex))
|
||||
{
|
||||
try
|
||||
{
|
||||
return Color.FromArgb(hex);
|
||||
}
|
||||
catch
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
return Color.FromArgb("#203041");
|
||||
}
|
||||
|
||||
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
|
||||
{
|
||||
if (value is Color color)
|
||||
return color.ToArgbHex();
|
||||
|
||||
return "#203041";
|
||||
}
|
||||
}
|
||||
|
||||
public static class ColorExtensions
|
||||
{
|
||||
public static string ToArgbHex(this Color color)
|
||||
{
|
||||
byte a = (byte)(color.Alpha * 255);
|
||||
byte r = (byte)(color.Red * 255);
|
||||
byte g = (byte)(color.Green * 255);
|
||||
byte b = (byte)(color.Blue * 255);
|
||||
|
||||
if (a < 255)
|
||||
return $"#{a:X2}{r:X2}{g:X2}{b:X2}";
|
||||
|
||||
return $"#{r:X2}{g:X2}{b:X2}";
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user