2024-02-08 00:54:45 +01:00
|
|
|
using Avalonia;
|
|
|
|
|
using Avalonia.Controls.ApplicationLifetimes;
|
|
|
|
|
using Avalonia.Markup.Xaml;
|
2024-02-21 02:17:33 +01:00
|
|
|
using Avalonia.Metadata;
|
2024-02-08 00:54:45 +01:00
|
|
|
|
2024-02-26 18:08:18 +01:00
|
|
|
using InkForge.Desktop.Views;
|
2024-02-09 01:23:38 +01:00
|
|
|
|
|
|
|
|
using Microsoft.Extensions.DependencyInjection;
|
|
|
|
|
|
2024-02-08 00:54:45 +01:00
|
|
|
using ReactiveUI;
|
|
|
|
|
|
2024-02-11 02:39:36 +01:00
|
|
|
using Splat;
|
|
|
|
|
using Splat.Microsoft.Extensions.DependencyInjection;
|
|
|
|
|
|
2024-02-16 02:23:58 +01:00
|
|
|
namespace InkForge.Desktop;
|
2024-02-08 00:54:45 +01:00
|
|
|
|
|
|
|
|
public partial class App : Application
|
|
|
|
|
{
|
2024-02-11 02:39:36 +01:00
|
|
|
public static readonly StyledProperty<IServiceProvider> ServiceProviderProperty
|
|
|
|
|
= AvaloniaProperty.Register<App, IServiceProvider>(
|
|
|
|
|
name: nameof(ServiceProvider),
|
|
|
|
|
coerce: OnServiceProviderChanged);
|
2024-02-08 00:54:45 +01:00
|
|
|
|
2024-02-08 01:19:26 +01:00
|
|
|
public IServiceProvider ServiceProvider => GetValue(ServiceProviderProperty);
|
2024-02-08 00:54:45 +01:00
|
|
|
|
2024-02-26 18:08:18 +01:00
|
|
|
public static void Configure(IServiceCollection services)
|
2024-02-11 02:39:36 +01:00
|
|
|
{
|
|
|
|
|
services.UseMicrosoftDependencyResolver();
|
|
|
|
|
Locator.CurrentMutable.InitializeSplat();
|
|
|
|
|
Locator.CurrentMutable.InitializeReactiveUI();
|
|
|
|
|
|
|
|
|
|
services.AddInkForge();
|
|
|
|
|
}
|
|
|
|
|
|
2024-02-08 00:54:45 +01:00
|
|
|
public override void Initialize()
|
|
|
|
|
{
|
|
|
|
|
AvaloniaXamlLoader.Load(this);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public override void OnFrameworkInitializationCompleted()
|
|
|
|
|
{
|
2024-02-09 01:23:38 +01:00
|
|
|
_ = ApplicationLifetime switch
|
|
|
|
|
{
|
2024-02-26 18:08:18 +01:00
|
|
|
IClassicDesktopStyleApplicationLifetime desktop => desktop.MainWindow = new MainWindow(),
|
2024-02-09 01:23:38 +01:00
|
|
|
_ => throw new NotSupportedException(),
|
|
|
|
|
};
|
2024-02-08 00:54:45 +01:00
|
|
|
}
|
2024-02-11 02:39:36 +01:00
|
|
|
|
|
|
|
|
private static IServiceProvider OnServiceProviderChanged(AvaloniaObject @object, IServiceProvider provider)
|
|
|
|
|
{
|
|
|
|
|
provider.UseMicrosoftDependencyResolver();
|
|
|
|
|
return provider;
|
|
|
|
|
}
|
2024-02-08 00:54:45 +01:00
|
|
|
}
|