Révision 1019554c

Voir les différences:

GES_PAC/Model/Serie.cs
10 10
        public double Temperature { get; set; }
11 11
        public double Humidite { get; set; }
12 12
        public double Pression { get; set; }
13
        public List<SerieAnimal> SeriesAnimales { get; set; }
13
        public List<SerieAnimal> SeriesAnimales { get; set; } = [];
14 14
        #endregion
15 15

  
16 16
        #region Constructeurs
......
28 28
        #region Méthodes
29 29
        public void AddSerieAnimal(SerieAnimal serieAnimal)
30 30
        {
31
            var existing = SeriesAnimales.FirstOrDefault(s => s.NumeroBoite == serieAnimal.NumeroBoite);
32
            if (existing != null)
33
                SeriesAnimales.Remove(existing);
31 34
            SeriesAnimales.Add(serieAnimal);
32 35
        }
33 36

  
......
36 39
            return SeriesAnimales.ToDictionary(sa => sa.NumeroBoite, sa => sa.GetMeasureCount());
37 40
        }
38 41

  
42
        public Mesure? GetLastMeasureByNumeroBoite(int numeroBoite)
43
        {
44
            var serieAnimal = SeriesAnimales.FirstOrDefault(sa => sa.NumeroBoite == numeroBoite);
45
            if (serieAnimal == null || !serieAnimal.Mesures.Any())
46
                return null;
47
            return serieAnimal.GetLastMeasure();
48
        }
49

  
39 50
        internal void AddMeasure(Mesure newMeasure, int numBoite)
40 51
        {
41 52
            SeriesAnimales.Select(sa => sa).Where(sa => sa.NumeroBoite == numBoite).First().AddMeasure(newMeasure);
GES_PAC/Model/SerieAnimal.cs
30 30
        {
31 31
            Mesures.Add(newMeasure);
32 32
        }
33

  
34
        public Mesure GetLastMeasure()
35
        {
36
            return Mesures.Last();
37
        }
33 38
    }
34 39
}
GES_PAC/View/ChambersView.xaml
25 25
                        <Border Stroke="Black" StrokeThickness="2" BackgroundColor="Transparent" HorizontalOptions="Center" StrokeShape="RoundRectangle 10">
26 26

  
27 27
                            <Grid
28
    BackgroundColor="LightGray"
29
    Padding="5"
30
    RowSpacing="0"
31
    ColumnSpacing="5"
32
    WidthRequest="250"
33
    HeightRequest="500">
28
                                BackgroundColor="LightGray"
29
                                Padding="5"
30
                                RowSpacing="0"
31
                                ColumnSpacing="5"
32
                                WidthRequest="250"
33
                                HeightRequest="500">
34 34

  
35 35
                                <Grid.ColumnDefinitions>
36 36
                                    <ColumnDefinition Width="Auto"/>
......
127 127

  
128 128
                <Button 
129 129
                    Text="Terminer les mesures"
130
                    Command="{Binding CreateSetCommand}"
130
                    Command="{Binding TerminateSetCommand}"
131 131
                    Style="{StaticResource btnNormal}"
132 132
                    IsEnabled="{Binding IsFormValid}"
133 133
                    VerticalOptions="End"/>
GES_PAC/View/CreateMeasureView.xaml
22 22
                        <!-- CH4 -->
23 23
                        <VerticalStackLayout>
24 24
                            <Label Text="CH4 (ppm)" FontSize="14" TextColor="Gray" FontAttributes="Bold"/>
25
                            <Entry Text="{Binding ConcCH4, Mode=TwoWay, TargetNullValue=''}" 
26
                                   FontSize="16" 
27
                                   TextColor="Black" 
28
                                   Placeholder="0,0" 
29
                                   Keyboard="Numeric"/>
25
                            <Grid ColumnDefinitions="*,Auto" ColumnSpacing="5">
26
                                <Entry Grid.Column="0"
27
                                   Text="{Binding ConcCH4, Mode=TwoWay, TargetNullValue=''}"
28
                                   FontSize="16"
29
                                   TextColor="Black"
30
                                   Placeholder="0,0"
31
                                   Keyboard="Numeric">
32
                                    <Entry.Triggers>
33
                                        <DataTrigger TargetType="Entry" Binding="{Binding HasLastMeasure}" Value="False">
34
                                            <Setter Property="Grid.ColumnSpan" Value="2" />
35
                                        </DataTrigger>
36
                                    </Entry.Triggers>
37
                                </Entry>
38
                                <Label Grid.Column="1"
39
                                   Text="{Binding LastCH4, StringFormat='[{0} ppm]'}"
