// PRE-GENERATED (design session). Import-preview dialog with local-DB match status.
using System.Windows;
using DansoriEQ.Core.Presets;
using DansoriEQ.Core.Profiles;

namespace DansoriEQ.App;

public partial class PresetInfoWindow : Wpf.Ui.Controls.FluentWindow
{
    private readonly IProfileDbService _db;

    public PresetInfoWindow(EqPreset preset, bool matched, IProfileDbService db)
    {
        InitializeComponent();
        _db = db;

        TxtTarget.Text = $"{preset.Target.Name}  ({preset.Target.Type})";
        TxtMeta.Text = $"{preset.Target.Brand} · {preset.Target.Source} · {preset.Target.TargetCurve}".Trim(' ', '·');
        TxtBands.Text = $"{preset.Eq.Filters.Count} bands · Preamp {preset.Eq.PreampDb:0.0} dB";
        TxtNote.Text = string.IsNullOrWhiteSpace(preset.AuthorNote) ? "(없음)" : preset.AuthorNote;
        HistoryList.ItemsSource = preset.History;

        MatchOk.Visibility = matched ? Visibility.Visible : Visibility.Collapsed;
        MatchMissing.Visibility = matched ? Visibility.Collapsed : Visibility.Visible;
    }

    private void BtnUpdateDb_Click(object sender, RoutedEventArgs e)
        => new DbManagerWindow(_db) { Owner = this }.ShowDialog();

    private void Ok_Click(object sender, RoutedEventArgs e) { DialogResult = true; }
    private void Cancel_Click(object sender, RoutedEventArgs e) { DialogResult = false; }
}
