Fix ColorSubgraph()
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
using PamhagenSysCtrl.Helpers.Pipeline;
|
||||
using System.Windows.Media;
|
||||
|
||||
namespace PamhagenSysCtrl.Helpers {
|
||||
public class PamhagenGraph : Graph {
|
||||
@@ -337,5 +338,26 @@ namespace PamhagenSysCtrl.Helpers {
|
||||
protected static Tank CreateTank(int n, double x, double y, int capacity) {
|
||||
return new($"Tank {n}", x, y, capacity, () => App.Plant?.TankFillLevels[n - 1] != FillState.Empty, () => App.Plant?.TankFillLevels[n - 1] != FillState.Full);
|
||||
}
|
||||
|
||||
public void ColorSubgraph(INode start, Brush color, Action<Valve>? valveAction = null) {
|
||||
if (start is Valve v) {
|
||||
valveAction?.Invoke(v);
|
||||
return;
|
||||
} else if (start is ISink || start is Pump) {
|
||||
return;
|
||||
}
|
||||
foreach (var edge in start.Inputs) {
|
||||
if (edge.Highlight != null) continue;
|
||||
var o = edge.IsTwoWay && edge.Start == start ? edge.End : edge.Start;
|
||||
edge.Highlight = color;
|
||||
ColorSubgraph(o, color, valveAction);
|
||||
}
|
||||
foreach (var edge in start.Outputs) {
|
||||
if (edge.Highlight != null) continue;
|
||||
var o = edge.IsTwoWay && edge.End == start ? edge.Start : edge.End;
|
||||
edge.Highlight = color;
|
||||
ColorSubgraph(o, color, valveAction);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user