moved to MVVM architecture
This commit is contained in:
+44
-3
@@ -1,10 +1,51 @@
|
||||
using System.Windows;
|
||||
using System.Windows;
|
||||
using CursorLang.Services;
|
||||
using CursorLang.ViewModels;
|
||||
using CursorLang.Views;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
|
||||
namespace CursorLang;
|
||||
|
||||
/// <summary>
|
||||
/// Interaction logic for App.xaml
|
||||
/// Композиционный корень: собирает контейнер и запускает главное окно.
|
||||
/// </summary>
|
||||
public partial class App : Application
|
||||
{
|
||||
}
|
||||
private ServiceProvider? _services;
|
||||
|
||||
protected override void OnStartup(StartupEventArgs e)
|
||||
{
|
||||
base.OnStartup(e);
|
||||
|
||||
var services = new ServiceCollection();
|
||||
ConfigureServices(services);
|
||||
_services = services.BuildServiceProvider();
|
||||
|
||||
MainWindow = _services.GetRequiredService<MainWindow>();
|
||||
MainWindow.Show();
|
||||
|
||||
_services.GetRequiredService<IKeyboardLayoutService>().Start();
|
||||
}
|
||||
|
||||
protected override void OnExit(ExitEventArgs e)
|
||||
{
|
||||
// Контейнер сам остановит таймеры и закроет окно подсказки
|
||||
_services?.Dispose();
|
||||
base.OnExit(e);
|
||||
}
|
||||
|
||||
private static void ConfigureServices(IServiceCollection services)
|
||||
{
|
||||
services.AddSingleton(new KeyboardLayoutOptions());
|
||||
services.AddSingleton(new PopupOptions());
|
||||
|
||||
services.AddSingleton<IKeyboardLayoutService, KeyboardLayoutService>();
|
||||
services.AddSingleton<ILayoutPopupService, LayoutPopupService>();
|
||||
|
||||
services.AddSingleton<LayoutPopupViewModel>();
|
||||
services.AddSingleton<MainViewModel>();
|
||||
|
||||
services.AddSingleton<LayoutPopupWindow>();
|
||||
services.AddSingleton<MainWindow>();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user