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;
|
|
|
|
using detect.gui.Views;
|
|
|
|
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();
|
|
|
|
|
|
|
|
Locator.CurrentMutable.RegisterConstant<IScreen>(RxApp.SuspensionHost.GetAppState<MainViewModel>());
|
|
|
|
Locator.CurrentMutable.Register(() => new LoginView(), typeof(IViewFor<LoginViewModel>));
|
|
|
|
Locator.CurrentMutable.Register(() => new HomeView(), typeof(IViewFor<HomeViewModel>));
|
|
|
|
Locator.CurrentMutable.Register(() => new DetectTaskView(), typeof(IViewFor<DetectTaskViewModel>));
|
|
|
|
Locator.CurrentMutable.Register(() => new DeviceView(), typeof(IViewFor<DeviceViewModel>));
|
|
|
|
Locator.CurrentMutable.Register(() => new LogView(), typeof(IViewFor<LogViewModel>));
|
|
|
|
Locator.CurrentMutable.Register(() => new UserView(), typeof(IViewFor<UserViewModel>));
|
|
|
|
|
|
|
|
Locator.CurrentMutable.Register(() => new DetectUserService(), typeof(DetectUserService));
|
2024-11-14 17:11:43 +08:00
|
|
|
Locator.CurrentMutable.Register(() => new DetectAuthorityService(), typeof(DetectAuthorityService));
|
2024-11-13 17:09:15 +08:00
|
|
|
Locator.CurrentMutable.Register(() => new DetectDeviceService(), typeof(DetectDeviceService));
|
|
|
|
Locator.CurrentMutable.Register(() => new DetectTaskService(), typeof(DetectTaskService));
|
2024-11-14 17:11:43 +08:00
|
|
|
Locator.CurrentMutable.Register(() => new DetectTaskLogService(), typeof(DetectTaskLogService));
|
|
|
|
Locator.CurrentMutable.Register(() => new DetectTaskProgressService(), typeof(DetectTaskProgressService));
|
2024-11-13 17:09:15 +08:00
|
|
|
Locator.CurrentMutable.Register(() => new DetectLogService(), typeof(DetectLogService));
|
|
|
|
|
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>();
|
|
|
|
|
|
|
|
new MainView { DataContext = Locator.Current.GetService<IScreen>() }.Show();
|
|
|
|
|
|
|
|
base.OnFrameworkInitializationCompleted();
|
|
|
|
}
|
|
|
|
}
|