Display filling level
This commit is contained in:
@@ -14,27 +14,26 @@ namespace PamhagenSysCtrl.Helpers.Pipeline {
|
||||
public double TopY => CenterY - HEIGHT / 2;
|
||||
public double BottomY => CenterY + HEIGHT / 2;
|
||||
public string Label { get; set; }
|
||||
public bool IsFull => CallbackIsFull();
|
||||
public bool IsFilled => CallbackIsFilled();
|
||||
public FillState FillState => CallbackFillState();
|
||||
public bool IsFull => FillState == FillState.Full;
|
||||
public bool IsFilled => FillState != FillState.Empty;
|
||||
|
||||
public ISet<IEdge> Inputs { get; init; }
|
||||
public ISet<IEdge> Outputs { get; init; }
|
||||
|
||||
public int? CapacityLiters { get; set; }
|
||||
|
||||
protected Func<bool> CallbackIsFilled;
|
||||
protected Func<bool> CallbackIsFull;
|
||||
protected Func<FillState> CallbackFillState;
|
||||
|
||||
private Shape? _rect;
|
||||
private TextBlock? _text;
|
||||
|
||||
public Tank(string label, double x, double y, int capacityLiters, Func<bool> cbFilled, Func<bool> cbFull) {
|
||||
public Tank(string label, double x, double y, int capacityLiters, Func<FillState> cbFillState) {
|
||||
CenterX = x;
|
||||
CenterY = y;
|
||||
Label = label;
|
||||
CapacityLiters = capacityLiters;
|
||||
CallbackIsFilled = cbFilled;
|
||||
CallbackIsFull = cbFull;
|
||||
CallbackFillState = cbFillState;
|
||||
Inputs = new HashSet<IEdge>();
|
||||
Outputs = new HashSet<IEdge>();
|
||||
}
|
||||
@@ -67,7 +66,11 @@ namespace PamhagenSysCtrl.Helpers.Pipeline {
|
||||
}
|
||||
|
||||
public void Update(bool isHovering, bool isPressed) {
|
||||
_rect?.Fill = isHovering ? Brushes.LightGray : Brushes.WhiteSmoke;
|
||||
_rect?.Fill = PamhagenBrushes.ForFillState(FillState,
|
||||
isHovering && isPressed ? Brushes.DarkGray :
|
||||
isHovering ? Brushes.LightGray :
|
||||
Brushes.WhiteSmoke
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user