Files
pamhagen-sysctrl/PamhagenSysCtrl/Helpers/PamhagenBrushes.cs
T

44 lines
1.8 KiB
C#

using System.Windows.Media;
namespace PamhagenSysCtrl.Helpers {
public class PamhagenBrushes {
public const double TRANSITION = 1.0 / 4096;
public static readonly SolidColorBrush Green = new SolidColorBrush(Color.FromRgb(0x20, 0xE0, 0x20));
public static readonly SolidColorBrush DimOrange = new SolidColorBrush(Color.FromRgb(0xFF, 0xC0, 0x80));
public static readonly SolidColorBrush Yellow = new SolidColorBrush(Color.FromRgb(0xFF, 0xE0, 0x10));
public static readonly SolidColorBrush Red = new SolidColorBrush(Color.FromRgb(0xFF, 0x20, 0x20));
public static Brush ForFillState(FillState state, Color background) {
return state switch {
FillState.Empty => GetEmpty(background),
FillState.Filled => GetFilled(background),
FillState.Half => GetHalf(background),
FillState.Full => GetFull(background),
_ => GetEmpty(background),
};
}
public static Brush ForFillState(FillState state, SolidColorBrush background) {
return ForFillState(state, background.Color);
}
public static Brush GetEmpty(Color background) {
return new SolidColorBrush(background);
}
public static Brush GetFilled(Color background) {
return new LinearGradientBrush(background, Green.Color, new(0.5, 0.875 - TRANSITION), new(0.5, 0.875 + TRANSITION));
}
public static Brush GetHalf(Color background) {
return new LinearGradientBrush(background, Green.Color, new(0.5, 0.5 - TRANSITION), new(0.5, 0.5 + TRANSITION));
}
public static Brush GetFull(Color background) {
return new LinearGradientBrush(background, Red.Color, new(0.5, 0.0625 - TRANSITION), new(0.5, 0.0625 + TRANSITION));
}
}
}