[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
+20 -14
View File
@@ -15,6 +15,13 @@ namespace PamhagenSysCtrl.Helpers.Pipeline {
public (bool TowardEnd, double PathOffset)? Flow { get; set; }
public double FlowLength => _flowArrows?.Length ?? 0;
public double X1 => Start.CenterX;
public double Y1 => Start.CenterY;
public double X2 => Orientation ? Start.CenterX : End.CenterX;
public double Y2 => Orientation ? End.CenterY : Start.CenterY;
public double X3 => End.CenterX;
public double Y3 => End.CenterY;
private Polyline? _outer;
private Polyline? _inner;
private TextBlock? _text;
@@ -31,23 +38,15 @@ namespace PamhagenSysCtrl.Helpers.Pipeline {
}
public void Draw(Canvas canvas) {
var x1 = Start.CenterX;
var y1 = Start.CenterY;
var x2 = Orientation ? Start.CenterX : End.CenterX;
var y2 = Orientation ? End.CenterY : Start.CenterY;
var x3 = End.CenterX;
var y3 = End.CenterY;
_outer = new Polyline() {
Points = [new(x1, y1), new(x2, y2), new(x3, y3)],
StrokeThickness = 10,
Points = [new(X1, Y1), new(X2, Y2), new(X3, Y3)],
Stroke = Brushes.Black,
StrokeStartLineCap = PenLineCap.Round,
StrokeEndLineCap = PenLineCap.Round,
StrokeLineJoin = PenLineJoin.Round,
};
_inner = new Polyline() {
Points = [new(x1, y1), new(x2, y2), new(x3, y3)],
StrokeThickness = 6,
Points = [new(X1, Y1), new(X2, Y2), new(X3, Y3)],
Stroke = Brushes.DarkGray,
StrokeStartLineCap = PenLineCap.Round,
StrokeEndLineCap = PenLineCap.Round,
@@ -58,20 +57,27 @@ namespace PamhagenSysCtrl.Helpers.Pipeline {
if (Label != null) {
_text = new() {
Text = Label,
FontSize = 12,
Width = 50,
TextAlignment = TextAlignment.Center,
VerticalAlignment = VerticalAlignment.Bottom,
HorizontalAlignment = HorizontalAlignment.Center,
SnapsToDevicePixels = true,
};
_text.SetValue(Canvas.LeftProperty, _textOffsetX != null ? (Orientation ? x2 : x1) + _textOffsetX : (Orientation ? (x2 + x3) / 2 : (x1 + x2) / 2) - 25);
_text.SetValue(Canvas.TopProperty, y2 - 22);
canvas.Children.Add(_text);
}
_flowArrows = FlowArrows.Create(canvas, _inner);
}
public void Scale(double scale) {
_outer?.RenderTransform = new ScaleTransform(scale, scale);
_outer?.StrokeThickness = 10 / scale;
_inner?.RenderTransform = new ScaleTransform(scale, scale);
_inner?.StrokeThickness = 6 / scale;
_text?.FontSize = 12;
_text?.Width = 10 * scale;
_text?.SetValue(Canvas.LeftProperty, (_textOffsetX != null ? (Orientation ? X2 : X1) + _textOffsetX : (Orientation ? (X2 + X3) / 2 : (X1 + X2) / 2) - 5) * scale);
_text?.SetValue(Canvas.TopProperty, Y2 * scale - 22);
}
public void Update() {
_inner?.Stroke = Highlight ?? Brushes.DarkGray;
_flowArrows?.Update(Flow);