-
Notifications
You must be signed in to change notification settings - Fork 0
/
App.axaml.cs
59 lines (52 loc) · 2.21 KB
/
App.axaml.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
using System.Threading;
using Avalonia;
using Avalonia.Controls.ApplicationLifetimes;
using Avalonia.Markup.Xaml;
using ReactiveUI;
using Splat;
using VibeOne.Operations;
using VibeOne.Services;
using VibeOne.ViewModels;
using VibeOne.Views;
namespace VibeOne;
public static class DeviceInstance
{
public static bool IsRPI { get; set; }
}
public class App : Application
{
public override void Initialize()
{
AvaloniaXamlLoader.Load(this);
// Locator.CurrentMutable.RegisterLazySingleton(() => new RoutingState());
// Locator.CurrentMutable.RegisterLazySingleton(() => new TankService());
// Locator.CurrentMutable.RegisterLazySingleton(() => new SensorService());
// Locator.CurrentMutable.RegisterLazySingleton(() => new RelayService());
Locator.CurrentMutable.RegisterLazySingleton(() => new CancellationTokenSource());
SplatRegistrations.RegisterLazySingleton<RoutingState>();
SplatRegistrations.RegisterLazySingleton<TankService>();
SplatRegistrations.RegisterLazySingleton<SensorService>();
SplatRegistrations.RegisterLazySingleton<RelayService>();
SplatRegistrations.RegisterLazySingleton<IAutoOperation, Co2TankOperation>();
SplatRegistrations.SetupIOC();
}
public override void OnFrameworkInitializationCompleted()
{
if (ApplicationLifetime is IClassicDesktopStyleApplicationLifetime desktop)
{
DeviceInstance.IsRPI = false;
Console.WriteLine($"Detected Classic Destkop Style Application Lifetime");
desktop.MainWindow = new MainWindow() { DataContext = new MainWindowViewModel() };
}
else if (ApplicationLifetime is ISingleViewApplicationLifetime singleView)
{
DeviceInstance.IsRPI = true;
Console.WriteLine($"Detected Single View Style Application Lifetime");
singleView.MainView = new MainView() { DataContext = new MainWindowViewModel() };
}
base.OnFrameworkInitializationCompleted();
}
}