commit 612877b5ae431bf6c2154081c01d148812e5297f
Author: lbihannic <lucas.bihannic@inrae.fr>
Date:   Wed Mar 26 14:36:22 2025 +0100

    add last time measure and color when anormal mesure

diff --git a/GES_PAC/View/CreateMeasureView.xaml b/GES_PAC/View/CreateMeasureView.xaml
index da56c55..4ce93a0 100644
--- a/GES_PAC/View/CreateMeasureView.xaml
+++ b/GES_PAC/View/CreateMeasureView.xaml
@@ -17,6 +17,13 @@
                        FontSize="20"
                        FontAttributes="Bold"
                        HorizontalOptions="Center" />
+
+                    <Label Text="{Binding LastTime}"
+                       FontSize="14"
+                       FontAttributes="Bold"
+                       HorizontalOptions="Center" 
+                       IsVisible="{Binding HasLastMeasure}"/>
+                    
                     <VerticalStackLayout Spacing="15" WidthRequest="300">
 
                         <!-- CH4 -->
@@ -29,16 +36,11 @@
                                    TextColor="Black"
                                    Placeholder="0,0"
                                    Keyboard="Numeric">
-                                    <Entry.Triggers>
-                                        <DataTrigger TargetType="Entry" Binding="{Binding HasLastMeasure}" Value="False">
-                                            <Setter Property="Grid.ColumnSpan" Value="2" />
-                                        </DataTrigger>
-                                    </Entry.Triggers>
                                 </Entry>
                                 <Label Grid.Column="1"
                                    Text="{Binding LastCH4, StringFormat='[{0} ppm]'}"
                                    FontSize="16"
-                                   TextColor="Gray"
+                                   TextColor="{Binding LastCH4Color}"
                                    VerticalOptions="Center"
                                    HorizontalOptions="End"
                                    IsVisible="{Binding HasLastMeasure}" />
@@ -61,16 +63,11 @@
                                    TextColor="Black"
                                    Placeholder="0,0"
                                    Keyboard="Numeric">
-                                    <Entry.Triggers>
-                                        <DataTrigger TargetType="Entry" Binding="{Binding HasLastMeasure}" Value="False">
-                                            <Setter Property="Grid.ColumnSpan" Value="2" />
-                                        </DataTrigger>
-                                    </Entry.Triggers>
                                 </Entry>
                                 <Label Grid.Column="1"
                                    Text="{Binding LastO2, StringFormat='[{0} %]'}"
                                    FontSize="16"
-                                   TextColor="Gray"
+                                   TextColor="{Binding LastO2Color}"
                                    VerticalOptions="Center"
                                    HorizontalOptions="End"
                                    IsVisible="{Binding HasLastMeasure}" />
@@ -93,16 +90,11 @@
                                    TextColor="Black"
                                    Placeholder="0,0"
                                    Keyboard="Numeric">
-                                    <Entry.Triggers>
-                                        <DataTrigger TargetType="Entry" Binding="{Binding HasLastMeasure}" Value="False">
-                                            <Setter Property="Grid.ColumnSpan" Value="2" />
-                                        </DataTrigger>
-                                    </Entry.Triggers>
                                 </Entry>
                                 <Label Grid.Column="1"
                                    Text="{Binding LastCO2, StringFormat='[{0} %]'}"
                                    FontSize="16"
-                                   TextColor="Gray"
+                                   TextColor="{Binding LastCO2Color}"
                                    VerticalOptions="Center"
                                    HorizontalOptions="End"
                                    IsVisible="{Binding HasLastMeasure}" />
@@ -120,12 +112,21 @@
             </ScrollView>
             <StackLayout
                 Margin="10"
-                HorizontalOptions="CenterAndExpand"
+                HorizontalOptions="Center"
                 Orientation="Horizontal"
                 VerticalOptions="FillAndExpand">
 
                 <Button 
-                    Text="Enregistrer les mesures"
+                    Text="Comportements"
+                    BackgroundColor="Orange"
+                    TextColor="White"
+                    Command="{Binding ComportementsCommand}"
+                    Style="{StaticResource btnNormal}"
+                    VerticalOptions="End"
+                    Margin="0,0,10,0"/>
+
+                <Button 
+                    Text="Enregistrer"
                     Command="{Binding CreateMeasureCommand}"
                     Style="{StaticResource btnNormal}"
                     IsEnabled="{Binding IsFormValid}"
