Révision fff89fc5 GES_PAC/ViewModel/ChambersViewModel.cs
GES_PAC/ViewModel/ChambersViewModel.cs | ||
---|---|---|
1 | 1 |
using GES_PAC.Model; |
2 | 2 |
using GES_PAC.View; |
3 |
using System.Collections.ObjectModel; |
|
3 | 4 |
using System.Windows.Input; |
4 | 5 |
|
5 | 6 |
namespace GES_PAC.ViewModel |
... | ... | |
8 | 9 |
{ |
9 | 10 |
|
10 | 11 |
#region Attributs |
12 |
|
|
11 | 13 |
#endregion |
12 | 14 |
|
13 | 15 |
#region Commandes |
... | ... | |
16 | 18 |
|
17 | 19 |
#region Propriétés |
18 | 20 |
|
21 |
public Dictionary<int, int> NumberMeasure { get; set; } |
|
22 |
|
|
23 |
public ObservableCollection<Color> ChamberColors { get; } = []; |
|
24 |
|
|
19 | 25 |
#endregion |
20 | 26 |
|
21 | 27 |
#region Constructeurs |
22 | 28 |
public ChambersViewModel() |
23 | 29 |
{ |
30 |
NumberMeasure = JourneeViewModel.Instance.GetCurrentDay().GetCurrentSet().GetMeasureNumber(); |
|
31 |
UpdateChamberColors(); |
|
32 |
|
|
24 | 33 |
OnClickChamberCommand = new Command<string>(async (idStr) => |
25 | 34 |
{ |
26 | 35 |
int id = int.Parse(idStr); |
27 | 36 |
await GoToEnterAnimal(id); |
28 | 37 |
}); |
29 |
|
|
30 | 38 |
} |
31 | 39 |
#endregion |
32 | 40 |
|
... | ... | |
37 | 45 |
await Shell.Current.GoToAsync($"{nameof(EnterAnimalView)}?chamberId={id}"); |
38 | 46 |
IsBusy = false; |
39 | 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 |
} |
|
40 | 58 |
#endregion |
41 | 59 |
} |
42 | 60 |
} |
Formats disponibles : Unified diff