Statistiques
| Branche: | Révision:

root / GES_PAC / ViewModel / ChambersViewModel.cs @ 42456640

Historique | Voir | Annoter | Télécharger (1,418 ko)

1 42456640 lbihannic
using GES_PAC.Model;
2
using GES_PAC.Services;
3 4e39035b lbihannic
using GES_PAC.View;
4 e837cdf1 lbihannic
using GES_PAC.ViewModel.Controls;
5
using System.Collections.ObjectModel;
6 09d4a0de lbihannic
using System.Windows.Input;
7
8
namespace GES_PAC.ViewModel
9
{
10
    public class ChambersViewModel : BaseViewModel
11
    {
12
        #region Attributs
13
        #endregion
14
15
        #region Commandes
16 42456640 lbihannic
        public Serie? CurrentSet { get; set; }
17 12ddf7ef lbihannic
        public ICommand TerminateSetCommand { get; }
18 09d4a0de lbihannic
        #endregion
19
20
        #region Propriétés
21 e837cdf1 lbihannic
        public TimerPublisher Timer { get; }
22 09d4a0de lbihannic
        #endregion
23
24
        #region Constructeurs
25
        public ChambersViewModel()
26
        {
27 4e39035b lbihannic
            TerminateSetCommand = new Command(async () => await TerminateSet());
28 e837cdf1 lbihannic
29 42456640 lbihannic
            CurrentSet = JourneeViewModel.Instance.GetCurrentSet();
30
31 e837cdf1 lbihannic
            Timer = new TimerPublisher();
32
            Timer.Start();
33 09d4a0de lbihannic
        }
34
        #endregion
35
36
        #region Méthodes
37 4e39035b lbihannic
        private async Task TerminateSet()
38
        {
39
            if (IsBusy) return;
40
            IsBusy = true;
41
            await Shell.Current.GoToAsync(nameof(EndSetView));
42
            IsBusy = false;
43
        }
44 42456640 lbihannic
45
        internal async void OnAppearing()
46
        {
47
            CurrentSet = JourneeViewModel.Instance.GetCurrentSet();
48
            if (CurrentSet == null)
49
            {
50
                IsBusy = true;
51
                await Shell.Current.GoToAsync(nameof(MainView));
52
                IsBusy = false;
53
            }
54
        }
55 09d4a0de lbihannic
        #endregion
56
    }
57
}