Files
pamhagen-sysctrl/PamhagenSysCtrl/Helpers/Pipeline/Pipe.cs
T
2026-07-16 00:09:26 +02:00

56 lines
1.9 KiB
C#

using System.Windows.Controls;
using System.Windows.Media;
using System.Windows.Shapes;
namespace PamhagenSysCtrl.Helpers.Pipeline {
public class Pipe : IEdge {
public INode Start { get; set; }
public INode End { get; set; }
public bool IsTwoWay { get; set; }
public bool Orientation { get; set; }
public Brush? Highlight { get; set; }
private Polyline? _outer;
private Polyline? _inner;
public Pipe(INode start, INode end, bool orientation = false, bool twoWay = false) {
Start = start;
End = end;
Orientation = orientation;
IsTwoWay = twoWay;
}
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,
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,
Stroke = Brushes.DarkGray,
StrokeStartLineCap = PenLineCap.Round,
StrokeEndLineCap = PenLineCap.Round,
StrokeLineJoin = PenLineJoin.Round,
};
canvas.Children.Add(_outer);
canvas.Children.Add(_inner);
}
public void Update() {
_inner?.Stroke = Highlight ?? Brushes.DarkGray;
}
}
}