📄 ui/src/Views/GraphConnection.cs
using Avalonia;
using Avalonia.Controls;
using Avalonia.Media;
using Cfa.Ui.Graph;

namespace Cfa.Ui.Views;

public sealed class GraphConnection : Control
{
    public static readonly StyledProperty<GraphEdge?> EdgeProperty = AvaloniaProperty.Register<
        GraphConnection,
        GraphEdge?
    >(nameof(Edge));

    static GraphConnection() => AffectsRender<GraphConnection>(EdgeProperty);

    public GraphEdge? Edge
    {
        get => GetValue(EdgeProperty);
        set => SetValue(EdgeProperty, value);
    }

    public override void Render(DrawingContext context)
    {
        base.Render(context);
        if (Edge is not { } edge)
        {
            return;
        }
        var brush = Brushes.SkyBlue;
        context.DrawGeometry(null, new Pen(brush, edge.Thickness), edge.CreateCurveGeometry());
        context.DrawGeometry(brush, null, edge.CreateArrowGeometry());
    }
}