moved to MVVM architecture

This commit is contained in:
2026-08-08 21:24:02 +05:00
parent a1ff8cc923
commit 3d614255d8
19 changed files with 565 additions and 346 deletions
+44 -3
View File
@@ -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>();
}
}