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

namespace TraceCad.App.Tools;

public sealed class TrimTool()
    : EndpointEditTool(
        "Trim",
        "Trim: click the green endpoint you want to shorten",
        "Trim: hover the cutting boundary, then click",
        "Trim: endpoint shortened",
        TryTrim)
{
    private static Entity? TryTrim(
        Entity subject,
        Point2 subjectPick,
        Entity boundary,
        Point2 boundaryPick,
        bool preview)
    {
        return EntityEditing.TryTrimEndpoint(subject, subjectPick, boundary, boundaryPick, out var replacement)
            ? replacement
            : null;
    }
}
