47 lines
1.3 KiB
C#
47 lines
1.3 KiB
C#
using System.Windows;
|
|
using Heisig.HMI.AdsManager;
|
|
using Microsoft.Extensions.DependencyInjection;
|
|
using Microsoft.Extensions.Hosting;
|
|
using TcEventLoggerAdsProxyLib;
|
|
|
|
namespace UniperHMI;
|
|
|
|
public partial class App : Application
|
|
{
|
|
public static IHost? AppHost { get; private set; }
|
|
|
|
public App()
|
|
{
|
|
AppHost = Host.CreateDefaultBuilder()
|
|
.ConfigureServices((hostContext, services) =>
|
|
{
|
|
services.AddSingleton<MainWindow>();
|
|
services.AddSingleton<MainWindowVM>();
|
|
services.AddSingleton<IAdsManager, AdsManager>();
|
|
services.AddTransient<AutomaticModePageVM>();
|
|
services.AddTransient<BatteryOverviewPageVM>();
|
|
services.AddTransient<StringOverviewPageVM>();
|
|
services.AddTransient<ModuleOverviewPageVM>();
|
|
services.AddSingleton<TcEventLogger>();
|
|
})
|
|
.Build();
|
|
}
|
|
|
|
protected override async void OnStartup(StartupEventArgs e)
|
|
{
|
|
await AppHost!.StartAsync();
|
|
|
|
var startupForm = AppHost.Services.GetRequiredService<MainWindow>();
|
|
startupForm.Show();
|
|
|
|
base.OnStartup(e);
|
|
}
|
|
|
|
protected override async void OnExit(ExitEventArgs e)
|
|
{
|
|
await AppHost!.StopAsync();
|
|
|
|
base.OnExit(e);
|
|
}
|
|
}
|