using System.Windows.Controls; using System.Windows.Media; using System.Windows.Shapes; namespace PamhagenSysCtrl.Helpers.Pipeline { public class Inlet : IEdge { public INode Start { get; set; } public INode End => Sink; public ISink Sink { get; set; } public bool IsTwoWay => false; public bool Orientation { get; set; } public Brush? Highlight { get; set; } private Line? _outer1; private Line? _outer2; private Line? _inner1; private Line? _inner2; public Inlet(INode start, ISink end, bool orientation = false) { Start = start; Sink = end; Orientation = orientation; } public void Draw(Canvas canvas) { var x1 = Start.CenterX; var y1 = Start.CenterY; var x2 = Start.CenterX; var y2 = Sink.TopY - 10; var x3 = Start.CenterX + (Orientation ? -20 : 20); var y3 = Sink.TopY + 20; _outer1 = new Line() { X1 = x1, Y1 = y1, X2 = x2, Y2 = y2, StrokeThickness = 10, Stroke = Brushes.Black, StrokeStartLineCap = PenLineCap.Round, StrokeEndLineCap = PenLineCap.Round, }; _inner1 = new Line() { X1 = x1, Y1 = y1, X2 = x2, Y2 = y2, StrokeThickness = 6, Stroke = Brushes.DarkGray, StrokeStartLineCap = PenLineCap.Round, StrokeEndLineCap = PenLineCap.Round, }; _outer2 = new Line() { X1 = x2, Y1 = y2, X2 = x3, Y2 = y3, StrokeThickness = 10, Stroke = Brushes.Black, StrokeStartLineCap = PenLineCap.Round, StrokeEndLineCap = PenLineCap.Flat, }; _inner2 = new Line() { X1 = x2, Y1 = y2, X2 = x3, Y2 = y3, StrokeThickness = 6, Stroke = Brushes.DarkGray, StrokeStartLineCap = PenLineCap.Round, StrokeEndLineCap = PenLineCap.Flat, }; canvas.Children.Add(_outer1); canvas.Children.Add(_outer2); canvas.Children.Add(_inner1); canvas.Children.Add(_inner2); } public void Update() { _inner1?.Stroke = Highlight ?? Brushes.DarkGray; _inner2?.Stroke = Highlight ?? Brushes.DarkGray; } } }