40
                                   FontSize="16"
41
                                   TextColor="Gray"
42
                                   VerticalOptions="Center"
43
                                   HorizontalOptions="End"
44
                                   IsVisible="{Binding HasLastMeasure}" />
45
                            </Grid>
46

  
30 47
                            <Label Text="Entrez une valeur"
31
                                FontSize="12"
32
                                TextColor="Red"
33
                                IsVisible="{Binding ConcCH4Error}"/>
48
                               FontSize="12"
49
                               TextColor="Red"
50
                               IsVisible="{Binding ConcCH4Error}"/>
34 51
                        </VerticalStackLayout>
35 52

  
53

  
36 54
                        <!-- O2 -->
37 55
                        <VerticalStackLayout>
38
                            <Label Text="O2 (% vol.)" FontSize="14" TextColor="Gray" FontAttributes="Bold"/>
39
                            <Entry Text="{Binding ConcO2 , Mode=TwoWay, TargetNullValue=''}" 
40
                                   FontSize="16" 
41
                                   TextColor="Black" 
42
                                   Placeholder="0,0" 
43
                                   Keyboard="Numeric"/>
56
                            <Label Text="O2 (%)" FontSize="14" TextColor="Gray" FontAttributes="Bold"/>
57
                            <Grid ColumnDefinitions="*,Auto" ColumnSpacing="5">
58
                                <Entry Grid.Column="0"
59
                                   Text="{Binding ConcO2, Mode=TwoWay, TargetNullValue=''}"
60
                                   FontSize="16"
61
                                   TextColor="Black"
62
                                   Placeholder="0,0"
63
                                   Keyboard="Numeric">
64
                                    <Entry.Triggers>
65
                                        <DataTrigger TargetType="Entry" Binding="{Binding HasLastMeasure}" Value="False">
66
                                            <Setter Property="Grid.ColumnSpan" Value="2" />
67
                                        </DataTrigger>
68
                                    </Entry.Triggers>
69
                                </Entry>
70
                                <Label Grid.Column="1"
71
                                   Text="{Binding LastO2, StringFormat='[{0} %]'}"
72
                                   FontSize="16"
73
                                   TextColor="Gray"
74
                                   VerticalOptions="Center"
75
                                   HorizontalOptions="End"
76
                                   IsVisible="{Binding HasLastMeasure}" />
77
                            </Grid>
78

  
44 79
                            <Label Text="Entrez une valeur"
45
                                FontSize="12"
46
                                TextColor="Red"
47
                                IsVisible="{Binding ConcO2Error}"/>
80
                               FontSize="12"
81
                               TextColor="Red"
82
                               IsVisible="{Binding ConcO2Error}"/>
48 83
                        </VerticalStackLayout>
49 84

  
85

  
50 86
                        <!-- CO2 -->
51 87
                        <VerticalStackLayout>
52
                            <Label Text="CO2 (% vol.)" FontSize="14" TextColor="Gray" FontAttributes="Bold"/>
53
                            <Entry Text="{Binding ConcCO2, Mode=TwoWay, TargetNullValue=''}" 
54
                                   FontSize="16" 
55
                                   TextColor="Black" 
56
                                   Placeholder="0,0" 
57
                                   Keyboard="Numeric"/>
88
                            <Label Text="CO2 (%)" FontSize="14" TextColor="Gray" FontAttributes="Bold"/>
89
                            <Grid ColumnDefinitions="*,Auto" ColumnSpacing="5">
90
                                <Entry Grid.Column="0"
91
                                   Text="{Binding ConcCO2, Mode=TwoWay, TargetNullValue=''}"
92
                                   FontSize="16"
93
                                   TextColor="Black"
94
                                   Placeholder="0,0"
95
                                   Keyboard="Numeric">
96
                                    <Entry.Triggers>
97
                                        <DataTrigger TargetType="Entry" Binding="{Binding HasLastMeasure}" Value="False">
98
                                            <Setter Property="Grid.ColumnSpan" Value="2" />
99
                                        </DataTrigger>
100
                                    </Entry.Triggers>
101
                                </Entry>
102
                                <Label Grid.Column="1"
103
                                   Text="{Binding LastCO2, StringFormat='[{0} %]'}"
104
                                   FontSize="16"
105
                                   TextColor="Gray"
106
                                   VerticalOptions="Center"
107
                                   HorizontalOptions="End"
108
                                   IsVisible="{Binding HasLastMeasure}" />
109
                            </Grid>
110

  
58 111
                            <Label Text="Entrez une valeur"
