using Avalonia;
using CommunityToolkit.Mvvm.ComponentModel;

namespace InABox.Avalonia.Converters;

public partial class DoubleToCornerRadiusConverter : AbstractConverter<double?,CornerRadius>
{
    [ObservableProperty] 
    private double _ratio;
    
    protected override CornerRadius Convert(double? value, object? parameter = null)
    {
        return value.HasValue 
            ? new CornerRadius(value.Value * Ratio) 
            : parameter is CornerRadius param 
                ? new CornerRadius(param.TopLeft * Ratio, param.TopRight * Ratio, param.BottomRight * Ratio, param.BottomLeft * Ratio) 
                : new CornerRadius();
    }
}

public partial class DoubleToThicknessConverter : AbstractConverter<double?,Thickness>
{
    [ObservableProperty] 
    private double _ratio;
    
    protected override Thickness Convert(double? value, object? parameter = null)
    {
        return value.HasValue 
            ? new Thickness(value.Value * Ratio) 
            : parameter is Thickness param 
                ? new Thickness(param.Left * Ratio, param.Top * Ratio, param.Right * Ratio, param.Bottom * Ratio) 
                : new Thickness();
    }
}