detect/detect.gui/App.axaml.cs

52 lines
2.3 KiB
C#
Raw Normal View History

2024-11-13 17:09:15 +08:00
using Avalonia;
using Avalonia.Markup.Xaml;
using Avalonia.ReactiveUI;
using detect.gui.Drivers;
using detect.gui.Services;
using detect.gui.Services.Detect;
using detect.gui.ViewModels;
2024-11-26 11:24:25 +08:00
using detect.gui.VWMS;
using detect.gui.VWS;
2024-11-13 17:09:15 +08:00
using ReactiveUI;
using Splat;
namespace detect.gui;
public class App : Application
{
public override void Initialize() => AvaloniaXamlLoader.Load(this);
public override void OnFrameworkInitializationCompleted()
{
var suspension = new AutoSuspendHelper(ApplicationLifetime!);
RxApp.SuspensionHost.CreateNewAppState = () => new MainViewModel();
RxApp.SuspensionHost.SetupDefaultSuspendResume(new NewtonsoftJsonSuspensionDriver("app.state.json"));
suspension.OnFrameworkInitializationCompleted();
2024-11-26 11:24:25 +08:00
Locator.CurrentMutable.Register(DetectUserService.Instance, typeof(DetectUserService));
Locator.CurrentMutable.Register(DetectAuthorityService.Instance, typeof(DetectAuthorityService));
Locator.CurrentMutable.Register(DetectDeviceService.Instance, typeof(DetectDeviceService));
Locator.CurrentMutable.Register( DetectTaskService.Instance, typeof(DetectTaskService));
Locator.CurrentMutable.Register(DetectTaskLogService.Instance, typeof(DetectTaskLogService));
Locator.CurrentMutable.Register(DetectTaskProgressService.Instance, typeof(DetectTaskProgressService));
Locator.CurrentMutable.Register(DetectLogService.Instance, typeof(DetectLogService));
2024-11-13 17:09:15 +08:00
2024-11-15 14:49:29 +08:00
Locator.CurrentMutable.Register(DeviceClientService.Instance, typeof(DeviceClientService));
2024-11-13 17:09:15 +08:00
Locator.Current.GetService<DeviceClientService>();
2024-11-26 11:24:25 +08:00
2025-02-07 12:16:01 +08:00
// Locator.CurrentMutable.Register(OCRService.Instance, typeof(OCRService));
// Locator.Current.GetService<OCRService>();
2024-11-26 11:24:25 +08:00
Locator.CurrentMutable.Register(MainWindowModel.Instance, typeof(MainWindowModel));
2025-02-07 12:16:01 +08:00
Locator.Current.GetService<MainWindowModel>();
2024-11-26 11:24:25 +08:00
Locator.CurrentMutable.Register(LoginControlModel.Instance, typeof(LoginControlModel));
2024-11-13 17:09:15 +08:00
2024-11-27 15:20:42 +08:00
Locator.CurrentMutable.Register(NotificationWindow.Instance, typeof(NotificationWindow));
2025-02-07 12:16:01 +08:00
Locator.CurrentMutable.Register(MainWindow.Instance, typeof(MainWindow));
2024-11-26 11:24:25 +08:00
Locator.Current.GetService<MainWindow>()!.Show();
2024-11-13 17:09:15 +08:00
base.OnFrameworkInitializationCompleted();
}
}