commit acb5dd8c3945b6c92c01cba5ad1c924ca7b63e5c
Author: lbihannic <lucas.bihannic@inrae.fr>
Date:   Wed Apr 9 09:28:02 2025 +0200

    add resume day function

diff --git a/GES_PAC/AppShell.xaml b/GES_PAC/AppShell.xaml
index 65f9619..d1b497e 100644
--- a/GES_PAC/AppShell.xaml
+++ b/GES_PAC/AppShell.xaml
@@ -24,12 +24,6 @@
         Route="CreatePlace"
         ContentTemplate="{DataTemplate local:CreatePlaceView}" />
 
-    <!-- ONLY FOR TESTS -->
-    <ShellContent 
-        Title="Chambres (test)" 
-        Route="Chambers"
-        ContentTemplate="{DataTemplate local:ChambersView}" />
-
     <Shell.FlyoutFooter>
         <Grid Padding="10" ColumnDefinitions="auto,auto">
             <Grid.GestureRecognizers>
diff --git a/GES_PAC/Model/Calibration.cs b/GES_PAC/Model/Calibration.cs
index 94dc626..fe4286d 100644
--- a/GES_PAC/Model/Calibration.cs
+++ b/GES_PAC/Model/Calibration.cs
@@ -28,7 +28,7 @@ namespace GES_PAC.Model
 
         public bool IsComplete()
         {
-            return Mesures.Count == 3;
+            return Mesures.Select(m => m.Type).Distinct().ToList().Count == 3;
         }
 
         public List<TypeCalibration> GetTypesDone()
diff --git a/GES_PAC/Model/Journee.cs b/GES_PAC/Model/Journee.cs
index 5f94368..a20bc99 100644
--- a/GES_PAC/Model/Journee.cs
+++ b/GES_PAC/Model/Journee.cs
@@ -70,7 +70,7 @@ namespace GES_PAC.Model
         
         public Serie GetCurrentSet()
         {
-            return Series.Last();
+            return Series.LastOrDefault();
         }
         public bool HasAnySet()
         {
@@ -100,7 +100,15 @@ namespace GES_PAC.Model
         }
         internal Calibration GetDebutCalibration()
         {
-            return Calibrations.First(c => c.Phase == PhaseCalibration.Debut);
+            return Calibrations.FirstOrDefault(c => c.Phase == PhaseCalibration.Debut);
+        }
+        internal bool IsCalibrationComplete(PhaseCalibration pc)
+        {
+            return Calibrations.FirstOrDefault(c => c.Phase == pc)?.IsComplete() ?? false;
+        }
+        internal bool IsComplete()
+        {
+            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 64440a0..0eb6737 100644
--- a/GES_PAC/Model/PhaseCalibration.cs
+++ b/GES_PAC/Model/PhaseCalibration.cs
@@ -1,9 +1,3 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
-
 namespace GES_PAC.Model
 {
     public class PhaseCalibration
diff --git a/GES_PAC/View/MainView.xaml b/GES_PAC/View/MainView.xaml
index 24be78e..93967a9 100644
--- a/GES_PAC/View/MainView.xaml
+++ b/GES_PAC/View/MainView.xaml
@@ -18,22 +18,20 @@
                         FontAttributes="Bold"
                         HorizontalOptions="Center"/>
 
-                    <Label Text="Pas de journée disponible"
+                    <Label Text="{Binding CurrentDayText}"
                         FontSize="18"
                         HorizontalOptions="Center"/>
 
-                    <Label Text="Créez une journée pour commencer"
-                        FontSize="16"
-                        HorizontalOptions="Center"
-                        Padding="10"/>
-
                 </StackLayout>
             </ScrollView>
-            <StackLayout
-                Margin="10"
-                HorizontalOptions="CenterAndExpand"
-                Orientation="Horizontal"
-                VerticalOptions="FillAndExpand">
+            <StackLayout HorizontalOptions="Center" VerticalOptions="EndAndExpand" Spacing="75" Margin="0, 0, 0, 50">
+                <Button  
+                    Text="Reprendre la journée"  
+                    Command="{Binding ResumeDayCommand}"  
+                    Style="{StaticResource btnNormal}"  
+                    VerticalOptions="End"  
+                    HorizontalOptions="Center"  
+                    IsVisible="{Binding HasLastDay}"/>
 
                 <Button 
                     Text="Créer une journée"
diff --git a/GES_PAC/View/MainView.xaml.cs b/GES_PAC/View/MainView.xaml.cs
index d8493dc..f44c25a 100644
--- a/GES_PAC/View/MainView.xaml.cs
+++ b/GES_PAC/View/MainView.xaml.cs
@@ -9,5 +9,15 @@ namespace GES_PAC.View
             InitializeComponent();
             BindingContext = mv;
         }
+
+        protected override void OnAppearing()
+        {
+            base.OnAppearing();
+
+            if (BindingContext is MainViewModel viewModel)
+            {
+                viewModel.GetLastDay();
+            }
+        }
     }
 }
