Révision ba296a27

Voir les différences:

GES_PAC/AppShell.xaml
24 24
        Route="CreatePlace"
25 25
        ContentTemplate="{DataTemplate local:CreatePlaceView}" />
26 26

  
27
    <!-- ONLY FOR TESTS -->
27 28
    <ShellContent 
28 29
        Title="Chambres (test)" 
29 30
        Route="Chambers"
GES_PAC/GES_PAC.csproj
84 84
	  <Compile Update="View\CreatePlaceView.xaml.cs">
85 85
	    <DependentUpon>CreatePlaceView.xaml</DependentUpon>
86 86
	  </Compile>
87
	  <Compile Update="View\EnterAnimalView.xaml.cs">
88
	    <DependentUpon>EnterAnimalView.xaml</DependentUpon>
89
	  </Compile>
87 90
	  <Compile Update="View\SetListView.xaml.cs">
88 91
	    <DependentUpon>SetListView.xaml</DependentUpon>
89 92
	  </Compile>
......
105 108
	  <MauiXaml Update="View\CreateSetView.xaml">
106 109
	    <Generator>MSBuild:Compile</Generator>
107 110
	  </MauiXaml>
108
	  <MauiXaml Update="View\EnterAnimal.xaml">
111
	  <MauiXaml Update="View\EnterAnimalView.xaml">
109 112
	    <Generator>MSBuild:Compile</Generator>
110 113
	  </MauiXaml>
111 114
	  <MauiXaml Update="View\MainView.xaml">
GES_PAC/Model/Journee.cs
71 71
            }
72 72
            return TypeCalibration.All.Except(Calibrations.Last().GetTypesDone()).ToList();
73 73
        }
74
        
75
        public Serie GetCurrentSet()
76
        {
77
            return Series.Last();
78
        }
74 79
        #endregion
75 80
    }
76 81
}
GES_PAC/Model/Serie.cs
3 3
{
4 4
    public class Serie
5 5
    {
6
        #region Propriétés
6 7
        public long Id { get; set; }
7 8
        public DateTime Time { get; set; }
8 9
        public DateTime MiseAJeun { get; set; }
......
10 11
        public double Humidite { get; set; }
11 12
        public double Pression { get; set; }
12 13
        public List<SerieAnimal> SeriesAnimales { get; set; }
14
        #endregion
13 15

  
16
        #region Constructeurs
14 17
        public Serie(DateTime Time, DateTime MiseAJeun, double Temperature, double Humidite, double Pression)
15 18
        {
16 19
            this.Time = Time;
......
20 23
            this.Pression = Pression;
21 24
            SeriesAnimales = [];
22 25
        }
26
        #endregion
27

  
28
        #region Méthodes
29
        public void AddSerieAnimal(SerieAnimal serieAnimal)
30
        {
31
            SeriesAnimales.Add(serieAnimal);
32
        }
33
        #endregion
23 34
    }
24 35
}
GES_PAC/Model/SerieAnimal.cs
6 6
        public long Id { get; set; }
7 7
        public int NumeroBoite { get; set; }
8 8
        public double Poids { get; set; }
9
        public double DatePesee { get; set; }
9
        public DateTime DatePesee { get; set; }
10 10
        public string RFID { get; set; }
11 11
        public List<Mesure> Mesures { get; set; }
12 12
        public List<Comportement> Comportements { get; set; }
13

  
14
        public SerieAnimal(int numeroBoite, double poids, DateTime datePesee, string rFID)
15
        {
16
            NumeroBoite = numeroBoite;
17
            Poids = poids;
18
            DatePesee = datePesee;
19
            RFID = rFID;
20
            Mesures = [];
21
            Comportements = [];
22
        }
13 23
    }
14 24
}
GES_PAC/View/ChambersView.xaml
72 72
                           HeightRequest="75"
73 73
                           WidthRequest="75"
74 74
                           Rotation="-90"
75
                           TranslationY="-60"
75
                           TranslationY="20"
76 76
                           HorizontalOptions="Center"
77
                           BackgroundColor="gray"/>
77
                           BackgroundColor="Transparent"/>
78 78
                    </VerticalStackLayout>
79 79

  
80 80

  
GES_PAC/View/EnterAnimal.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.EnterAnimalView"
7
             x:DataType="vm:EnterAnimalViewModel">
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="Informations de la série"
17
                       FontSize="20"
18
                       FontAttributes="Bold"
19
                       HorizontalOptions="Center" />
20
                    <VerticalStackLayout Spacing="15" WidthRequest="300">
