2025-09-16 16:06:41 +08:00
|
|
|
|
using System.Windows.Media;
|
|
|
|
|
|
|
2026-02-28 22:34:51 +08:00
|
|
|
|
namespace Szmedi.RvKits.RvScript
|
2025-09-16 16:06:41 +08:00
|
|
|
|
{
|
|
|
|
|
|
public static class ExtensionMethods
|
|
|
|
|
|
{
|
|
|
|
|
|
public static SolidColorBrush GetSolidColorBrush(this string hex)
|
|
|
|
|
|
{
|
|
|
|
|
|
hex = hex.Replace("#", string.Empty);
|
|
|
|
|
|
|
|
|
|
|
|
byte a = 255;
|
|
|
|
|
|
int index = 0;
|
|
|
|
|
|
|
|
|
|
|
|
if (hex.Length == 8)
|
|
|
|
|
|
{
|
|
|
|
|
|
a = (byte)(Convert.ToUInt32(hex.Substring(index, 2), 16));
|
|
|
|
|
|
index += 2;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
byte r = (byte)(Convert.ToUInt32(hex.Substring(index, 2), 16));
|
|
|
|
|
|
index += 2;
|
|
|
|
|
|
byte g = (byte)(Convert.ToUInt32(hex.Substring(index, 2), 16));
|
|
|
|
|
|
index += 2;
|
|
|
|
|
|
byte b = (byte)(Convert.ToUInt32(hex.Substring(index, 2), 16));
|
|
|
|
|
|
SolidColorBrush myBrush = new(Color.FromArgb(a, r, g, b));
|
|
|
|
|
|
return myBrush;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|