Display filling level

This commit is contained in:
2026-07-15 13:59:22 +02:00
parent 4c9da5c9d5
commit b8ac414673
10 changed files with 128 additions and 47 deletions
@@ -0,0 +1,43 @@
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));
}
}
}