\ No newline at end of file
diff --git a/GES_PAC/View/SetListView.xaml b/GES_PAC/View/SetListView.xaml
index 20b05bc..a90876f 100644
--- a/GES_PAC/View/SetListView.xaml
+++ b/GES_PAC/View/SetListView.xaml
@@ -11,9 +11,14 @@
  
            <tools:ConnectionIndicatorView />  
            <ScrollView>  
-               <StackLayout Spacing="100">  
- 
-                   <Label Text="{Binding LastSetText}"  
+               <StackLayout Spacing="100">
+
+                    <Label Text="Sélectionnez une série"   
+                        FontSize="22"
+                        FontAttributes="Bold"
+                        HorizontalOptions="Center"/>
+                   
+                    <Label Text="{Binding LastSetText}"  
                        FontSize="18"  
                        HorizontalOptions="Center"/>  
  
diff --git a/GES_PAC/View/SetListView.xaml.cs b/GES_PAC/View/SetListView.xaml.cs
index 579a9e5..1b91f2d 100644
--- a/GES_PAC/View/SetListView.xaml.cs
+++ b/GES_PAC/View/SetListView.xaml.cs
@@ -9,4 +9,12 @@ public partial class SetListView
         InitializeComponent();
         BindingContext = new SetListViewModel();
     }
+    protected override void OnAppearing()
+    {
+        base.OnAppearing();
+        if (BindingContext is SetListViewModel viewModel)
+        {
+            viewModel.GetLastSet();
+        }
+    }
 }
diff --git a/GES_PAC/ViewModel/JourneeViewModel.cs b/GES_PAC/ViewModel/JourneeViewModel.cs
index eaa8213..ee2c630 100644
--- a/GES_PAC/ViewModel/JourneeViewModel.cs
+++ b/GES_PAC/ViewModel/JourneeViewModel.cs
@@ -22,7 +22,7 @@ namespace GES_PAC.ViewModel
         public Journee GetCurrentDay()
         {
             DateTime today = DateTime.Today;
-            return Journees.FirstOrDefault(j => j.Date.Date == today);
+            return Journees.LastOrDefault(j => j.Date.Date == today);
         }
         public PhaseCalibration GetCurrentPhase()
         {
diff --git a/GES_PAC/ViewModel/MainViewModel.cs b/GES_PAC/ViewModel/MainViewModel.cs
index d4b0ad8..2f03710 100644
--- a/GES_PAC/ViewModel/MainViewModel.cs
+++ b/GES_PAC/ViewModel/MainViewModel.cs
@@ -1,40 +1,90 @@
 using GES_PAC.Model;
 using GES_PAC.Services;
 using GES_PAC.View;
+using System.Windows.Input;
 
 namespace GES_PAC.ViewModel
 {
-    public class MainViewModel : BaseViewModel
+    public class MainViewModel : BaseViewModel 
     {
+        #region Attributs
+        private bool _hasLastDay = false;
+        private Journee _currentDay;
+        private string _currentDayText;
+        #endregion
+
         #region Services
         private readonly ConnexionService connService;
         #endregion
 
         #region Commandes
-        public Command GoToCreateDayCommand { get; }
+        public ICommand GoToCreateDayCommand { get; }
+        public ICommand ResumeDayCommand { get; }
+        #endregion
+
+        #region Propriétés
+        public bool HasLastDay
+        {
+            get => _hasLastDay;
+            set
+            {
+                SetProperty(ref _hasLastDay, value);
+                OnPropertyChanged();
+            }
+        }
+        public Journee CurrentDay
+        {
+            get => _currentDay;
+            set
+            {
+                SetProperty(ref _currentDay, value);
+                OnPropertyChanged();
+            }
+        }
+        public string CurrentDayText
+        {
+            get => _currentDayText;
+            set
+            {
+                SetProperty(ref _currentDayText, value);
+                OnPropertyChanged();
+            }
+        }
         #endregion
 
         #region Constructeur
         public MainViewModel(ConnexionService connService)
         {
             //ONLY FOR TESTS
-            var date = DateTime.Now;
-            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.GetCurrentSet().AddSerieAnimal(new SerieAnimal(1, 500, date, ""));
-            newDay.GetCurrentSet().AddMeasure(new Mesure(date, 50, 50, 50), 1, false);
-            JourneeViewModel.Instance.Journees.Add(newDay);
+            //var date = DateTime.Now;
+            //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.GetCurrentSet().AddSerieAnimal(new SerieAnimal(1, 500, date, ""));
+            //newDay.GetCurrentSet().AddMeasure(new Mesure(date, 50, 50, 50), 1, false);
+            //JourneeViewModel.Instance.Journees.Add(newDay);
             //ONLY FOR TESTS
 
-            this.connService = connService;
             GoToCreateDayCommand = new Command(async () => await GoToCreateDayPage());
+            ResumeDayCommand = new Command(async () => await ResumeDay());
+
+            this.connService = connService;
+
+            GetLastDay();
         }
         #endregion
 
         #region Méthodes
+        
+        public void GetLastDay()
+        {
+            CurrentDay = JourneeViewModel.Instance.GetCurrentDay();
+            HasLastDay = !CurrentDay?.IsComplete() ?? false;
+            CurrentDayText = HasLastDay ? "Une journée en cours, la reprendre ?" : "Aucune journée trouvée, en créer une ?";
+
+        }
         private async Task GoToCreateDayPage()
         {
             if (IsBusy) return;
@@ -42,6 +92,20 @@ namespace GES_PAC.ViewModel
             await Shell.Current.GoToAsync(nameof(CreateDayView));
             IsBusy = false;
         }
+
+        private async Task ResumeDay()
+        {
+            if (IsBusy) return;
+            IsBusy = true;
+
+            CurrentDay = JourneeViewModel.Instance.GetCurrentDay();
+            var targetView = nameof(CreateCalibrationView);
+            if (CurrentDay.IsCalibrationComplete(PhaseCalibration.Debut))
+                targetView = nameof(SetListView);
+
+            await Shell.Current.GoToAsync(targetView);
+            IsBusy = false;
+        }
         #endregion
     }
 }
diff --git a/GES_PAC/ViewModel/SetListViewModel.cs b/GES_PAC/ViewModel/SetListViewModel.cs
index 62cb99a..e5a12dd 100644
--- a/GES_PAC/ViewModel/SetListViewModel.cs
+++ b/GES_PAC/ViewModel/SetListViewModel.cs
@@ -8,6 +8,7 @@ namespace GES_PAC.ViewModel
     {
         #region Attributs
         private bool _hasLastSet = false;
+        public string _lastSetText;
         #endregion
 
         #region Propriétés
@@ -20,8 +21,15 @@ namespace GES_PAC.ViewModel
                 OnPropertyChanged();
             }
         }