59
                                FontSize="12"
60
                                TextColor="Red"
61
                                IsVisible="{Binding ConcCO2Error}"/>
112
                               FontSize="12"
113
                               TextColor="Red"
114
                               IsVisible="{Binding ConcCO2Error}"/>
62 115
                        </VerticalStackLayout>
116

  
117

  
63 118
                    </VerticalStackLayout>
64 119
                </VerticalStackLayout>
65 120
            </ScrollView>
GES_PAC/ViewModel/BaseViewModel.cs
5 5
{
6 6
    public class BaseViewModel : INotifyPropertyChanged
7 7
    {
8
        private bool isBusy;
8
        private bool isBusy = false;
9 9

  
10 10
        public bool IsBusy
11 11
        {
GES_PAC/ViewModel/ChambersViewModel.cs
19 19
        #region Propriétés
20 20

  
21 21
        public Dictionary<int, int> NumberMeasure { get; set; }
22

  
23 22
        public ObservableCollection<Color> ChamberColors { get; } = [];
24 23
        public ObservableCollection<int> ChamberNumbers { get; } = [];
25 24

  
......
28 27
        #region Constructeurs
29 28
        public ChambersViewModel()
30 29
        {
30
            //ONLY FOR TESTS
31
            var date = DateTime.Now;
32
            var newDay = new Journee(date, PersonViewModel.Instance.Persons[0], PlaceViewModel.Instance.Places[0], "");
33
            newDay.AddSerie(new Serie(date, date, 25, 25, 25));
34
            newDay.GetCurrentSet().AddSerieAnimal(new SerieAnimal(1, 500, date, ""));
35
            newDay.GetCurrentSet().AddMeasure(new Mesure(date, 50, 50, 50), 1);
36
            JourneeViewModel.Instance.Journees.Add(newDay);
37
            //ONLY FOR TESTS
38

  
31 39
            NumberMeasure = JourneeViewModel.Instance.GetCurrentDay().GetCurrentSet().GetMeasureNumber();
32 40
            UpdateChamberDatas();
33 41

  
......
42 50
        #region Méthodes
43 51
        private async Task GoToEnterAnimal(int id)
44 52
        {
53
            if (IsBusy) return;
45 54
            IsBusy = true;
46 55

  
47 56
            if (!NumberMeasure.ContainsValue(id))
GES_PAC/ViewModel/CreateCalibrationViewModel.cs
125 125
        #region Méthodes
126 126
        private async Task CreateCalibration()
127 127
        {
128
            if (IsBusy) return;
128 129
            IsBusy = true;
129 130

  
130 131
            var date = DateTime.Now;
GES_PAC/ViewModel/CreateDayViewModel.cs
86 86
        private async Task AddPlace() => await Shell.Current.GoToAsync(nameof(CreatePlaceView));
87 87
        private async Task CreateDay()
88 88
        {
89
            if (IsBusy) return;
89 90
            IsBusy = true;
90 91
            var date = DateTime.Now;
91 92
            var newDay = new Journee(date, SelectedPerson, SelectedPlace, Regime);
GES_PAC/ViewModel/CreateMeasureViewModel.cs
1 1
using GES_PAC.Model;
2 2
using GES_PAC.View;
3
using System.Collections.ObjectModel;
4 3
using System.Windows.Input;
5 4

  
6 5
namespace GES_PAC.ViewModel
......
15 14
        private double? _conc_co2;
16 15
        private double? _conc_ch4;
17 16
        private bool _isFormValid;
17
        private bool _hasLastMeasure;
18
        private double? _lastO2;
19
        private double? _lastCO2;
20
        private double? _lastCH4;
18 21
        #endregion
19 22

  
20 23
        #region Commandes
......
30 33
                _chamberId = value;
31 34
                OnPropertyChanged();
32 35
                OnPropertyChanged(nameof(Titre));
36
                GetLastMeasure();
33 37
            }
34 38
        }
35 39

  
......
65 69
                ValidateForm();
66 70
            }
67 71
        }
68

  
72
        public bool HasLastMeasure
73
        {
74
            get => _hasLastMeasure;
75
            set
76
            {
77
                _hasLastMeasure = value;
78
                OnPropertyChanged();
79
            }
80
        }
81
        public double? LastO2
82
        {
83
            get => _lastO2;
84
            set
85
            {
86
                _lastO2 = value;
87
                OnPropertyChanged();
88
            }
89
        }
90
        public double? LastCO2
91
        {
92
            get => _lastCO2;
93
            set
94
            {
95
                _lastCO2 = value;
96
                OnPropertyChanged();
97
            }
98
        }
99
        public double? LastCH4
100
        {
101
            get => _lastCH4;
102
            set
103
            {
104
                _lastCH4 = value;
105
                OnPropertyChanged();
106
            }
107
        }
69 108
        public bool IsFormValid
70 109
        {
71 110
            get => _isFormValid;
......
80 119
        public bool ConcCO2Error { get; private set; } = true;
81 120
        public bool ConcCH4Error { get; private set; } = true;
82 121
        public string Titre => $"Mesures chambre {ChamberId}";
122
        public Mesure? LastMeasure { get; set; }
83 123
        #endregion
84 124

  
85 125
        #region Constructeurs
86 126
        public CreateMeasureViewModel()
87 127
        {
88 128
            CreateMeasureCommand = new Command(async () => await CreateMeasure());
129

  
130
            HasLastMeasure = false;
89 131
        }
90 132
        #endregion
91 133

  
92 134
        #region Méthodes
93 135
        private async Task CreateMeasure()
94 136
        {
137
            if (IsBusy) return;
95 138
            IsBusy = true;
96 139

  
97 140
            var date = DateTime.Now;
98 141
            var newMeasure = new Mesure(date, ConcO2 ?? 0, ConcCO2 ?? 0, ConcCH4 ?? 0);
99
            var phaseCalibration = JourneeViewModel.Instance.GetCurrentPhase();
100 142

  
101 143
            JourneeViewModel.Instance.AddMeasureToCurrentSet(newMeasure, ChamberId);
102 144

  
......
119 161

  
120 162
            (CreateMeasureCommand as Command)?.ChangeCanExecute();
121 163
        }
164

  
165
        private void GetLastMeasure()
166
        {
167
            LastMeasure = JourneeViewModel.Instance.GetCurrentSet().GetLastMeasureByNumeroBoite(ChamberId);
168
            HasLastMeasure = LastMeasure != null;
169
            if (HasLastMeasure)
170
            {
171
                LastO2 = LastMeasure.Conc_O2;
172
                LastCO2 = LastMeasure.Conc_CO2;
173
                LastCH4 = LastMeasure.Conc_CH4;
174
            }
175
        }
122 176
        #endregion
123 177
    }
124 178
}
GES_PAC/ViewModel/CreateSetViewModel.cs
97 97

  
98 98
        private async Task CreateSet()
99 99
        {
100
            if (IsBusy) return;
100 101
            IsBusy = true;
101 102
            var date = DateTime.Now;
102 103
            var journeeActuelle = JourneeViewModel.Instance.GetCurrentDay();
GES_PAC/ViewModel/EnterAnimalViewModel.cs
82 82
        #region Méthodes
83 83
        private async Task EnterAnimal()
84 84
        {
85
            if (IsBusy) return;
85 86
            IsBusy = true;
86 87
            var date = DateTime.Now;
87 88
            var journeeActuelle = JourneeViewModel.Instance.GetCurrentDay();
GES_PAC/ViewModel/JourneeViewModel.cs
1 1
using GES_PAC.Model;
2
using System;
3
using System.Collections.Generic;
4 2
using System.Collections.ObjectModel;
5
using System.Linq;
6
using System.Text;
7
using System.Threading.Tasks;
8 3

  
9 4
namespace GES_PAC.ViewModel
10 5
{
......
31 26
        }
32 27
        public PhaseCalibration GetCurrentPhase()
33 28
        {
34
            var journeeActuelle = GetCurrentDay();
35
            return journeeActuelle.GetCurrentPhase();
29
            return GetCurrentDay().GetCurrentPhase();
30
        }
31
        public Serie GetCurrentSet()
32
        {
33
            return GetCurrentDay().GetCurrentSet();
36 34
        }
37 35

  
38 36
        public void AddMeasureToCurrentSet(Mesure newMeasure, int numBoite)
GES_PAC/ViewModel/MainViewModel.cs
24 24
        #region Méthodes
25 25
        private async Task GoToCreateDayPage()
26 26
        {
27
            if (IsBusy) return;
27 28
            IsBusy = true;
28 29
            await Shell.Current.GoToAsync(nameof(CreateDayView));
29 30
            IsBusy = false;
GES_PAC/ViewModel/SetListViewModel.cs
25 25
        #region Méthodes
26 26
        private async Task GoToCreateSetPage()
27 27
        {
28
            if (IsBusy) return;
28 29
            IsBusy = true;
29 30
            await Shell.Current.GoToAsync(nameof(CreateSetView));
30 31
            IsBusy = false;

Formats disponibles : Unified diff