Révision 9fd69a0e

Voir les différences:

GES_PAC/AppShell.xaml.cs
20 20
            Routing.RegisterRoute(nameof(ChambersView), typeof(ChambersView));
21 21
            Routing.RegisterRoute(nameof(EnterAnimalView), typeof(EnterAnimalView));
22 22
            Routing.RegisterRoute(nameof(CreateMeasureView), typeof(CreateMeasureView));
23
            Routing.RegisterRoute(nameof(CreateBehaviourView), typeof(CreateBehaviourView));
23 24
        }
24 25
    }
25 26
}
GES_PAC/GES_PAC.csproj
123 123
	  <MauiXaml Update="View\SetListView.xaml">
124 124
	    <Generator>MSBuild:Compile</Generator>
125 125
	  </MauiXaml>
126
	  <MauiXaml Update="View\CreateBehaviourView.xaml">
127
	    <Generator>MSBuild:Compile</Generator>
128
	  </MauiXaml>
126 129
	  <MauiXaml Update="View\Tools\ConnectionIndicatorView.xaml">
127 130
	    <Generator>MSBuild:Compile</Generator>
128 131
	  </MauiXaml>
GES_PAC/GES_PAC.csproj.user
3 3
  <PropertyGroup>
4 4
    <IsFirstTimeProjectOpen>False</IsFirstTimeProjectOpen>
5 5
    <ActiveDebugFramework>net9.0-android</ActiveDebugFramework>
6
    <ActiveDebugProfile>Xiaomi 23090RA98G (Android 14.0 - API 34)</ActiveDebugProfile>
6
    <ActiveDebugProfile>Xiaomi 23090RA98G (Android 15.0 - API 35)</ActiveDebugProfile>
7 7
    <SelectedPlatformGroup>PhysicalDevice</SelectedPlatformGroup>
8 8
    <DefaultDevice>pixel_7_-_api_35</DefaultDevice>
9 9
    <SelectedDevice>Xiaomi 23090RA98G</SelectedDevice>
GES_PAC/Model/Comportement.cs
3 3
{
4 4
    public class Comportement
5 5
    {
6
        private DateTime date;
7
        private TypeComportement selectedType;
8
        private string description;
9

  
10
        public Comportement(DateTime date, TypeComportement selectedType, string description)
11
        {
12
            this.date = date;
13
            this.selectedType = selectedType;
14
            this.description = description;
15
        }
16

  
6 17
        public long Id { get; set; }
7 18
        public DateTime Time { get; set; }
8
        public TypeComportement Type { get; set; }
19
        public TypeComportement? Type { get; set; }
9 20
        public string? Commentaire { get; set; }
10 21
    }
11

  
12
    public enum TypeComportement
13
    {
14
        SUFFOCATION,
15
        AGITATION,
16
        HYPERTENSION,
17
        HYPOGLYCEMIE,
18
        HYPERGLYCEMIE,
19
        AUTRE
20
    }
21 22
}
GES_PAC/Model/PhaseCalibration.cs
11 11
        public string Name { get; }
12 12
        public int Value { get; }
13 13

  
14
        private PhaseCalibration(string name, int value) // a passer en public quand integration webservice
14
        private PhaseCalibration(string name, int value)
