Add pipe labels
Test / Run tests (push) Successful in 13s

This commit is contained in:
2026-08-07 12:30:11 +02:00
parent 96bb51807d
commit dbcf807154
6 changed files with 40 additions and 17 deletions
+21 -1
View File
@@ -1,3 +1,4 @@
using System.Windows;
using System.Windows.Controls;
using System.Windows.Media;
using System.Windows.Shapes;
@@ -7,6 +8,7 @@ namespace PamhagenSysCtrl.Helpers.Pipeline {
public INode Start { get; set; }
public INode End { get; set; }
public string? Label { get; set; }
public bool IsTwoWay { get; set; }
public bool Orientation { get; set; }
public Brush? Highlight { get; set; }
@@ -15,11 +17,15 @@ namespace PamhagenSysCtrl.Helpers.Pipeline {
private Polyline? _outer;
private Polyline? _inner;
private TextBlock? _text;
private FlowArrows? _flowArrows;
private double? _textOffsetX;
public Pipe(INode start, INode end, bool orientation = false, bool twoWay = false) {
public Pipe(INode start, INode end, string? label = null, bool orientation = false, bool twoWay = false, double? textOffsetX = null) {
Start = start;
End = end;
Label = label;
_textOffsetX = textOffsetX;
Orientation = orientation;
IsTwoWay = twoWay;
}
@@ -49,6 +55,20 @@ namespace PamhagenSysCtrl.Helpers.Pipeline {
};
canvas.Children.Add(_outer);
canvas.Children.Add(_inner);
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);
}