Add clearance logic to PamhagenPlant
This commit is contained in:
@@ -15,14 +15,26 @@ namespace PamhagenSysCtrl.Helpers.Pipeline {
|
||||
public ISet<IEdge> Inputs { get; init; }
|
||||
public ISet<IEdge> Outputs { get; init; }
|
||||
|
||||
public Brush? Highlight { get; set; }
|
||||
public bool IsActive => CallbackActive();
|
||||
public bool HasClearance => CallbackClearance();
|
||||
public bool IsSelected => CallbackSelected(this);
|
||||
|
||||
protected Func<bool> CallbackActive;
|
||||
protected Func<bool> CallbackClearance;
|
||||
protected Func<Pump, bool> CallbackSelected;
|
||||
|
||||
private Shape? _circle;
|
||||
private Shape? _triangle;
|
||||
private TextBlock? _text;
|
||||
|
||||
public Pump(string label, double x, double y) {
|
||||
public Pump(string label, double x, double y, Func<bool> cbActive, Func<bool> cbClearance, Func<Pump, bool> cbSelected) {
|
||||
CenterX = x;
|
||||
CenterY = y;
|
||||
Label = label;
|
||||
CallbackActive = cbActive;
|
||||
CallbackClearance = cbClearance;
|
||||
CallbackSelected = cbSelected;
|
||||
Inputs = new HashSet<IEdge>();
|
||||
Outputs = new HashSet<IEdge>();
|
||||
}
|
||||
@@ -63,7 +75,13 @@ namespace PamhagenSysCtrl.Helpers.Pipeline {
|
||||
}
|
||||
|
||||
public void Update(bool isHovering, bool isPresed) {
|
||||
_circle?.Fill = isHovering ? Brushes.LightGray : Brushes.WhiteSmoke;
|
||||
_circle?.Fill = Highlight ?? (
|
||||
IsActive && isHovering ? PamhagenBrushes.Red :
|
||||
IsActive ? PamhagenBrushes.Green :
|
||||
HasClearance && IsSelected && isHovering ? PamhagenBrushes.Green :
|
||||
HasClearance && IsSelected ? PamhagenBrushes.Yellow :
|
||||
IsSelected ? PamhagenBrushes.Red :
|
||||
isHovering ? Brushes.LightGray : Brushes.WhiteSmoke);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user