using System.Windows;
using System.Windows.Input;

namespace AxCopilot.Views;

public partial class LargeTypeWindow : Window
{
    private readonly string _text;

    public LargeTypeWindow(string text)
    {
        _text = text;
        InitializeComponent();
    }

    private void Window_Loaded(object sender, RoutedEventArgs e)
    {
        LargeText.Text = _text;

        // 텍스트 길이에 따라 기본 폰트 크기 결정
        // (Viewbox가 최종 크기를 조정하지만, 줄바꿈 결정을 위해 명시적 크기 필요)
        LargeText.FontSize = _text.Length switch
        {
            <= 10  => 120,
            <= 30  => 96,
            <= 60  => 72,
            <= 120 => 52,
            _      => 38,
        };

        Focus();
    }

    private void Window_KeyDown(object sender, KeyEventArgs e)
    {
        if (e.Key == Key.Escape) Close();
    }

    private void Window_MouseDown(object sender, MouseButtonEventArgs e)
    {
        Close();
    }

    private void Close_Click(object sender, RoutedEventArgs e)
    {
        Close();
    }
}
