using Avalonia.Controls.ApplicationLifetimes;
using Avalonia.Markup.Xaml;
using Microsoft.Extensions.DependencyInjection;

namespace ImageCatalog_2;

public partial class AvaloniaApp : Avalonia.Application
{
    public override void Initialize() => AvaloniaXamlLoader.Load(this);

    public override void OnFrameworkInitializationCompleted()
    {
        if (ApplicationLifetime is IClassicDesktopStyleApplicationLifetime desktop)
        {
            var model = Program.ServiceProvider.GetRequiredService<DataModel>();
            desktop.MainWindow = new AvaloniaMainWindow(model);
        }
        base.OnFrameworkInitializationCompleted();
    }
}
