Add Avalonia based desktop client
Squashed commit of the following: commit 0bfba90cd31bc9d401bf25cd479f6aef314988d5 Author: luxick <git@luxick.de> Date: Mon Mar 2 21:58:32 2020 +0100 Add view switching with Global.Navigator commit e0f535152aaa31fc2d4b6712459d208e27831696 Author: luxick <git@luxick.de> Date: Mon Mar 2 20:53:01 2020 +0100 Make ViewModels require api client commit f66c9148fdb1c34a2b92321dfc7a053894f381ce Author: luxick <git@luxick.de> Date: Mon Mar 2 20:51:35 2020 +0100 Update framework to core 3.1 commit 273b2940f043d889c70e8d7a69a54d6b4b200a62 Author: luxick <git@luxick.de> Date: Mon Mar 2 20:49:43 2020 +0100 Player and Season View/Models commit b3325b176740c403381009882c98a401ece05d0a Author: luxick <git@luxick.de> Date: Mon Mar 2 20:44:55 2020 +0100 Add EstusShots.Avalonia project
This commit is contained in:
44
EstusShots.Avalonia/App.xaml.cs
Normal file
44
EstusShots.Avalonia/App.xaml.cs
Normal file
@@ -0,0 +1,44 @@
|
||||
using Avalonia;
|
||||
using Avalonia.Controls.ApplicationLifetimes;
|
||||
using Avalonia.Markup.Xaml;
|
||||
using EstusShots.Avalonia.ViewModels;
|
||||
using EstusShots.Avalonia.Views;
|
||||
using EstusShots.Client;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
|
||||
namespace EstusShots.Avalonia
|
||||
{
|
||||
public class App : Application
|
||||
{
|
||||
public override void Initialize()
|
||||
{
|
||||
AvaloniaXamlLoader.Load(this);
|
||||
}
|
||||
|
||||
public override void OnFrameworkInitializationCompleted()
|
||||
{
|
||||
if (ApplicationLifetime is IClassicDesktopStyleApplicationLifetime desktop)
|
||||
{
|
||||
// The Application uses a single shared API client.
|
||||
var apiClient = new EstusShotsClient("http://localhost:5000/api/");
|
||||
|
||||
// Add all our services to the DI Container
|
||||
var serviceProvider = new ServiceCollection()
|
||||
.AddSingleton(apiClient)
|
||||
.AddViewModels()
|
||||
.BuildServiceProvider();
|
||||
|
||||
var main = new MainWindowViewModel(serviceProvider);
|
||||
Global.Navigator = new Navigator(main);
|
||||
Global.Navigator.GoTo<SeasonsViewModel>();
|
||||
|
||||
desktop.MainWindow = new MainWindow
|
||||
{
|
||||
DataContext = main,
|
||||
};
|
||||
}
|
||||
|
||||
base.OnFrameworkInitializationCompleted();
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user