using System.Windows.Controls; using System.Windows.Media; using System.Windows.Shapes; namespace PamhagenSysCtrl.Helpers.Pipeline { public class Outlet : IEdge { public const double POINT = 3.2; public INode Start => Source; public INode End { get; set; } public ISource Source { get; set; } public string? Label => null; public bool IsTwoWay => false; public bool Orientation { get; set; } public Brush? Highlight { get; set; } public (bool TowardEnd, double PathOffset)? Flow { get; set; } public double FlowLength => _flowArrows?.Length ?? 0; public double X1 => Start.CenterX; public double Y1 => Source.BottomY; 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 Polygon? _hopper; private FlowArrows? _flowArrows; private Polyline? _outer; private Polyline? _inner; public Outlet(ISource start, INode end) { Source = start; End = end; Orientation = true; } public void Draw(Canvas canvas) { _hopper = new Polygon() { Points = [new(X1 - POINT, Y1 - 0.4), new(X1 + POINT, Y1 - 0.4), new(X1, Y1 + POINT)], Fill = Brushes.DarkGray, Stroke = Brushes.Black, }; _outer = new Polyline() { Points = [new(X1, Y1), new(X2, Y2), new(X3, Y3)], Stroke = Brushes.Black, StrokeStartLineCap = PenLineCap.Round, StrokeEndLineCap = PenLineCap.Round, }; _inner = new Polyline() { Points = [new(X1, Y1), new(X2, Y2), new(X3, Y3)], Stroke = Brushes.DarkGray, StrokeStartLineCap = PenLineCap.Round, StrokeEndLineCap = PenLineCap.Round, }; canvas.Children.Add(_outer); canvas.Children.Add(_hopper); canvas.Children.Add(_inner); _flowArrows = FlowArrows.Create(canvas, _inner); } public void Scale(double scale) { _hopper?.RenderTransform = new ScaleTransform(scale, scale); _hopper?.StrokeThickness = 2 / scale; _outer?.RenderTransform = new ScaleTransform(scale, scale); _outer?.StrokeThickness = 10 / scale; _inner?.RenderTransform = new ScaleTransform(scale, scale); _inner?.StrokeThickness = 6 / scale; } public void Update() { _inner?.Stroke = Highlight ?? Brushes.DarkGray; _hopper?.Fill = Highlight ?? Brushes.DarkGray; _flowArrows?.Update(Flow); } } }