21

  
22
                        <!-- Num RFID -->
23
                        <VerticalStackLayout>
24

  
25
                            <Label Text="Numéro RFID" FontSize="14" TextColor="Gray" FontAttributes="Bold"/>
26
                            <Entry Text="{Binding NumRFID}" FontSize="16" TextColor="Black" Placeholder="25"/>
27
                            <Label Text="Entrez une valeur"
28
                                FontSize="12"
29
                                TextColor="Red"
30
                                IsVisible="{Binding NumRFIDError}"/>
31

  
32
                        </VerticalStackLayout>
33

  
34
                        <!-- Poids -->
35
                        <VerticalStackLayout>
36
                            <Label Text="Température (°C)" FontSize="14" TextColor="Gray" FontAttributes="Bold"/>
37
                            <Entry Text="{Binding Temperature}" FontSize="16" TextColor="Black" Placeholder="25" Keyboard="Numeric"/>
38
                            <Label Text="Entrez une valeur"
39
                                FontSize="12"
40
                                TextColor="Red"
41
                                IsVisible="{Binding TemperatureError}"/>
42
                        </VerticalStackLayout>
43

  
44
                    </VerticalStackLayout>
45
                </VerticalStackLayout>
46
            </ScrollView>
47
            <StackLayout
48
                Margin="10"
49
                HorizontalOptions="CenterAndExpand"
50
                Orientation="Horizontal"
51
                VerticalOptions="FillAndExpand">
52

  
53
                <Button 
54
                    Text="Enregistrer"
55
                    Command="{Binding CreateSetCommand}"
56
                    Style="{StaticResource btnNormal}"
57
                    IsEnabled="{Binding IsFormValid}"
58
                    VerticalOptions="End"/>
59
            </StackLayout>
60
        </StackLayout>
61
        <Grid Grid.RowSpan="1" IsVisible="{Binding IsBusy}">
62
            <Border StrokeThickness="0"
63
                            Background="Black"
64
                            Opacity="0.5"
65
                            Padding="20"
66
                            WidthRequest="160"
67
                            HeightRequest="160"
68
                            HorizontalOptions="Center"
69
                            VerticalOptions="Center"
70
                            StrokeShape="RoundRectangle 20">
71

  
72
                <VerticalStackLayout HorizontalOptions="Center" VerticalOptions="Center">
73
                    <ActivityIndicator IsRunning="True" Color="White" />
74
                    <Label Text="Chargement..."
75
                            FontSize="14"
76
                            TextColor="white"
77
                            HorizontalOptions="Center"/>
78
                </VerticalStackLayout>
79
            </Border>
80
        </Grid>
81
    </Grid>
82

  
83
</ContentPage>
GES_PAC/View/EnterAnimal.xaml.cs
1
using GES_PAC.ViewModel;
2

  
3
namespace GES_PAC.View;
4

  
5
public partial class EnterAnimalView
6
{
7
    public EnterAnimalView()
8
    {
9
        InitializeComponent();
10
        BindingContext = new EnterAnimalViewModel();
11
    }
12
}
GES_PAC/View/EnterAnimalView.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.EnterAnimalView"
7
             x:DataType="vm:EnterAnimalViewModel">
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
                        <!-- Num RFID -->
23
                        <VerticalStackLayout>
24

  
25
                            <Label Text="Numéro RFID" FontSize="14" TextColor="Gray" FontAttributes="Bold"/>
26
                            <Entry Text="{Binding NumRFID}" FontSize="16" TextColor="Black" Placeholder="25"/>
27
                            <Label Text="Min. 5 caractères"
28
                                FontSize="12"
29
                                TextColor="Red"
30
                                IsVisible="{Binding NumRFIDError}"/>
31

  
32
                        </VerticalStackLayout>
33

  
34
                        <!-- Poids -->
35
                        <VerticalStackLayout>
36
                            <Label Text="Poids (kg)" FontSize="14" TextColor="Gray" FontAttributes="Bold"/>
37
                            <Entry Text="{Binding Poids}" FontSize="16" TextColor="Black" Placeholder="25" Keyboard="Numeric"/>
38
                            <Label Text="Entrez une valeur"
39
                                FontSize="12"
40
                                TextColor="Red"
41
                                IsVisible="{Binding PoidsError}"/>
42
                        </VerticalStackLayout>
43

  
44
                    </VerticalStackLayout>
45
                </VerticalStackLayout>
46
            </ScrollView>
47
            <StackLayout
48
                Margin="10"
49
                HorizontalOptions="CenterAndExpand"
