-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathApp.xaml.cs
98 lines (84 loc) · 4 KB
/
App.xaml.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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
// Ignore Spelling: App
using DnDManager.ViewModels;
using DnDManager.Services;
using System;
using System.Windows;
using DnDManager.Stores;
using System.Reflection.Metadata;
using DnDManager.Models;
namespace DnDManager
{
/// <summary>
/// Interaction logic for App.xaml
/// </summary>
public partial class App : Application
{
private readonly NavigationStore _navigationStore;
private readonly UserStore _userStore;
private readonly DatabaseProvider _dbProvider;
public App()
{
_navigationStore = new NavigationStore();
_userStore = new UserStore();
_dbProvider = DatabaseProvider.Create();
}
protected override void OnStartup(StartupEventArgs e)
{
_navigationStore.CurrentViewModel = CreateLoginViewModel();
MainWindow = new MainWindow()
{
DataContext = new MainViewModel(_navigationStore)
};
MainWindow.Show();
base.OnStartup(e);
}
private GamesBrowserViewModel CreateGameBrowserViewModel()
{
return new GamesBrowserViewModel(_userStore, _dbProvider,
new NavigationService<MainPlayerViewModel>(_navigationStore, CreateMainPlayerViewModel),
new NavigationService<FindGameViewModel>(_navigationStore, CreateFindGameViewModel));
}
private FindGameViewModel CreateFindGameViewModel()
{
return new FindGameViewModel(_userStore, _dbProvider,
new NavigationService<GamesBrowserViewModel>(_navigationStore, CreateGameBrowserViewModel));
}
private LoginViewModel CreateLoginViewModel()
{
return new LoginViewModel(_dbProvider, _userStore,
new NavigationService<RegistrationViewModel>(_navigationStore, CreateRegistrationViewModel),
new NavigationService<MainPlayerViewModel>(_navigationStore, CreateMainPlayerViewModel));
}
private MainPlayerViewModel CreateMainPlayerViewModel()
{
return new MainPlayerViewModel(_userStore,
new ParameterNavigationService<Character, CharacterModificationViewModel>(_navigationStore,
(character) => CreateCharacterModificationViewModel(character)),
new NavigationService<CharacterBrowserViewModel>(_navigationStore, CreateCharacterBrowserViewModel),
new NavigationService<CreateGameViewModel>(_navigationStore, CreateCreateGameViewModel),
new NavigationService<GamesBrowserViewModel>(_navigationStore, CreateGameBrowserViewModel));
}
private CreateGameViewModel CreateCreateGameViewModel()
{
return new CreateGameViewModel(_dbProvider, _userStore,
new NavigationService<MainPlayerViewModel>(_navigationStore, CreateMainPlayerViewModel));
}
private CharacterModificationViewModel CreateCharacterModificationViewModel(Character character)
{
return new CharacterModificationViewModel(_userStore, character, _dbProvider,
new NavigationService<MainPlayerViewModel>(_navigationStore, CreateMainPlayerViewModel));
}
private CharacterBrowserViewModel CreateCharacterBrowserViewModel()
{
return new CharacterBrowserViewModel(_userStore, _dbProvider,
new NavigationService<MainPlayerViewModel>(_navigationStore, CreateMainPlayerViewModel),
new ParameterNavigationService<Character, CharacterModificationViewModel>(_navigationStore,
(character) => CreateCharacterModificationViewModel(character)));
}
private RegistrationViewModel CreateRegistrationViewModel()
{
return new RegistrationViewModel(_dbProvider,
new NavigationService<LoginViewModel>(_navigationStore, CreateLoginViewModel));
}
}
}