-
-        public string LastSetText => HasLastSet ? "Série existante. La reprendre ?" : "Aucune série trouvée";
+        public string LastSetText
+        {
+            get => _lastSetText;
+            set
+            {
+                SetProperty(ref _lastSetText, value);
+                OnPropertyChanged();
+            }
+        }
         #endregion
 
         #region Commandes
@@ -37,7 +45,7 @@ namespace GES_PAC.ViewModel
             GoToLastSetCommand = new Command(async () => await GoToLastSetPage());
             GoToEndDayCommand = new Command(async () => await GoToEndDayPage());
 
-            HasLastSet = JourneeViewModel.Instance.GetCurrentDay().HasAnySet();
+            GetLastSet();
         }
         #endregion
 
@@ -64,6 +72,11 @@ namespace GES_PAC.ViewModel
             await Shell.Current.GoToAsync(nameof(EndDayView));
             IsBusy = false;
         }
+        public void GetLastSet()
+        {
+            HasLastSet = JourneeViewModel.Instance.GetCurrentDay()?.HasAnySet() ?? false;
+            LastSetText = HasLastSet ? "Une série en cours, la reprendre ?" : "Aucune série trouvée, en créer une ?";
+        }
         #endregion
     }
 }
diff --git a/GES_PAC/ViewModel/TypeCalibrationViewModel.cs b/GES_PAC/ViewModel/TypeCalibrationViewModel.cs
deleted file mode 100644
index a66be31..0000000
--- a/GES_PAC/ViewModel/TypeCalibrationViewModel.cs
+++ /dev/null
@@ -1,20 +0,0 @@
-using GES_PAC.Model;
-using System;
-using System.Collections.Generic;
-using System.Collections.ObjectModel;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
-
-namespace GES_PAC.ViewModel
-{
-    public class TypeCalibrationViewModel
-    {
-        public ObservableCollection<TypeCalibration> Calibrations { get; }
-
-        public TypeCalibrationViewModel()
-        {
-            Calibrations = new ObservableCollection<TypeCalibration>(TypeCalibration.All);
-        }
-    }
-}
