root / GES_PAC / ViewModel / ChambersViewModel.cs @ fff89fc5
Historique | Voir | Annoter | Télécharger (1,537 ko)
1 | 09d4a0de | lbihannic | using GES_PAC.Model; |
---|---|---|---|
2 | using GES_PAC.View; |
||
3 | fff89fc5 | lbihannic | using System.Collections.ObjectModel; |
4 | 09d4a0de | lbihannic | using System.Windows.Input; |
5 | |||
6 | namespace GES_PAC.ViewModel |
||
7 | { |
||
8 | public class ChambersViewModel : BaseViewModel |
||
9 | { |
||
10 | |||
11 | #region Attributs |
||
12 | fff89fc5 | lbihannic | |
13 | 09d4a0de | lbihannic | #endregion |
14 | |||
15 | #region Commandes |
||
16 | public ICommand OnClickChamberCommand { get; } |
||
17 | #endregion |
||
18 | |||
19 | #region Propriétés |
||
20 | |||
21 | fff89fc5 | lbihannic | public Dictionary<int, int> NumberMeasure { get; set; } |
22 | |||
23 | public ObservableCollection<Color> ChamberColors { get; } = []; |
||
24 | |||
25 | 09d4a0de | lbihannic | #endregion |
26 | |||
27 | #region Constructeurs |
||
28 | public ChambersViewModel() |
||
29 | { |
||
30 | fff89fc5 | lbihannic | NumberMeasure = JourneeViewModel.Instance.GetCurrentDay().GetCurrentSet().GetMeasureNumber(); |
31 | UpdateChamberColors(); |
||
32 | |||
33 | ba296a27 | lbihannic | OnClickChamberCommand = new Command<string>(async (idStr) => |
34 | { |
||
35 | int id = int.Parse(idStr); |
||
36 | await GoToEnterAnimal(id); |
||
37 | }); |
||
38 | 09d4a0de | lbihannic | } |
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 | fff89fc5 | lbihannic | |
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 | 09d4a0de | lbihannic | #endregion |
59 | } |
||
60 | } |