using System.Windows;
using System.Windows.Controls;
using System.Windows.Media;

namespace Noctalk.UI.Components.Label;

public sealed class Noctalk_label : TextBlock
{
    public static readonly DependencyProperty SizeProperty = DependencyProperty.Register(
        nameof(Size),
        typeof(Noctalk_label_size),
        typeof(Noctalk_label),
        new PropertyMetadata(Noctalk_label_size.medium, UI__label__property_changed));

    public static readonly DependencyProperty ColorProperty = DependencyProperty.Register(
        nameof(Color),
        typeof(Noctalk_label_color),
        typeof(Noctalk_label),
        new PropertyMetadata(Noctalk_label_color.standard, UI__label__property_changed));

    public Noctalk_label_size Size
    {
        get => (Noctalk_label_size)GetValue(SizeProperty);
        set => SetValue(SizeProperty, value);
    }

    public Noctalk_label_color Color
    {
        get => (Noctalk_label_color)GetValue(ColorProperty);
        set => SetValue(ColorProperty, value);
    }

    public Noctalk_label()
    {
        FontWeight = FontWeights.Bold;
        VerticalAlignment = VerticalAlignment.Center;
        UI__label__apply();
    }

    private static void UI__label__property_changed(DependencyObject Dependency_object, DependencyPropertyChangedEventArgs Event_args)
    {
        ((Noctalk_label)Dependency_object).UI__label__apply();
    }

    private void UI__label__apply()
    {
        FontSize = Size switch
        {
            Noctalk_label_size.small => 12,
            Noctalk_label_size.large => 18,
            Noctalk_label_size.very_large => 26,
            _ => 14
        };

        Foreground = Color == Noctalk_label_color.red_light
            ? new SolidColorBrush(System.Windows.Media.Color.FromRgb(255, 70, 70))
            : new SolidColorBrush(System.Windows.Media.Color.FromRgb(73, 217, 255));
    }
}
