root / GES_PAC / ViewModel / ChambersViewModel.cs @ fff89fc5
Historique | Voir | Annoter | Télécharger (1,537 ko)
1 |
using GES_PAC.Model; |
---|---|
2 |
using GES_PAC.View; |
3 |
using System.Collections.ObjectModel; |
4 |
using System.Windows.Input; |
5 |
|
6 |
namespace GES_PAC.ViewModel |
7 |
{ |
8 |
public class ChambersViewModel : BaseViewModel |
9 |
{ |
10 |
|
11 |
#region Attributs |
12 |
|
13 |
#endregion |
14 |
|
15 |
#region Commandes |
16 |
public ICommand OnClickChamberCommand { get; } |
17 |
#endregion |
18 |
|
19 |
#region Propriétés |
20 |
|
21 |
public Dictionary<int, int> NumberMeasure { get; set; } |
22 |
|
23 |
public ObservableCollection<Color> ChamberColors { get; } = []; |
24 |
|
25 |
#endregion |
26 |
|
27 |
#region Constructeurs |
28 |
public ChambersViewModel() |
29 |
{ |
30 |
NumberMeasure = JourneeViewModel.Instance.GetCurrentDay().GetCurrentSet().GetMeasureNumber(); |
31 |
UpdateChamberColors(); |
32 |
|
33 |
OnClickChamberCommand = new Command<string>(async (idStr) => |
34 |
{ |
35 |
int id = int.Parse(idStr); |
36 |
await GoToEnterAnimal(id); |
37 |
}); |
38 |
} |
39 |
#endregion |
40 |
|
41 |
#region Méthodes |
42 |
private async Task GoToEnterAnimal(int id) |
43 |
{ |
44 |
IsBusy = true; |
45 |
await Shell.Current.GoToAsync($"{nameof(EnterAnimalView)}?chamberId={id}"); |
46 |
IsBusy = false; |
47 |
} |
48 |
|
49 |
private void UpdateChamberColors() |
50 |
{ |
51 |
ChamberColors.Clear(); |
52 |
for (int i = 1; i <= 12; i++) |
53 |
{ |
54 |
int count = NumberMeasure.TryGetValue(i, out var val) ? val : 0; |
55 |
ChamberColors.Add(count > 0 ? Colors.LightGreen : Colors.White); |
56 |
} |
57 |
} |
58 |
#endregion |
59 |
} |
60 |
} |