PlantSchemeWindow: Expand graph

This commit is contained in:
2026-07-12 22:26:08 +02:00
parent a3a0504c11
commit 791ee7b804
12 changed files with 129 additions and 25 deletions
+16 -4
View File
@@ -11,29 +11,41 @@ namespace PamhagenSysCtrl.Helpers.Pipeline {
public bool IsOpen => CallbackIsOpen();
public bool WantOpen => CallbackWantOpen();
public ISet<IEdge> Inputs { get; init; }
public ISet<IEdge> Outputs { get; init; }
protected Func<bool> CallbackIsOpen;
protected Func<bool> CallbackWantOpen;
private Ellipse Me;
public Valve(string label, double x, double y, Func<bool> cbOpen, Func<bool> cbWant) {
CenterX = x;
CenterY = y;
Label = label;
CallbackIsOpen = cbOpen;
CallbackWantOpen = cbWant;
Inputs = new HashSet<IEdge>();
Outputs = new HashSet<IEdge>();
}
public void Draw(Canvas canvas) {
var e = new Ellipse() {
Me = new Ellipse() {
Height = 20,
Width = 20,
Fill = Brushes.Gray,
Stroke = Brushes.Black,
StrokeThickness = 2,
};
e.SetValue(Canvas.LeftProperty, CenterX - 10);
e.SetValue(Canvas.TopProperty, CenterY - 10);
canvas.Children.Add(e);
Me.SetValue(Canvas.LeftProperty, CenterX - 10);
Me.SetValue(Canvas.TopProperty, CenterY - 10);
canvas.Children.Add(Me);
}
public bool Update(double x, double y) {
var hover = Math.Sqrt(Math.Pow(CenterX - x, 2) + Math.Pow(CenterY - y, 2)) <= 10;
Me.Fill = hover ? Brushes.LightGray : Brushes.Gray;
return hover;
}
}
}