15 15
        {
16 16
            Name = name;
17 17
            Value = value;
GES_PAC/Model/Serie.cs
1 1

  
2
using System.Collections.ObjectModel;
3

  
2 4
namespace GES_PAC.Model
3 5
{
4 6
    public class Serie
......
34 36
            SeriesAnimales.Add(serieAnimal);
35 37
        }
36 38

  
37
        public Dictionary<int, int> GetMeasureNumber()
39
        public int GetMeasureNumberByNumeroBoite(int nb)
40
        {
41
            var sa = SeriesAnimales.FirstOrDefault(sa => sa.NumeroBoite == nb);
42
            if (sa == null)
43
                return 0;
44
            return sa.GetMeasureCount();
45
        }
46

  
47
        public bool GetHasBehaviourByNumeroBoite(int nb)
48
        {
49
            var sa = SeriesAnimales.FirstOrDefault(sa => sa.NumeroBoite == nb);
50
            if (sa == null)
51
                return false;
52
            return sa.HasBehaviour();
53
        }
54

  
55
        public ObservableCollection<bool> GetIsOutDatas()
38 56
        {
39
            return SeriesAnimales.ToDictionary(sa => sa.NumeroBoite, sa => sa.GetMeasureCount());
57
            var isOutDatas = new ObservableCollection<bool>();
58
            for (int i = 1; i <= 12; i++)
59
            {
60
                var serieAnimal = SeriesAnimales.FirstOrDefault(sa => sa.NumeroBoite == i);
61
                isOutDatas.Add(!serieAnimal?.IsOut ?? true);
62
            }
63
            return isOutDatas;
40 64
        }
41 65

  
42 66
        public Mesure? GetLastMeasureByNumeroBoite(int numeroBoite)
......
51 75
        {
52 76
            SeriesAnimales.Select(sa => sa).Where(sa => sa.NumeroBoite == numBoite).First().AddMeasure(newMeasure);
53 77
        }
78

  
79
        internal void AddBehaviour(Comportement newBehaviour, int numBoite, bool isAnimalOut)
80
        {
81
            var sa = SeriesAnimales.Select(sa => sa).Where(sa => sa.NumeroBoite == numBoite).First();
82
            sa.AddBehaviour(newBehaviour);
83
            if (isAnimalOut)
84
                sa.IsOut = true;
85
        }
54 86
        #endregion
55 87
    }