diff --git a/GES_PAC/ViewModel/ChambersViewModel.cs b/GES_PAC/ViewModel/ChambersViewModel.cs
index 8daf4b3..b6a1c96 100644
--- a/GES_PAC/ViewModel/ChambersViewModel.cs
+++ b/GES_PAC/ViewModel/ChambersViewModel.cs
@@ -53,7 +53,7 @@ namespace GES_PAC.ViewModel
             if (IsBusy) return;
             IsBusy = true;
 
-            if (!NumberMeasure.ContainsValue(id))
+            if (!NumberMeasure.ContainsKey(id))
                 await Shell.Current.GoToAsync($"{nameof(EnterAnimalView)}?chamberId={id}");
             else
                 await Shell.Current.GoToAsync($"{nameof(CreateMeasureView)}?chamberId={id}");
diff --git a/GES_PAC/ViewModel/CreateMeasureViewModel.cs b/GES_PAC/ViewModel/CreateMeasureViewModel.cs
index 935eb1d..1710eb8 100644
--- a/GES_PAC/ViewModel/CreateMeasureViewModel.cs
+++ b/GES_PAC/ViewModel/CreateMeasureViewModel.cs
@@ -18,6 +18,11 @@ namespace GES_PAC.ViewModel
         private double? _lastO2;
         private double? _lastCO2;
         private double? _lastCH4;
+        private string _lastTime;
+        private Color _lastCH4Color;
+        private Color _lastO2Color;
+        private Color _lastCO2Color;
+
         #endregion
 
         #region Commandes
@@ -45,6 +50,7 @@ namespace GES_PAC.ViewModel
                 _conc_o2 = value;
                 OnPropertyChanged();
                 ValidateForm();
+                UpdateColors();
             }
         }
 
@@ -56,6 +62,7 @@ namespace GES_PAC.ViewModel
                 _conc_co2 = value;
                 OnPropertyChanged();
                 ValidateForm();
+                UpdateColors();
             }
         }
 
@@ -67,6 +74,7 @@ namespace GES_PAC.ViewModel
                 _conc_ch4 = value;
                 OnPropertyChanged();
                 ValidateForm();
+                UpdateColors();
             }
         }
         public bool HasLastMeasure
@@ -105,6 +113,42 @@ namespace GES_PAC.ViewModel
                 OnPropertyChanged();
             }
         }
+        public string LastTime
+        {
+            get => _lastTime;
+            set
+            {
+                _lastTime = value;
+                OnPropertyChanged();
+            }
+        }
+        public Color LastCH4Color
+        {
+            get => _lastCH4Color;
+            set
+            {
+                _lastCH4Color = value;
+                OnPropertyChanged();
+            }
+        }
+        public Color LastO2Color
+        {
+            get => _lastO2Color;
+            set
+            {
+                _lastO2Color = value;
+                OnPropertyChanged();
+            }
+        }
+        public Color LastCO2Color
+        {
+            get => _lastCO2Color;
+            set
+            {
+                _lastCO2Color = value;
+                OnPropertyChanged();
+            }
+        }
         public bool IsFormValid
         {
             get => _isFormValid;
@@ -171,8 +215,16 @@ namespace GES_PAC.ViewModel
                 LastO2 = LastMeasure.Conc_O2;
                 LastCO2 = LastMeasure.Conc_CO2;
                 LastCH4 = LastMeasure.Conc_CH4;
+                LastTime = "Dernière mesure : " + (int)(DateTime.Now - LastMeasure.Time).TotalMinutes + " min";
+                UpdateColors();
             }
         }
+        private void UpdateColors()
+        {
+            LastCH4Color = (ConcCH4 < LastCH4) ? Colors.Orange : Colors.Gray;
+            LastO2Color = (ConcO2 > LastO2) ? Colors.Orange : Colors.Gray;
+            LastCO2Color = (ConcCO2 < LastCO2) ? Colors.Orange : Colors.Gray;
+        }
         #endregion
     }
 }
