root / GES_PAC / ViewModel / SetListViewModel.cs @ e837cdf1
Historique | Voir | Annoter | Télécharger (2,249 ko)
1 |
using System.Windows.Input; |
---|---|
2 |
using GES_PAC.View; |
3 |
|
4 |
|
5 |
namespace GES_PAC.ViewModel |
6 |
{ |
7 |
public class SetListViewModel : BaseViewModel |
8 |
{ |
9 |
#region Attributs |
10 |
private bool _hasLastSet = false; |
11 |
public string _lastSetText; |
12 |
#endregion |
13 |
|
14 |
#region Propriétés |
15 |
public bool HasLastSet |
16 |
{ |
17 |
get => _hasLastSet; |
18 |
set |
19 |
{ |
20 |
SetProperty(ref _hasLastSet, value); |
21 |
OnPropertyChanged(); |
22 |
} |
23 |
} |
24 |
public string LastSetText |
25 |
{ |
26 |
get => _lastSetText; |
27 |
set |
28 |
{ |
29 |
SetProperty(ref _lastSetText, value); |
30 |
OnPropertyChanged(); |
31 |
} |
32 |
} |
33 |
#endregion |
34 |
|
35 |
#region Commandes |
36 |
public ICommand GoToCreateSetCommand { get; } |
37 |
public ICommand GoToLastSetCommand { get; } |
38 |
public ICommand GoToEndDayCommand { get; } |
39 |
#endregion |
40 |
|
41 |
#region Constructeur |
42 |
public SetListViewModel() |
43 |
{ |
44 |
GoToCreateSetCommand = new Command(async () => await GoToCreateSetPage()); |
45 |
GoToLastSetCommand = new Command(async () => await GoToLastSetPage()); |
46 |
GoToEndDayCommand = new Command(async () => await GoToEndDayPage()); |
47 |
|
48 |
GetLastSet(); |
49 |
} |
50 |
#endregion |
51 |
|
52 |
#region Méthodes |
53 |
private async Task GoToCreateSetPage() |
54 |
{ |
55 |
if (IsBusy) return; |
56 |
IsBusy = true; |
57 |
await Shell.Current.GoToAsync(nameof(CreateSetView)); |
58 |
IsBusy = false; |
59 |
} |
60 |
|
61 |
private async Task GoToLastSetPage() |
62 |
{ |
63 |
if (IsBusy) return; |
64 |
IsBusy = true; |
65 |
await Shell.Current.GoToAsync(nameof(ChambersView)); |
66 |
IsBusy = false; |
67 |
} |
68 |
private async Task GoToEndDayPage() |
69 |
{ |
70 |
if (IsBusy) return; |
71 |
IsBusy = true; |
72 |
await Shell.Current.GoToAsync(nameof(EndDayView)); |
73 |
IsBusy = false; |
74 |
} |
75 |
public void GetLastSet() |
76 |
{ |
77 |
HasLastSet = JourneeViewModel.Instance.GetCurrentDay()?.HasAnySet() ?? false; |
78 |
LastSetText = HasLastSet ? "Une série en cours, la reprendre ?" : "Aucune série trouvée, en créer une ?"; |
79 |
} |
80 |
#endregion |
81 |
} |
82 |
} |
83 |
|