using TraceCad.Core.Geometry;
using TraceCad.Core.Model;

namespace TraceCad.App.Tools;

public sealed class ExtendTool()
    : EndpointEditTool(
        "Extend",
        "Extend: click the green endpoint you want to lengthen",
        "Extend: hover the target boundary, then click",
        "Extend: endpoint lengthened",
        TryExtend)
{
    private static Entity? TryExtend(
        Entity subject,
        Point2 subjectPick,
        Entity boundary,
        Point2 boundaryPick,
        bool preview)
    {
        return EntityEditing.TryExtendEndpoint(subject, subjectPick, boundary, boundaryPick, out var replacement)
            ? replacement
            : null;
    }
}
