[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
+19 -16
View File
@@ -1,13 +1,12 @@
using System.Windows;
using System.Windows.Controls;
using System.Windows.Media;
using System.Windows.Media.Media3D;
using System.Windows.Shapes;
namespace PamhagenSysCtrl.Helpers.Pipeline {
public class Press : INode, ISink {
public const double DIAMETER = 120;
public const double DIAMETER = 24;
public double CenterX { get; set; }
public double CenterY { get; set; }
@@ -40,39 +39,43 @@ namespace PamhagenSysCtrl.Helpers.Pipeline {
public void Draw(Canvas canvas) {
_circle = new Ellipse() {
Width = DIAMETER,
Height = DIAMETER,
Stroke = Brushes.Black,
StrokeThickness = 2,
Fill = Brushes.WhiteSmoke,
};
_frame = new Polygon() {
Points = [
new(CenterX - DIAMETER / 2 - 10, CenterY), new(CenterX + DIAMETER / 2 + 10, CenterY),
new(CenterX + DIAMETER / 2 + 10, CenterY + DIAMETER / 2 + 30), new(CenterX + DIAMETER / 2 - 20, CenterY + DIAMETER / 2 + 30),
new(CenterX + DIAMETER / 2 - 20, CenterY + DIAMETER / 2 + 10), new(CenterX - DIAMETER / 2 + 20, CenterY + DIAMETER / 2 + 10),
new(CenterX - DIAMETER / 2 + 20, CenterY + DIAMETER / 2 + 30), new(CenterX - DIAMETER / 2 - 10, CenterY + DIAMETER / 2 + 30)
new(CenterX - DIAMETER / 2 - 2, CenterY), new(CenterX + DIAMETER / 2 + 2, CenterY),
new(CenterX + DIAMETER / 2 + 2, CenterY + DIAMETER / 2 + 6), new(CenterX + DIAMETER / 2 - 4, CenterY + DIAMETER / 2 + 6),
new(CenterX + DIAMETER / 2 - 4, CenterY + DIAMETER / 2 + 2), new(CenterX - DIAMETER / 2 + 4, CenterY + DIAMETER / 2 + 2),
new(CenterX - DIAMETER / 2 + 4, CenterY + DIAMETER / 2 + 6), new(CenterX - DIAMETER / 2 - 2, CenterY + DIAMETER / 2 + 6)
],
Stroke = Brushes.Black,
StrokeThickness = 2,
Fill = Brushes.WhiteSmoke,
};
_text = new() {
Text = CapacityLiters.HasValue ? $"{Label}\n{CapacityLiters:N0}" : Label,
FontSize = 14,
Width = DIAMETER,
TextAlignment = TextAlignment.Center,
VerticalAlignment = VerticalAlignment.Center,
};
_circle.SetValue(Canvas.LeftProperty, CenterX - DIAMETER / 2);
_circle.SetValue(Canvas.TopProperty, CenterY - DIAMETER / 2);
_text.SetValue(Canvas.LeftProperty, CenterX - DIAMETER / 2);
_text.SetValue(Canvas.TopProperty, CenterY - (CapacityLiters.HasValue ? 20 : 10));
canvas.Children.Add(_frame);
canvas.Children.Add(_circle);
canvas.Children.Add(_text);
}
public void Scale(double scale) {
_circle?.Width = DIAMETER * scale;
_circle?.Height = DIAMETER * scale;
_circle?.StrokeThickness = 2;
_circle?.SetValue(Canvas.LeftProperty, (CenterX - DIAMETER / 2) * scale);
_circle?.SetValue(Canvas.TopProperty, (CenterY - DIAMETER / 2) * scale);
_frame?.RenderTransform = new ScaleTransform(scale, scale);
_frame?.StrokeThickness = 2 / scale;
_text?.FontSize = 14;
_text?.Width = DIAMETER * scale;
_text?.SetValue(Canvas.LeftProperty, (CenterX - DIAMETER / 2) * scale);
_text?.SetValue(Canvas.TopProperty, (CenterY * scale) - (CapacityLiters.HasValue ? 20 : 10));
}
public bool IsInside(double x, double y) {
return Math.Sqrt(Math.Pow(CenterX - x, 2) + Math.Pow(CenterY - y, 2)) <= DIAMETER / 2 || (Math.Abs(x - CenterX) <= DIAMETER / 2 + 10 && y >= CenterY && y <= CenterY + DIAMETER / 2 + 30);
}