You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
49 lines
1.2 KiB
49 lines
1.2 KiB
using Microsoft.Extensions.DependencyInjection;
|
|
using Microsoft.Extensions.Hosting;
|
|
using MultiTerm.Core.ViewModel;
|
|
using Common.StartupHelpers;
|
|
using System.Windows;
|
|
using MultiTerm.Core.Common;
|
|
using MultiTerm.Core.Helpers;
|
|
|
|
namespace MultiTerm.Wpf;
|
|
|
|
public partial class App : Application
|
|
{
|
|
public static IHost? AppHost { get; private set; }
|
|
|
|
public App()
|
|
{
|
|
// create dependency injection host
|
|
AppHost = Host.CreateDefaultBuilder()
|
|
.ConfigureServices((hostContext, services) =>
|
|
{
|
|
services.AddSingleton<MainWindow>();
|
|
|
|
// viewmodels
|
|
services.AddSingleton<ShellViewModel>();
|
|
|
|
// application specific
|
|
services.AddTerminalViewModelFactory();
|
|
})
|
|
.Build();
|
|
}
|
|
|
|
protected override async void OnStartup(StartupEventArgs e)
|
|
{
|
|
await AppHost!.StartAsync();
|
|
|
|
// instanciate startup form and show
|
|
var startupForm = AppHost.Services.GetRequiredService<MainWindow>();
|
|
startupForm.Show();
|
|
|
|
base.OnStartup(e);
|
|
}
|
|
|
|
protected override async void OnExit(ExitEventArgs e)
|
|
{
|
|
await AppHost!.StopAsync();
|
|
base.OnExit(e);
|
|
}
|
|
|
|
}
|
|
|