Add remaining tanks

This commit is contained in:
2026-07-13 17:11:21 +02:00
parent 011f90233c
commit 74ec9527da
13 changed files with 378 additions and 110 deletions
+22 -6
View File
@@ -1,4 +1,5 @@
using System.Windows.Controls;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Media;
using System.Windows.Shapes;
@@ -11,6 +12,7 @@ namespace PamhagenSysCtrl.Helpers.Pipeline {
public double CenterX { get; set; }
public double CenterY { get; set; }
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();
@@ -21,6 +23,9 @@ namespace PamhagenSysCtrl.Helpers.Pipeline {
protected Func<bool> CallbackIsFilled;
protected Func<bool> CallbackIsFull;
private Shape? _rect;
private TextBlock? _text;
public Tank(string label, double x, double y, Func<bool> cbFilled, Func<bool> cbFull) {
CenterX = x;
CenterY = y;
@@ -32,20 +37,31 @@ namespace PamhagenSysCtrl.Helpers.Pipeline {
}
public void Draw(Canvas canvas) {
var rect = new Rectangle() {
_rect = new Rectangle() {
Width = WIDTH,
Height = HEIGHT,
Stroke = Brushes.Black,
StrokeThickness = 2,
Fill = Brushes.White,
Fill = Brushes.WhiteSmoke,
};
rect.SetValue(Canvas.LeftProperty, CenterX - WIDTH / 2);
rect.SetValue(Canvas.TopProperty, CenterY - HEIGHT / 2);
canvas.Children.Add(rect);
_text = new() {
Text = Label,
FontSize = 12,
Width = WIDTH,
TextAlignment = TextAlignment.Center,
VerticalAlignment = VerticalAlignment.Center,
};
_rect.SetValue(Canvas.LeftProperty, CenterX - WIDTH / 2);
_rect.SetValue(Canvas.TopProperty, CenterY - HEIGHT / 2);
_text.SetValue(Canvas.LeftProperty, CenterX - WIDTH / 2);
_text.SetValue(Canvas.TopProperty, CenterY - 8);
canvas.Children.Add(_rect);
canvas.Children.Add(_text);
}
public bool Update(double x, double y) {
var hover = Math.Abs(x - CenterX) <= WIDTH / 2 && Math.Abs(y - CenterY) <= HEIGHT / 2;
_rect?.Fill = hover ? Brushes.LightGray : Brushes.WhiteSmoke;
return hover;
}
}