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

This commit is contained in:
2026-08-13 18:15:58 +02:00
parent 2dee3a9ae9
commit 36c1ced254
24 changed files with 649 additions and 537 deletions
@@ -6,8 +6,8 @@ using System.Windows.Shapes;
namespace PamhagenSysCtrl.Helpers.Pipeline {
public class EncasedAuger : INode {
public const double WIDTH = 80;
public const double HEIGHT = 20;
public const double WIDTH = 16;
public const double HEIGHT = 4;
public double CenterX { get; set; }
public double CenterY { get; set; }
@@ -29,8 +29,9 @@ namespace PamhagenSysCtrl.Helpers.Pipeline {
protected Func<bool> CallbackActive;
private bool _animationActive;
private Shape? _inner;
private Shape? _outer;
private Canvas? _canvas;
private Rectangle? _inner;
private Rectangle? _outer;
private Auger? _auger;
private TextBlock? _text;
@@ -46,41 +47,49 @@ namespace PamhagenSysCtrl.Helpers.Pipeline {
}
public void Draw(Canvas canvas) {
var c = new Canvas() {
RenderTransform = new RotateTransform(Angle, WIDTH / 2, HEIGHT / 2),
_canvas = new Canvas() {
RenderTransform = new RotateTransform(Angle),
};
_outer = new Rectangle() {
Width = WIDTH,
Height = HEIGHT,
Fill = Brushes.Black,
};
_inner = new Rectangle() {
Width = WIDTH,
Height = HEIGHT - 4,
Fill = Brushes.WhiteSmoke,
};
c.SetValue(Canvas.LeftProperty, CenterX - WIDTH / 2);
c.SetValue(Canvas.TopProperty, CenterY - HEIGHT / 2);
_inner.SetValue(Canvas.TopProperty, 2.0);
c.Children.Add(_outer);
c.Children.Add(_inner);
canvas.Children.Add(c);
_canvas.Children.Add(_outer);
_canvas.Children.Add(_inner);
canvas.Children.Add(_canvas);
_text = new() {
Text = Label,
Width = WIDTH,
FontSize = 12,
TextAlignment = TextAlignment.Center,
VerticalAlignment = VerticalAlignment.Center,
};
_text.SetValue(Canvas.LeftProperty, CenterX - WIDTH / 2);
_text.SetValue(Canvas.TopProperty, CenterY + HEIGHT / 2);
canvas.Children.Add(_text);
_auger = new Auger(CenterX, CenterY, WIDTH, 12, Angle);
_auger = new Auger(CenterX, CenterY, WIDTH, 2.4, Angle);
_auger.Draw(canvas);
}
public void Scale(double scale) {
var border = Graph.ToBorder(scale);
_canvas?.SetValue(Canvas.LeftProperty, (CenterX - WIDTH / 2) * scale);
_canvas?.SetValue(Canvas.TopProperty, (CenterY - HEIGHT / 2) * scale);
_canvas?.RenderTransform = new RotateTransform(Angle, WIDTH / 2 * scale, HEIGHT / 2 * scale);
_outer?.Width = WIDTH * scale;
_outer?.Height = HEIGHT * scale;
_inner?.Width = WIDTH * scale;
_inner?.Height = HEIGHT * scale - border * 2;
_inner?.SetValue(Canvas.TopProperty, border);
_text?.FontSize = 12;
_text?.Width = WIDTH * scale;
_text?.SetValue(Canvas.LeftProperty, (CenterX - WIDTH / 2) * scale);
_text?.SetValue(Canvas.TopProperty, (CenterY + HEIGHT / 2) * scale);
_auger?.Scale(scale);
}
public bool IsInside(double x, double y) {
return Math.Sqrt(Math.Pow(CenterX - x, 2) + Math.Pow(CenterY - y, 2)) <= WIDTH / 2;
}