56 88
}
GES_PAC/Model/SerieAnimal.cs
1 1

  
2
using Microsoft.Maui.Layouts;
3

  
2 4
namespace GES_PAC.Model
3 5
{
4 6
    public class SerieAnimal
......
10 12
        public string RFID { get; set; }
11 13
        public List<Mesure> Mesures { get; set; }
12 14
        public List<Comportement> Comportements { get; set; }
15
        public bool IsOut { get; set; } = false;
13 16

  
14 17
        public SerieAnimal(int numeroBoite, double poids, DateTime datePesee, string rFID)
15 18
        {
......
35 38
        {
36 39
            return Mesures.Last();
37 40
        }
41

  
42
        public void AddBehaviour(Comportement newBehaviour)
43
        {
44
            Comportements.Add(newBehaviour);
45
        }
46

  
47
        public bool HasBehaviour()
48
        {
49
            return Comportements.Any();
50
        }
38 51
    }
39 52
}
GES_PAC/Model/TypeCalibration.cs
1
using System;
2
using System.Collections.Generic;
3
using System.Linq;
4
using System.Text;
5
using System.Threading.Tasks;
6

  
7 1
namespace GES_PAC.Model
8 2
{
9 3
    public class TypeCalibration
GES_PAC/Model/TypeComportement.cs
1

  
2
namespace GES_PAC.Model
3
{
4
    public class TypeComportement
5
    {
6
        public string Name { get; }
7
        public int Value { get; }
8

  
9
        private TypeComportement(string name, int value)
10
        {
11
            Name = name;
12
            Value = value;
13
        }
14

  
15
        public static readonly TypeComportement SUFFOCATION = new("SUFFOCATION", 1);
16
        public static readonly TypeComportement AGITATION = new("AGITATION", 2);
17
        public static readonly TypeComportement PERTE_DE_CONNAISSANCE = new("PERTE DE CONNAISSANCE", 3);
18
        public static readonly TypeComportement HYPOTHERMIE = new("HYPOTHERMIE", 4);
19
        public static readonly TypeComportement HYPERTHERMIE = new("HYPERTHERMIE", 5);
20
        public static readonly TypeComportement AUTRE = new("AUTRE", 6);
21

  
22
        public static readonly List<TypeComportement> All = new()
23
        {
24
            SUFFOCATION,
25
            AGITATION,
26
            PERTE_DE_CONNAISSANCE,
27
            HYPOTHERMIE,
28
            HYPERTHERMIE,
29
            AUTRE
30
        };
31

  
32
        public override string ToString() => Name;
33
    }
34
}
GES_PAC/Resources/Styles/Styles.xaml
500 500
                            <Setter Property="Opacity" Value="1" />
501 501
                        </VisualState.Setters>
502 502
                    </VisualState>
503
                    <VisualState x:Name="Disabled">
504
                        <VisualState.Setters>
505
                            <Setter Property="Opacity" Value="0.3" />
506
                        </VisualState.Setters>
507
                    </VisualState>
503 508
                </VisualStateGroup>
504 509
            </VisualStateGroupList>
505 510
        </Setter>
GES_PAC/View/ChambersView.xaml
49 49

  
50 50
                                <!-- Boutons Gauche -->
51 51
                                <Grid Grid.Row="5" Grid.Column="0">
52
                                    <Button Text="1" Style="{StaticResource ChambreButtonStyle}" Command="{Binding OnClickChamberCommand}" CommandParameter="1" BackgroundColor="{Binding ChamberColors[0]}" />
52
                                    <Button Text="1" Style="{StaticResource ChambreButtonStyle}" Command="{Binding OnClickChamberCommand}" CommandParameter="1" BackgroundColor="{Binding ChamberColors[0]}" IsEnabled="{Binding ChamberIsIn[0]}"/>
53 53
                                    <Label Text="{Binding ChamberNumbers[0]}" FontSize="10" Margin="3" HorizontalOptions="Start" VerticalOptions="Start" />
54
									<Label Text="{Binding ChamberIsOut[0]}" FontSize="10" Margin="10" HorizontalOptions="Start" VerticalOptions="Start" />
54 55
                                </Grid>
55 56
                                <Grid Grid.Row="4" Grid.Column="0">
56
                                    <Button Text="3" Style="{StaticResource ChambreButtonStyle}" Command="{Binding OnClickChamberCommand}" CommandParameter="3" BackgroundColor="{Binding ChamberColors[2]}" />
57
                                    <Button Text="3" Style="{StaticResource ChambreButtonStyle}" Command="{Binding OnClickChamberCommand}" CommandParameter="3" BackgroundColor="{Binding ChamberColors[2]}" IsEnabled="{Binding ChamberIsIn[2]}"/>
57 58
                                    <Label Text="{Binding ChamberNumbers[2]}" FontSize="10" Margin="3" HorizontalOptions="Start" VerticalOptions="Start" />
58 59
                                </Grid>
59 60
                                <Grid Grid.Row="3" Grid.Column="0">
60
                                    <Button Text="5" Style="{StaticResource ChambreButtonStyle}" Command="{Binding OnClickChamberCommand}" CommandParameter="5" BackgroundColor="{Binding ChamberColors[4]}" />
61
                                    <Button Text="5" Style="{StaticResource ChambreButtonStyle}" Command="{Binding OnClickChamberCommand}" CommandParameter="5" BackgroundColor="{Binding ChamberColors[4]}" IsEnabled="{Binding ChamberIsIn[4]}"/>
61 62
                                    <Label Text="{Binding ChamberNumbers[4]}" FontSize="10" Margin="3" HorizontalOptions="Start" VerticalOptions="Start" />
62 63
                                </Grid>
63 64
                                <Grid Grid.Row="2" Grid.Column="0">
64 65
                                    
65
                                    <Button Text="7" Style="{StaticResource ChambreButtonStyle}" Command="{Binding OnClickChamberCommand}" CommandParameter="7" BackgroundColor="{Binding ChamberColors[6]}" />
66
                                    <Button Text="7" Style="{StaticResource ChambreButtonStyle}" Command="{Binding OnClickChamberCommand}" CommandParameter="7" BackgroundColor="{Binding ChamberColors[6]}" IsEnabled="{Binding ChamberIsIn[6]}"/>
66 67
                                    <Label Text="{Binding ChamberNumbers[6]}" FontSize="10" Margin="3" HorizontalOptions="Start" VerticalOptions="Start" />
67 68
                                </Grid>
68 69
                                <Grid Grid.Row="1" Grid.Column="0">
69
                                    <Button Text="9" Style="{StaticResource ChambreButtonStyle}" Command="{Binding OnClickChamberCommand}" CommandParameter="9" BackgroundColor="{Binding ChamberColors[8]}" />
70
                                    <Button Text="9" Style="{StaticResource ChambreButtonStyle}" Command="{Binding OnClickChamberCommand}" CommandParameter="9" BackgroundColor="{Binding ChamberColors[8]}" IsEnabled="{Binding ChamberIsIn[8]}"/>
70 71
                                    <Label Text="{Binding ChamberNumbers[8]}" FontSize="10" Margin="3" HorizontalOptions="Start" VerticalOptions="Start" />
71 72
                                </Grid>
72 73
                                <Grid Grid.Row="0" Grid.Column="0">
73
                                    <Button Text="11" Style="{StaticResource ChambreButtonStyle}" Command="{Binding OnClickChamberCommand}" CommandParameter="11" BackgroundColor="{Binding ChamberColors[10]}" />
74
                                    <Button Text="11" Style="{StaticResource ChambreButtonStyle}" Command="{Binding OnClickChamberCommand}" CommandParameter="11" BackgroundColor="{Binding ChamberColors[10]}" IsEnabled="{Binding ChamberIsIn[10]}"/>
74 75
                                    <Label Text="{Binding ChamberNumbers[10]}" FontSize="10" Margin="3" HorizontalOptions="Start" VerticalOptions="Start" />
75 76
                                </Grid>
76 77

  
77 78
                                <!-- Boutons Droite -->
78 79
                                <Grid Grid.Row="5" Grid.Column="2">
79
                                    <Button Text="2" Style="{StaticResource ChambreButtonStyle}" Command="{Binding OnClickChamberCommand}" CommandParameter="2" BackgroundColor="{Binding ChamberColors[1]}" />
80
                                    <Button Text="2" Style="{StaticResource ChambreButtonStyle}" Command="{Binding OnClickChamberCommand}" CommandParameter="2" BackgroundColor="{Binding ChamberColors[1]}" IsEnabled="{Binding ChamberIsIn[1]}"/>
80 81
                                    <Label Text="{Binding ChamberNumbers[1]}" FontSize="10" Margin="3" HorizontalOptions="Start" VerticalOptions="Start" />
81 82
                                </Grid>
82 83
                                <Grid Grid.Row="4" Grid.Column="2">
83
                                    <Button Text="4" Style="{StaticResource ChambreButtonStyle}" Command="{Binding OnClickChamberCommand}" CommandParameter="4" BackgroundColor="{Binding ChamberColors[3]}" />
84
                                    <Button Text="4" Style="{StaticResource ChambreButtonStyle}" Command="{Binding OnClickChamberCommand}" CommandParameter="4" BackgroundColor="{Binding ChamberColors[3]}" IsEnabled="{Binding ChamberIsIn[3]}"/>
84 85
                                    <Label Text="{Binding ChamberNumbers[3]}" FontSize="10" Margin="3" HorizontalOptions="Start" VerticalOptions="Start" />
85 86
                                </Grid>
86 87
                                <Grid Grid.Row="3" Grid.Column="2">
87
                                    <Button Text="6" Style="{StaticResource ChambreButtonStyle}" Command="{Binding OnClickChamberCommand}" CommandParameter="6" BackgroundColor="{Binding ChamberColors[5]}" />
88
                                    <Button Text="6" Style="{StaticResource ChambreButtonStyle}" Command="{Binding OnClickChamberCommand}" CommandParameter="6" BackgroundColor="{Binding ChamberColors[5]}" IsEnabled="{Binding ChamberIsIn[5]}"/>
88 89
                                    <Label Text="{Binding ChamberNumbers[5]}" FontSize="10" Margin="3" HorizontalOptions="Start" VerticalOptions="Start" />
89 90
                                </Grid>
90 91
                                <Grid Grid.Row="2" Grid.Column="2">
91
                                    <Button Text="8" Style="{StaticResource ChambreButtonStyle}" Command="{Binding OnClickChamberCommand}" CommandParameter="8" BackgroundColor="{Binding ChamberColors[7]}" />
92
                                    <Button Text="8" Style="{StaticResource ChambreButtonStyle}" Command="{Binding OnClickChamberCommand}" CommandParameter="8" BackgroundColor="{Binding ChamberColors[7]}" IsEnabled="{Binding ChamberIsIn[7]}"/>
92 93
                                    <Label Text="{Binding ChamberNumbers[7]}" FontSize="10" Margin="3" HorizontalOptions="Start" VerticalOptions="Start" />
93 94
                                </Grid>
94 95
                                <Grid Grid.Row="1" Grid.Column="2">
95
                                    <Button Text="10" Style="{StaticResource ChambreButtonStyle}" Command="{Binding OnClickChamberCommand}" CommandParameter="10" BackgroundColor="{Binding ChamberColors[9]}" />
96
                                    <Button Text="10" Style="{StaticResource ChambreButtonStyle}" Command="{Binding OnClickChamberCommand}" CommandParameter="10" BackgroundColor="{Binding ChamberColors[9]}" IsEnabled="{Binding ChamberIsIn[9]}"/>
96 97
                                    <Label Text="{Binding ChamberNumbers[9]}" FontSize="10" Margin="3" HorizontalOptions="Start" VerticalOptions="Start" />
97 98
                                </Grid>
98 99
                                <Grid Grid.Row="0" Grid.Column="2">
99
                                    <Button Text="12" Style="{StaticResource ChambreButtonStyle}" Command="{Binding OnClickChamberCommand}" CommandParameter="12" BackgroundColor="{Binding ChamberColors[11]}" />
100
                                    <Button Text="12" Style="{StaticResource ChambreButtonStyle}" Command="{Binding OnClickChamberCommand}" CommandParameter="12" BackgroundColor="{Binding ChamberColors[11]}" IsEnabled="{Binding ChamberIsIn[11]}"/>
100 101
                                    <Label Text="{Binding ChamberNumbers[11]}" FontSize="10" Margin="3" HorizontalOptions="Start" VerticalOptions="Start" />
101 102
                                </Grid>
102 103

  
GES_PAC/View/CreateBehaviourView.xaml
1
<?xml version="1.0" encoding="utf-8" ?>
2
<ContentPage xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
3
             xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
4
             xmlns:vm="clr-namespace:GES_PAC.ViewModel"
5
             xmlns:tools="clr-namespace:GES_PAC.View.Tools"
6
             x:Class="GES_PAC.View.CreateBehaviourView"
7
             x:DataType="vm:CreateBehaviourViewModel">
8

  
9
    <Grid>
10
        <StackLayout BackgroundColor="White" Spacing="50">
11
            <tools:ConnectionIndicatorView />
12
            <ScrollView>
13

  
14
                <VerticalStackLayout Grid.Row="1" Spacing="30">
15

  
16
                    <Label Text="{Binding Titre}"
17
                       FontSize="20"
18
                       FontAttributes="Bold"
19
                       HorizontalOptions="Center" />
20
                    <VerticalStackLayout Spacing="15" WidthRequest="300">
21

  
22
                        <!-- Type de comportement -->
23
                        <VerticalStackLayout>
24

  
25
                            <Label Text="Type de comportement" FontSize="14" TextColor="Gray" FontAttributes="Bold"/>
26

  
27
                            <Picker Title="Sélectionnez un type de comportement"
28
                                ItemsSource="{Binding TypeComp}"
29
                                ItemDisplayBinding="{Binding Name}"
30
                                SelectedItem="{Binding SelectedType}" />
31

  
32

  
33
                            <Label Text="Sélectionnez un type de comportement"
34
                                FontSize="12"
35
                                TextColor="Red"
36
                                IsVisible="{Binding TypeError}"/>
37
                        </VerticalStackLayout>
38

  
39
                        <!-- Commentaire -->
40
                        <VerticalStackLayout>
41
                            <Label Text="Commentaire" FontSize="14" TextColor="Gray" FontAttributes="Bold"/>
42
                            <Entry Text="{Binding Description, Mode=TwoWay, TargetNullValue=''}" 
43
                                   FontSize="16" 
44
                                   TextColor="Black" 
45
                                   Placeholder="(facultatif)"/>
46
                        </VerticalStackLayout>
47

  
48
                        <!-- sortie de l'animal -->
49
                        <HorizontalStackLayout HorizontalOptions="Center" VerticalOptions="Center">
50
                            <CheckBox IsChecked="{Binding IsAnimalOut}" HorizontalOptions="Center" />
51
                            <Label Text="Sortie de l'animal" FontSize="14" TextColor="Gray" HorizontalOptions="Center" VerticalOptions="Center" />
52
                        </HorizontalStackLayout>
53

  
54
                    </VerticalStackLayout>
55
                </VerticalStackLayout>
56
            </ScrollView>
57
            <StackLayout
58
                Margin="10"
59
                HorizontalOptions="CenterAndExpand"
60
                Orientation="Horizontal"
61
                VerticalOptions="FillAndExpand">
62

  
63
                <Button 
64
                    Text="Enregistrer"
65
                    Command="{Binding CreateBehaviourCommand}"
66
                    Style="{StaticResource btnNormal}"
67
                    IsEnabled="{Binding IsFormValid}"
68
                    VerticalOptions="End"/>
69
            </StackLayout>
70
        </StackLayout>
71
        <Grid Grid.RowSpan="1" IsVisible="{Binding IsBusy}">
72
            <Border StrokeThickness="0"
73
                            Background="Black"
74
                            Opacity="0.5"
75
                            Padding="20"
76
                            WidthRequest="160"
77
                            HeightRequest="160"
78
                            HorizontalOptions="Center"
79
                            VerticalOptions="Center"
80
                            StrokeShape="RoundRectangle 20">
81

  
82
                <VerticalStackLayout HorizontalOptions="Center" VerticalOptions="Center">
83
                    <ActivityIndicator IsRunning="True" Color="White" />
84
                    <Label Text="Chargement..."
85
                            FontSize="14"
86
                            TextColor="white"
87
                            HorizontalOptions="Center"/>
88
                </VerticalStackLayout>
89
            </Border>
90
        </Grid>
91
    </Grid>
92

  
93
</ContentPage>
GES_PAC/View/CreateBehaviourView.xaml.cs
1
using GES_PAC.ViewModel;
2

  
3
namespace GES_PAC.View
4
{
5
    public partial class CreateBehaviourView
6
    {
7
        public CreateBehaviourView()
8
        {
9
            InitializeComponent();
10
            BindingContext = new CreateBehaviourViewModel();
11
        }
12
    }
13
}
GES_PAC/View/CreateMeasureView.xaml
120 120
                    Text="Comportements"
121 121
                    BackgroundColor="Orange"
122 122
                    TextColor="White"
123
                    Command="{Binding ComportementsCommand}"
123
                    Command="{Binding BehaviourCommand}"
124 124
                    Style="{StaticResource btnNormal}"
125 125
                    VerticalOptions="End"
126 126
                    Margin="0,0,10,0"/>
GES_PAC/View/EnterAnimalView.xaml
23 23
                        <VerticalStackLayout>
24 24

  
25 25
                            <Label Text="Numéro RFID" FontSize="14" TextColor="Gray" FontAttributes="Bold"/>
26
                            <Entry Text="{Binding NumRFID}" FontSize="16" TextColor="Black" Placeholder="04 9C 64 D2 45 2B 80"/>
27
                            <Label Text="Min. 5 caractères"
26
                            <Entry Text="{Binding NumRFID}" FontSize="16" TextColor="Black" Placeholder="12345" Keyboard="Numeric"/>
27
                            <Label Text="Min. 5 chiffres"
28 28
                                FontSize="12"
29 29
                                TextColor="Red"
30 30
                                IsVisible="{Binding NumRFIDError}"/>
GES_PAC/ViewModel/ChambersViewModel.cs
17 17
        #endregion
18 18

  
19 19
        #region Propriétés
20

  
21
        public Dictionary<int, int> NumberMeasure { get; set; }
22
        public ObservableCollection<Color> ChamberColors { get; } = [];
23
        public ObservableCollection<int> ChamberNumbers { get; } = [];
20
        public ObservableCollection<Color> ChamberColors { get; set; } = [];
21
        public ObservableCollection<int> ChamberNumbers { get; set; } = [];
22
        public ObservableCollection<bool> ChamberIsIn { get; set; } = [];
23
        public Serie CurrentSet { get; set; }
24 24

  
25 25
        #endregion
26 26

  
......
36 36
            JourneeViewModel.Instance.Journees.Add(newDay);
37 37
            //ONLY FOR TESTS
38 38

  
39
            NumberMeasure = JourneeViewModel.Instance.GetCurrentDay().GetCurrentSet().GetMeasureNumber();
39
            CurrentSet = JourneeViewModel.Instance.GetCurrentSet();
40 40
            UpdateChamberDatas();
41 41

  
42 42
            OnClickChamberCommand = new Command<string>(async (idStr) =>
......
53 53
            if (IsBusy) return;
54 54
            IsBusy = true;
55 55

  
56
            if (!NumberMeasure.ContainsKey(id))
56
            if (CurrentSet.GetMeasureNumberByNumeroBoite(id) == 0)
57 57
                await Shell.Current.GoToAsync($"{nameof(EnterAnimalView)}?chamberId={id}");
58 58
            else
59 59
                await Shell.Current.GoToAsync($"{nameof(CreateMeasureView)}?chamberId={id}");
......
63 63

  
64 64
        private void UpdateChamberDatas()
65 65
        {
66
            ChamberColors.Clear();
66
            ChamberIsIn = JourneeViewModel.Instance.GetCurrentSet().GetIsOutDatas();
67 67
            for (int i = 1; i <= 12; i++)
68 68
            {
69
                int count = NumberMeasure.TryGetValue(i, out var val) ? val : 0;
70
                ChamberColors.Add(count > 0 ? Colors.LightGreen : Colors.White);
69
                bool hasBehaviour = CurrentSet.GetHasBehaviourByNumeroBoite(i);
70
                int count = CurrentSet.GetMeasureNumberByNumeroBoite(i);
71
                if (hasBehaviour)
72
                    ChamberColors.Add(Colors.Yellow);
73
                else
74
                    ChamberColors.Add(count > 0 ? Colors.LightGreen : Colors.White);
71 75
                ChamberNumbers.Add(count);
72 76
            }
73 77
        }
GES_PAC/ViewModel/CreateBehaviourViewModel.cs
1
using GES_PAC.Model;
2
using GES_PAC.View;
3
using System.Collections.ObjectModel;
4
using System.Windows.Input;
5

  
6
namespace GES_PAC.ViewModel
7
{
8
    [QueryProperty(nameof(ChamberId), "chamberId")]
9
    public class CreateBehaviourViewModel : BaseViewModel
10
    {
11

  
12
        #region Attributs
13
        private int _chamberId;
14
        private TypeComportement _selectedType;
15
        private string _description;
16
        private bool _isFormValid;
17
        private bool _isAnimalOut;
18
        #endregion
19

  
20
        #region Commandes
21
        public ICommand CreateBehaviourCommand { get; }
22
        #endregion
23

  
24
        #region Propriétés
25
        public int ChamberId
26
        {
27
            get => _chamberId;
28
            set
29
            {
30
                _chamberId = value;
31
                OnPropertyChanged();
32
                OnPropertyChanged(nameof(Titre));
33
            }
34
        }
35
        public ObservableCollection<TypeComportement> TypeComp { get; }
36
        public TypeComportement SelectedType
37
        {
38
            get => _selectedType;
39
            set
40
            {
41
                _selectedType = value;
42
                OnPropertyChanged();
43
                ValidateForm();
44
            }
45
        }
46
        public string Description
47
        {
48
            get => _description;
49
            set
50
            {
51
                _description = value;
52
                OnPropertyChanged();
53
                ValidateForm();
54
            }
55
        }
56
        public bool IsAnimalOut
57
        {
58
            get => _isAnimalOut;
59
            set => SetProperty(ref _isAnimalOut, value);
60
        }
61

  
62
        public bool IsFormValid
63
        {
64
            get => _isFormValid;
65
            set
66
            {
67
                _isFormValid = value;
68
                OnPropertyChanged();
69
            }
70
        }
71
        public string Titre => $"Comportement chambre {ChamberId}";
72

  
73
        public bool TypeError { get; private set; } = true;
74
        #endregion
75

  
76
        #region Constructeurs
77
        public CreateBehaviourViewModel()
78
        {
79
            CreateBehaviourCommand = new Command(async () => await CreateBehaviour());
80

  
81
            TypeComp = new ObservableCollection<TypeComportement>(TypeComportement.All);
82
        }
83
        #endregion
84

  
85
        #region Méthodes
86
        private async Task CreateBehaviour()
87
        {
88
            if (IsBusy) return;
89
            IsBusy = true;
90

  
91
            var date = DateTime.Now;
92
            var set = JourneeViewModel.Instance.GetCurrentSet();
93
            var newBehaviour = new Comportement(date, SelectedType, Description);
94
            set.AddBehaviour(newBehaviour, ChamberId, IsAnimalOut);
95

  
96
            await Shell.Current.GoToAsync(nameof(ChambersView));
97
            IsBusy = false;
98
        }
99

  
100
        private void ValidateForm()
101
        {
102
            TypeError = SelectedType == null;
103

  
104
            OnPropertyChanged(nameof(TypeError));
105

  
106
            IsFormValid = !TypeError;
107

  
108
            (CreateBehaviourCommand as Command)?.ChangeCanExecute();
109
        }
110
        #endregion
111
    }
112
}
GES_PAC/ViewModel/CreateMeasureViewModel.cs
27 27

  
28 28
        #region Commandes
29 29
        public ICommand CreateMeasureCommand { get; }
30
        public ICommand BehaviourCommand { get; }
30 31
        #endregion
31 32

  
32 33
        #region Propriétés
......
170 171
        public CreateMeasureViewModel()
171 172
        {
172 173
            CreateMeasureCommand = new Command(async () => await CreateMeasure());
174
            BehaviourCommand = new Command(async () => await GoToBehaviour());
173 175

  
174 176
            HasLastMeasure = false;
175 177
        }
......
190 192

  
191 193
            IsBusy = false;
192 194
        }
195
        private async Task GoToBehaviour()
196
        {
197
            if (IsBusy) return;
198
            IsBusy = true;
193 199

  
200
            await Shell.Current.GoToAsync($"{nameof(CreateBehaviourView)}?chamberId={ChamberId}");
201

  
202
            IsBusy = false;
203
        }
204
        
194 205
        private void ValidateForm()
195 206
        {
196 207
            ConcO2Error = ConcO2 == null;
GES_PAC/ViewModel/CreateSetViewModel.cs
110 110

  
111 111
        private void ValidateForm()
112 112
        {
113
            DateMAJError = DateTimeMAJ > DateTime.Now;
113
            DateMAJError = DateTimeMAJ > DateTime.Now.AddHours(-1);
114 114
            TemperatureError = Temperature == null;
115 115
            HumiditeError = Humidite == null;
116 116
            PressionError = Pression == null;

Formats disponibles : Unified diff