commit 9601eaf01d1365042d2fff28149da95eadc97077
Author: lbihannic <lucas.bihannic@inrae.fr>
Date:   Wed Apr 16 16:01:26 2025 +0200

    change timer color when 1h or more

diff --git a/GES_PAC/Model/Comportement.cs b/GES_PAC/Model/Comportement.cs
index 60b4178..7881226 100644
--- a/GES_PAC/Model/Comportement.cs
+++ b/GES_PAC/Model/Comportement.cs
@@ -11,7 +11,7 @@ namespace GES_PAC.Model
         public Comportement(DateTime Time, TypeComportement Type, string Commentaire)
         {
             this.Time = Time;
-            this.Type = Type ?? TypeComportement.AUTRE;
+            this.Type = Type;
             this.Commentaire = Commentaire;
         }
     }
diff --git a/GES_PAC/Model/Journee.cs b/GES_PAC/Model/Journee.cs
index b1cb3d7..a0ccf5f 100644
--- a/GES_PAC/Model/Journee.cs
+++ b/GES_PAC/Model/Journee.cs
@@ -48,9 +48,9 @@ namespace GES_PAC.Model
         {
             if (Series.Count == 0)
             {
-                return PhaseCalibration.Debut;
+                return PhaseCalibration.DEBUT;
             }
-            return PhaseCalibration.Fin;
+            return PhaseCalibration.FIN;
         }
 
         public Calibration GetCurrentCalibration()
@@ -99,7 +99,7 @@ namespace GES_PAC.Model
         }
         internal Calibration GetDebutCalibration()
         {
-            return Calibrations.FirstOrDefault(c => c.Phase == PhaseCalibration.Debut);
+            return Calibrations.FirstOrDefault(c => c.Phase == PhaseCalibration.DEBUT);
         }
         internal bool IsCalibrationComplete(PhaseCalibration pc)
         {
@@ -107,7 +107,7 @@ namespace GES_PAC.Model
         }
         internal bool IsComplete()
         {
-            return Calibrations.FirstOrDefault(c => c.Phase == PhaseCalibration.Fin)?.IsComplete() ?? false;
+            return Calibrations.FirstOrDefault(c => c.Phase == PhaseCalibration.FIN)?.IsComplete() ?? false;
         }
         #endregion
     }
diff --git a/GES_PAC/Model/PhaseCalibration.cs b/GES_PAC/Model/PhaseCalibration.cs
index 27f46c9..98ec2ff 100644
--- a/GES_PAC/Model/PhaseCalibration.cs
+++ b/GES_PAC/Model/PhaseCalibration.cs
@@ -11,10 +11,10 @@ namespace GES_PAC.Model
             Value = value;
         }
 
-        public static readonly PhaseCalibration Debut = new("DEBUT", 1);
-        public static readonly PhaseCalibration Fin = new("FIN", 2);
+        public static readonly PhaseCalibration DEBUT = new("d�but", 1);
+        public static readonly PhaseCalibration FIN = new("fin", 2);
 
-        public static readonly List<PhaseCalibration> All = new() { Debut, Fin };
+        public static readonly List<PhaseCalibration> All = new() { DEBUT, FIN };
 
         public override string ToString() => Name;
 
diff --git a/GES_PAC/Model/SerieAnimal.cs b/GES_PAC/Model/SerieAnimal.cs
index 65f1c62..3723660 100644
--- a/GES_PAC/Model/SerieAnimal.cs
+++ b/GES_PAC/Model/SerieAnimal.cs
@@ -1,4 +1,4 @@
-
+﻿
 using Microsoft.Maui.Layouts;
 
 namespace GES_PAC.Model
@@ -52,7 +52,13 @@ namespace GES_PAC.Model
         {
             return Comportements.Count != 0;
         }
