[WIP] Scaling
Test / Run tests (push) Successful in 14s

This commit is contained in:
2026-08-12 16:39:02 +02:00
parent 2dee3a9ae9
commit 31e1347376
22 changed files with 430 additions and 409 deletions
+14 -11
View File
@@ -6,8 +6,8 @@ using System.Windows.Shapes;
namespace PamhagenSysCtrl.Helpers.Pipeline {
public class Tank : INode, ISink, ISource {
public const double WIDTH = 60;
public const double HEIGHT = 100;
public const double WIDTH = 12;
public const double HEIGHT = 20;
public double CenterX { get; set; }
public double CenterY { get; set; }
@@ -40,27 +40,30 @@ namespace PamhagenSysCtrl.Helpers.Pipeline {
public void Draw(Canvas canvas) {
_rect = new Rectangle() {
Width = WIDTH,
Height = HEIGHT,
Stroke = Brushes.Black,
StrokeThickness = 2,
Fill = Brushes.WhiteSmoke,
};
_text = new() {
Text = CapacityLiters.HasValue ? $"{Label}\n{CapacityLiters:N0}" : 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 - (CapacityLiters.HasValue ? 16 : 8));
canvas.Children.Add(_rect);
canvas.Children.Add(_text);
}
public void Scale(double scale) {
_rect?.Height = HEIGHT * scale;
_rect?.Width = WIDTH * scale;
_rect?.StrokeThickness = 2;
_rect?.SetValue(Canvas.LeftProperty, (CenterX - WIDTH / 2) * scale);
_rect?.SetValue(Canvas.TopProperty, (CenterY - HEIGHT / 2) * scale);
_text?.Width = WIDTH * scale;
_text?.FontSize = 12;
_text?.SetValue(Canvas.LeftProperty, (CenterX - WIDTH / 2) * scale);
_text?.SetValue(Canvas.TopProperty, (CenterY * scale) - (CapacityLiters.HasValue ? 16 : 8));
}
public bool IsInside(double x, double y) {
return Math.Abs(x - CenterX) <= WIDTH / 2 && Math.Abs(y - CenterY) <= HEIGHT / 2;
}