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
+12 -7
View File
@@ -13,21 +13,22 @@ namespace PamhagenSysCtrl.Helpers.Pipeline {
public double CenterY { get; set; }
public double BottomY => CenterY + HEIGHT / 2;
public string Label { get; set; }
public bool IsFilled => CallbackIsFilled();
public FillState FillState => CallbackFillState();
public bool IsFilled => FillState != FillState.Empty;
public ISet<IEdge> Inputs { get; init; }
public ISet<IEdge> Outputs { get; init; }
protected Func<bool> CallbackIsFilled;
protected Func<FillState> CallbackFillState;
private Shape? _inner;
private Shape? _outer;
private TextBlock? _text;
public Trough(string label, double x, double y, Func<bool> cbFilled) {
public Trough(string label, double x, double y, Func<FillState> cbFillState) {
CenterX = x;
CenterY = y;
Label = label;
CallbackIsFilled = cbFilled;
CallbackFillState = cbFillState;
Inputs = new HashSet<IEdge>();
Outputs = new HashSet<IEdge>();
}
@@ -45,7 +46,7 @@ namespace PamhagenSysCtrl.Helpers.Pipeline {
};
_text = new() {
Text = Label,
FontSize = 12,
FontSize = 14,
Width = WIDTH,
TextAlignment = TextAlignment.Center,
VerticalAlignment = VerticalAlignment.Center,
@@ -55,7 +56,7 @@ namespace PamhagenSysCtrl.Helpers.Pipeline {
_inner.SetValue(Canvas.LeftProperty, CenterX - WIDTH / 2 + 2);
_inner.SetValue(Canvas.TopProperty, CenterY - HEIGHT / 2);
_text.SetValue(Canvas.LeftProperty, CenterX - WIDTH / 2);
_text.SetValue(Canvas.TopProperty, CenterY - 8);
_text.SetValue(Canvas.TopProperty, CenterY - 10);
canvas.Children.Add(_outer);
canvas.Children.Add(_inner);
canvas.Children.Add(_text);
@@ -66,7 +67,11 @@ namespace PamhagenSysCtrl.Helpers.Pipeline {
}
public void Update(bool isHovering, bool isPressed) {
_inner?.Fill = isHovering ? Brushes.LightGray : Brushes.WhiteSmoke;
_inner?.Fill = PamhagenBrushes.ForFillState(FillState,
isHovering && isPressed ? Brushes.DarkGray :
isHovering ? Brushes.LightGray :
Brushes.WhiteSmoke
);
}
}
}