-        public string GetTimeInChamber()
+        public bool IsTimeWarning()
+        {
+            if (Mesures.Count == 0 || IsOut)
+                return false;
+            return (DateTime.Now - GetFirstMeasure().Time) > TimeSpan.FromHours(1);
+        }
+        public string GetFormatedTimeInChamber()
         {
             if (Mesures.Count == 0)
                 return "";
@@ -63,7 +69,8 @@ namespace GES_PAC.Model
             else
                 timeInChamber = DateTime.Now - GetFirstMeasure().Time;
 
-            return $"{timeInChamber.Hours:00}:{timeInChamber.Minutes:00}";
+            return $"{timeInChamber.Hours:00}:{timeInChamber.Minutes:00}" + (IsTimeWarning() ? "⚠" : "");
         }
+        
     }
 }
diff --git a/GES_PAC/View/Controls/ChamberButtonView.xaml b/GES_PAC/View/Controls/ChamberButtonView.xaml
index 419a1b7..0c3f51a 100644
--- a/GES_PAC/View/Controls/ChamberButtonView.xaml
+++ b/GES_PAC/View/Controls/ChamberButtonView.xaml
@@ -21,6 +21,7 @@
            VerticalOptions="Start" />  
 
        <Label Text="{Binding TimeIn}"  
+           TextColor="{Binding TimeColor}"
            FontSize="12"  
            Margin="3"  
            HorizontalOptions="End"  
diff --git a/GES_PAC/View/CreateCalibrationView.xaml b/GES_PAC/View/CreateCalibrationView.xaml
index 61f4ef3..40cdb3f 100644
--- a/GES_PAC/View/CreateCalibrationView.xaml
+++ b/GES_PAC/View/CreateCalibrationView.xaml
@@ -14,7 +14,7 @@
 
                 <VerticalStackLayout Grid.Row="1" Spacing="30">
 
-                    <Label Text="Mesure de calibration"
+                    <Label Text="{Binding PhaseName, StringFormat='Calibration de {0}'}"
                        FontSize="20"
                        FontAttributes="Bold"
                        HorizontalOptions="Center" />
diff --git a/GES_PAC/ViewModel/Controls/ChamberButtonViewModel.cs b/GES_PAC/ViewModel/Controls/ChamberButtonViewModel.cs
index e10c432..199f885 100644
--- a/GES_PAC/ViewModel/Controls/ChamberButtonViewModel.cs
+++ b/GES_PAC/ViewModel/Controls/ChamberButtonViewModel.cs
@@ -14,6 +14,7 @@ namespace GES_PAC.ViewModel.Controls
         private bool _buttonIsEnabled;
         private string _buttonLabel;
         private string _timeIn;
+        private Color _timeColor;
         private ICommand _onClickChamberCommand;
         private readonly TimerPublisher _timer;
 
@@ -80,6 +81,16 @@ namespace GES_PAC.ViewModel.Controls
             {
                 _timeIn = value;
                 OnPropertyChanged();
+
+            }
+        }
+        public Color TimeColor
+        {
+            get => _timeColor;
+            set
+            {
+                _timeColor = value;
+                OnPropertyChanged();
             }
         }
         public SerieAnimal? AnimalSet;
@@ -156,9 +167,11 @@ namespace GES_PAC.ViewModel.Controls
             ButtonIsEnabled = !AnimalSet.IsOut;
             ButtonBackgroundColor = AnimalSet.HasBehaviour() ? Colors.Yellow : Colors.LightGreen;
             ButtonLabel = measureCount.ToString();
-            TimeIn = AnimalSet.GetTimeInChamber();
+            TimeIn = AnimalSet.GetFormatedTimeInChamber();
+            TimeColor = AnimalSet.IsTimeWarning() ? Colors.Red : Colors.Black;
         }
 
+
         private async Task GoToChamber()
         {
             if (IsBusy) return;
@@ -172,7 +185,8 @@ namespace GES_PAC.ViewModel.Controls
         }
         public void OnTimerTick(object? sender, EventArgs e)
         {
-            TimeIn = AnimalSet?.GetTimeInChamber() ?? "";
+            TimeIn = AnimalSet?.GetFormatedTimeInChamber() ?? "";
+            TimeColor = AnimalSet?.IsTimeWarning() ?? false ? Colors.Red : Colors.Black;
         }
 
         #endregion
