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

This commit is contained in:
2026-08-13 23:47:43 +02:00
parent 2dee3a9ae9
commit c7f90889d8
24 changed files with 764 additions and 564 deletions
+18 -14
View File
@@ -6,8 +6,8 @@ using System.Windows.Shapes;
namespace PamhagenSysCtrl.Helpers.Pipeline {
public class Trough : INode, ISource {
public const double WIDTH = 100;
public const double HEIGHT = 60;
public const double WIDTH = 20;
public const double HEIGHT = 12;
public double CenterX { get; set; }
public double CenterY { get; set; }
@@ -35,33 +35,37 @@ namespace PamhagenSysCtrl.Helpers.Pipeline {
public void Draw(Canvas canvas) {
_outer = new Rectangle() {
Width = WIDTH,
Height = HEIGHT,
Fill = Brushes.Black,
};
_inner = new Rectangle() {
Width = WIDTH - 4,
Height = HEIGHT - 2,
Fill = Brushes.WhiteSmoke,
};
_text = new() {
Text = Label,
FontSize = 14,
Width = WIDTH,
TextAlignment = TextAlignment.Center,
VerticalAlignment = VerticalAlignment.Center,
};
_outer.SetValue(Canvas.LeftProperty, CenterX - WIDTH / 2);
_outer.SetValue(Canvas.TopProperty, CenterY - HEIGHT / 2);
_inner.SetValue(Canvas.LeftProperty, CenterX - WIDTH / 2 + 2);
_inner.SetValue(Canvas.TopProperty, CenterY - HEIGHT / 2);
_text.SetValue(Canvas.LeftProperty, CenterX - WIDTH / 2);
_text.SetValue(Canvas.TopProperty, CenterY - 10);
canvas.Children.Add(_outer);
canvas.Children.Add(_inner);
canvas.Children.Add(_text);
}
public void Scale(double scale) {
var border = Graph.ToBorder(scale);
_outer?.Width = WIDTH * scale;
_outer?.Height = HEIGHT * scale;
_inner?.Width = WIDTH * scale - border * 2;
_inner?.Height = HEIGHT * scale - border;
_text?.Width = WIDTH * scale;
_text?.FontSize = 14;
_outer?.SetValue(Canvas.LeftProperty, (CenterX - WIDTH / 2) * scale);
_outer?.SetValue(Canvas.TopProperty, (CenterY - HEIGHT / 2) * scale);
_inner?.SetValue(Canvas.LeftProperty, (CenterX - WIDTH / 2) * scale + border);
_inner?.SetValue(Canvas.TopProperty, (CenterY - HEIGHT / 2) * scale);
_text?.SetValue(Canvas.LeftProperty, (CenterX - WIDTH / 2) * scale);
_text?.SetValue(Canvas.TopProperty, (CenterY * scale) - 10);
}
public bool IsInside(double x, double y) {
return Math.Abs(x - CenterX) <= WIDTH / 2 && Math.Abs(y - CenterY) <= HEIGHT / 2;
}