50
                Orientation="Horizontal"
51
                VerticalOptions="FillAndExpand">
52

  
53
                <Button 
54
                    Text="Enregistrer"
55
                    Command="{Binding EnterAnimalCommand}"
56
                    Style="{StaticResource btnNormal}"
57
                    IsEnabled="{Binding IsFormValid}"
58
                    VerticalOptions="End"/>
59
            </StackLayout>
60
        </StackLayout>
61
        <Grid Grid.RowSpan="1" IsVisible="{Binding IsBusy}">
62
            <Border StrokeThickness="0"
63
                            Background="Black"
64
                            Opacity="0.5"
65
                            Padding="20"
66
                            WidthRequest="160"
67
                            HeightRequest="160"
68
                            HorizontalOptions="Center"
69
                            VerticalOptions="Center"
70
                            StrokeShape="RoundRectangle 20">
71

  
72
                <VerticalStackLayout HorizontalOptions="Center" VerticalOptions="Center">
73
                    <ActivityIndicator IsRunning="True" Color="White" />
74
                    <Label Text="Chargement..."
75
                            FontSize="14"
76
                            TextColor="white"
77
                            HorizontalOptions="Center"/>
78
                </VerticalStackLayout>
79
            </Border>
80
        </Grid>
81
    </Grid>
82

  
83
</ContentPage>
GES_PAC/View/EnterAnimalView.xaml.cs
1
using GES_PAC.ViewModel;
2

  
3
namespace GES_PAC.View;
4

  
5
public partial class EnterAnimalView
6
{
7
    public EnterAnimalView()
8
    {
9
        InitializeComponent();
10
        BindingContext = new EnterAnimalViewModel();
11
    }
12
}
GES_PAC/ViewModel/ChambersViewModel.cs
21 21
        #region Constructeurs
22 22
        public ChambersViewModel()
23 23
        {
24
            OnClickChamberCommand = new Command<int>(async (id) => await GoToEnterAnimal(id));
24
            OnClickChamberCommand = new Command<string>(async (idStr) =>
25
            {
26
                int id = int.Parse(idStr);
27
                await GoToEnterAnimal(id);
28
            });
25 29

  
26 30
        }
27 31
        #endregion
GES_PAC/ViewModel/CreateSetViewModel.cs
103 103
            var newSet = new Serie(date, DateTimeMAJ, Temperature ?? 0, Humidite ?? 0, Pression ?? 0);
104 104
            journeeActuelle.AddSerie(newSet);
105 105

  
106
            await Shell.Current.GoToAsync(nameof(CreateCalibrationView));
106
            await Shell.Current.GoToAsync(nameof(ChambersView));
107 107
            IsBusy = false;
108 108
        }
109 109

  
GES_PAC/ViewModel/EnterAnimalViewModel.cs
4 4

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

  
......
29 30
            {
30 31
                _chamberId = value;
31 32
                OnPropertyChanged();
33
                OnPropertyChanged(nameof(Titre));
32 34
            }
33 35
        }
34 36

  
......
66 68

  
67 69
        public bool NumRFIDError { get; private set; } = true;
68 70
        public bool PoidsError { get; private set; } = true;
71
        public string Titre => $"Information animal chambre {ChamberId}";
72

  
69 73
        #endregion
70 74

  
71 75
        #region Constructeurs
......
76 80
        #endregion
77 81

  
78 82
        #region Méthodes
79

  
80 83
        private async Task EnterAnimal()
81 84
        {
82 85
            IsBusy = true;
83 86
            var date = DateTime.Now;
84 87
            var journeeActuelle = JourneeViewModel.Instance.GetCurrentDay();
85
            var newSet = new SerieAnimal();
86
            journeeActuelle.AddSerie(newSet); //getcurrentset a créer
88
            var newAnimalSet = new SerieAnimal(ChamberId, Poids ?? 0, date, NumRFID);
89
            journeeActuelle.GetCurrentSet().AddSerieAnimal(newAnimalSet);
87 90

  
88
            await Shell.Current.GoToAsync(nameof(CreateCalibrationView));
91
            await Shell.Current.GoToAsync(nameof(ChambersView));
89 92
            IsBusy = false;
90 93
        }
91 94

  
92 95
        private void ValidateForm()
93 96
        {
94
            NumRFIDError = NumRFID == null;
97
            NumRFIDError = NumRFID.Length < 5 ;
95 98
            PoidsError = Poids == null;
96 99

  
97 100
            OnPropertyChanged(nameof(NumRFIDError));

Formats disponibles : Unified diff