diff --git a/GES_PAC/ViewModel/CreateCalibrationViewModel.cs b/GES_PAC/ViewModel/CreateCalibrationViewModel.cs
index f76f133..737f027 100644
--- a/GES_PAC/ViewModel/CreateCalibrationViewModel.cs
+++ b/GES_PAC/ViewModel/CreateCalibrationViewModel.cs
@@ -5,10 +5,12 @@ using System.Windows.Input;
 
 namespace GES_PAC.ViewModel
 {
+    [QueryProperty(nameof(PhaseName), "phase")]
     public class CreateCalibrationViewModel : BaseViewModel
     {
 
         #region Attributs
+        public string _phaseName;
         private TypeCalibration _selectedType;
         private double? _conc_o2;
         private double? _conc_co2;
@@ -28,6 +30,17 @@ namespace GES_PAC.ViewModel
         #endregion
 
         #region Propriétés
+        public PhaseCalibration Phase { get; private set; }
+        public string PhaseName
+        {
+            get => _phaseName;
+            set
+            {
+                _phaseName = value;
+                Phase = PhaseCalibration.All.FirstOrDefault(p => p.Name == value) ?? PhaseCalibration.DEBUT;
+                OnPropertyChanged();
+            }
+        }
         public ObservableCollection<TypeCalibration> TypeCalibrations { get; }
         public TypeCalibration SelectedType
         {
@@ -163,11 +176,12 @@ namespace GES_PAC.ViewModel
 
             var journeeActuelle = JourneeViewModel.Instance.GetCurrentDay();
             var typesManquants = journeeActuelle.GetCurrentMissingCalibration();
+            var phaseCalibration = journeeActuelle.GetCurrentPhase();
 
             TypeCalibrations = new ObservableCollection<TypeCalibration>(typesManquants);
             SelectedType = TypeCalibrations[0];
 
-            if (journeeActuelle.GetCurrentPhase() == PhaseCalibration.Fin)
+            if (journeeActuelle.GetCurrentPhase() == PhaseCalibration.FIN)
             { 
                 LastCalibration = journeeActuelle.GetDebutCalibration();
                 HasLastMeasure = true;
@@ -183,12 +197,11 @@ namespace GES_PAC.ViewModel
 
             var date = DateTime.Now;
             var newCalib = new MesureCalibration(date, ConcO2 ?? 0, ConcCO2 ?? 0, ConcCH4 ?? 0, SelectedType, RefBouteille);
-            var phaseCalibration = JourneeViewModel.Instance.GetCurrentPhase();
-            var isComplete = JourneeViewModel.Instance.GetCurrentDay().AddCalibration(newCalib, phaseCalibration);
+            var isComplete = JourneeViewModel.Instance.GetCurrentDay().AddCalibration(newCalib, Phase);
 
-            var targetView = nameof(CreateCalibrationView);
+            var targetView = $"{nameof(CreateCalibrationView)}?phase={PhaseName}";
             if (isComplete) {
-                targetView = phaseCalibration == PhaseCalibration.Debut ? nameof(SetListView) : nameof(MainView);
+                targetView = Phase == PhaseCalibration.DEBUT ? nameof(SetListView) : nameof(MainView);
             }
             await Shell.Current.GoToAsync(targetView);
 
diff --git a/GES_PAC/ViewModel/CreateDayViewModel.cs b/GES_PAC/ViewModel/CreateDayViewModel.cs
index f955d60..414ccdd 100644
--- a/GES_PAC/ViewModel/CreateDayViewModel.cs
+++ b/GES_PAC/ViewModel/CreateDayViewModel.cs
@@ -91,7 +91,7 @@ namespace GES_PAC.ViewModel
             var date = DateTime.Now;
             var newDay = new Journee(date, SelectedPerson, SelectedPlace, Regime);
             JourneeViewModel.Instance.Journees.Add(newDay);
-            await Shell.Current.GoToAsync(nameof(CreateCalibrationView));
+            await Shell.Current.GoToAsync($"{nameof(CreateCalibrationView)}?phase={PhaseCalibration.DEBUT.Name}");
             IsBusy = false;
         }
 
diff --git a/GES_PAC/ViewModel/EndDayViewModel.cs b/GES_PAC/ViewModel/EndDayViewModel.cs
index bdc9f8e..f16d284 100644
--- a/GES_PAC/ViewModel/EndDayViewModel.cs
+++ b/GES_PAC/ViewModel/EndDayViewModel.cs
@@ -1,4 +1,5 @@
-﻿using GES_PAC.View;
+﻿using GES_PAC.Model;
+using GES_PAC.View;
 
 namespace GES_PAC.ViewModel
 {
@@ -71,7 +72,7 @@ namespace GES_PAC.ViewModel
         {
             if (IsBusy) return;
             IsBusy = true;
-            await Shell.Current.GoToAsync(nameof(CreateCalibrationView));
+            await Shell.Current.GoToAsync($"{nameof(CreateCalibrationView)}?phase={PhaseCalibration.FIN.Name}");
             IsBusy = false;
         }
         #endregion
diff --git a/GES_PAC/ViewModel/MainViewModel.cs b/GES_PAC/ViewModel/MainViewModel.cs
index 0f4e659..2a15a88 100644
--- a/GES_PAC/ViewModel/MainViewModel.cs
+++ b/GES_PAC/ViewModel/MainViewModel.cs
@@ -52,12 +52,12 @@ namespace GES_PAC.ViewModel
         public MainViewModel()
         {
             //ONLY FOR TESTS
-            var date = DateTime.Now;
+            var date = DateTime.Now.AddHours(-2);
             var newDay = new Journee(date, PersonViewModel.Instance.Persons[0], PlaceViewModel.Instance.Places[0], "");
             newDay.AddSet(new Serie(date, date, 25, 25, 25));
-            newDay.AddCalibration(new MesureCalibration(date, 50, 40, 500, TypeCalibration.Air, ""), PhaseCalibration.Debut);
-            newDay.AddCalibration(new MesureCalibration(date, 0, 0, 1000000, TypeCalibration.Methane, "dazdazd"), PhaseCalibration.Debut);
-            newDay.AddCalibration(new MesureCalibration(date, 30, 30, 3000, TypeCalibration.Melange, "deqsfsdf"), PhaseCalibration.Debut);
+            newDay.AddCalibration(new MesureCalibration(date, 50, 40, 500, TypeCalibration.Air, ""), PhaseCalibration.DEBUT);
+            newDay.AddCalibration(new MesureCalibration(date, 0, 0, 1000000, TypeCalibration.Methane, "dazdazd"), PhaseCalibration.DEBUT);
+            newDay.AddCalibration(new MesureCalibration(date, 30, 30, 3000, TypeCalibration.Melange, "deqsfsdf"), PhaseCalibration.DEBUT);
             newDay.GetCurrentSet().AddSerieAnimal(new SerieAnimal(1, 500, date, ""));
             newDay.GetCurrentSet().AddMeasure(new Mesure(date, 50, 50, 50), 1, false);
             JourneeViewModel.Instance.Journees.Add(newDay);
@@ -94,8 +94,8 @@ namespace GES_PAC.ViewModel
             IsBusy = true;
 
             CurrentDay = JourneeViewModel.Instance.GetCurrentDay();
-            var targetView = nameof(CreateCalibrationView);
-            if (CurrentDay.IsCalibrationComplete(PhaseCalibration.Debut))
+            var targetView = $"{nameof(CreateCalibrationView)}?phase={PhaseCalibration.DEBUT.Name}";
+            if (CurrentDay.IsCalibrationComplete(PhaseCalibration.DEBUT))
                 targetView = nameof(SetListView);
 
             await Shell.Current.GoToAsync(targetView);
