Révision 4e39035b

Voir les différences:

GES_PAC/AppShell.xaml.cs
21 21
            Routing.RegisterRoute(nameof(EnterAnimalView), typeof(EnterAnimalView));
22 22
            Routing.RegisterRoute(nameof(CreateMeasureView), typeof(CreateMeasureView));
23 23
            Routing.RegisterRoute(nameof(CreateBehaviourView), typeof(CreateBehaviourView));
24
            Routing.RegisterRoute(nameof(EndSetView), typeof(EndSetView));
24 25
        }
25 26
    }
26 27
}
GES_PAC/GES_PAC.csproj
114 114
	  <MauiXaml Update="View\CreateSetView.xaml">
115 115
	    <Generator>MSBuild:Compile</Generator>
116 116
	  </MauiXaml>
117
	  <MauiXaml Update="View\EndSetView.xaml">
118
	    <Generator>MSBuild:Compile</Generator>
119
	  </MauiXaml>
117 120
	  <MauiXaml Update="View\EnterAnimalView.xaml">
118 121
	    <Generator>MSBuild:Compile</Generator>
119 122
	  </MauiXaml>
GES_PAC/Model/Journee.cs
76 76
        {
77 77
            return Series.Last();
78 78
        }
79
        public bool HasAnySet()
80
        {
81
            return Series.Count > 0;
82
        }
79 83
        #endregion
80 84
    }
81 85
}
GES_PAC/Model/Serie.cs
82 82
            if (isAnimalOut)
83 83
                sa.IsOut = true;
84 84
        }
85

  
86
        public int GetAnimalCount()
87
        {
88
            return SeriesAnimales.Count();
89
        }
90
        public int GetMeasureCount()
91
        {
92
            return SeriesAnimales.Sum(sa => sa.GetMeasureCount());
93
        }
94
        public int GetBehaviourCount()
95
        {
96
            return SeriesAnimales.Sum(sa => sa.Comportements.Count());
97
        }
85 98
        #endregion
86 99
    }
87 100
}
GES_PAC/View/EndSetView.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.EndSetView"
7
             x:DataType="vm:EndSetViewModel">
8

  
9
    <Grid>
10
        <StackLayout BackgroundColor="White" Spacing="50">
11

  
12
            <tools:ConnectionIndicatorView />
13
            <ScrollView>
14
                <StackLayout Spacing="50">
15

  
16
                    <Label Text="Cloturer la série ?"
17
                       FontSize="22"
18
                       FontAttributes="Bold"
19
                       HorizontalOptions="Center"/>
20

  
21
                    <Label
22
                        Text="{Binding NumberAnimal, StringFormat='Nombre d animaux étudiés : {0}'}"
23
                        FontSize="16"
24
                        HorizontalOptions="Center" />
25

  
26
                    <Label
27
                        Text="{Binding NumberMeasure, StringFormat='Nombre de mesures : {0}'}"
28
                        FontSize="16"
29
                        HorizontalOptions="Center" />
30

  
31
                    <Label
32
                        Text="{Binding NumberBehaviour, StringFormat='Nombre de comportements : {0}'}"
33
                        FontSize="16"
34
                        HorizontalOptions="Center" />
35

  
36
                </StackLayout>
37
            </ScrollView>
38
            <StackLayout
39
                Margin="10"
40
                HorizontalOptions="CenterAndExpand"
41
                Orientation="Horizontal"
42
                VerticalOptions="FillAndExpand">
43

  
44
                <Button 
45
                    Text="Confirmer"
46
                    Command="{Binding GoToCreateDayCommand}"
47
                    Style="{StaticResource btnNormal}"
48
                    VerticalOptions="End"/>
49
            </StackLayout>
50
        </StackLayout>
51
        <Grid Grid.RowSpan="1" IsVisible="{Binding IsBusy}">
52
            <Border StrokeThickness="0"
53
                Background="Black"
54
                Opacity="0.5"
55
                Padding="20"
56
                WidthRequest="160"
57
                HeightRequest="160"
58
                HorizontalOptions="Center"
59
                VerticalOptions="Center"
60
                StrokeShape="RoundRectangle 20">
61

  
62
                <VerticalStackLayout HorizontalOptions="Center" VerticalOptions="Center">
63
                    <ActivityIndicator IsRunning="True" Color="White" />
64
                    <Label Text="Chargement..."
65
                        FontSize="14"
66
                        TextColor="white"
67
                        HorizontalOptions="Center"/>
68
                </VerticalStackLayout>
69
            </Border>
70
        </Grid>
71

  
72
    </Grid>
73
</ContentPage>
GES_PAC/View/EndSetView.xaml.cs
1
using GES_PAC.ViewModel;
2

  
3
namespace GES_PAC.View
4
{
5
    public partial class EndSetView
6
    {
7
        public EndSetView()
8
        {
9
            InitializeComponent();
10
            BindingContext = new EndSetViewModel();
11
        }
12
    }
13
}
GES_PAC/View/MainView.xaml
14 14
                <StackLayout Spacing="100">
15 15

  
16 16
                    <Label Text="Bonjour"
17
               FontSize="22"
18
               FontAttributes="Bold"
19
               HorizontalOptions="Center"/>
17
                        FontSize="22"
18
                        FontAttributes="Bold"
19
                        HorizontalOptions="Center"/>
20 20

  
21 21
                    <Label Text="Pas de journée disponible"
22
               FontSize="18"
23
               HorizontalOptions="Center"/>
22
                        FontSize="18"
23
                        HorizontalOptions="Center"/>
24 24

  
25 25
                    <Label Text="Créez une journée pour commencer"
26
               FontSize="16"
27
               HorizontalOptions="Center"
28
               Padding="10"/>
26
                        FontSize="16"
27
                        HorizontalOptions="Center"
28
                        Padding="10"/>
29 29

  
30 30
                </StackLayout>
31 31
            </ScrollView>
......
36 36
                VerticalOptions="FillAndExpand">
37 37

  
38 38
                <Button 
39
                            Text="Créer une journée"
40
                            Command="{Binding GoToCreateDayCommand}"
41
                            Style="{StaticResource btnNormal}"
42
                            VerticalOptions="End"/>
39
                    Text="Créer une journée"
40
                    Command="{Binding GoToCreateDayCommand}"
41
                    Style="{StaticResource btnNormal}"
42
                    VerticalOptions="End"/>
43 43
            </StackLayout>
44 44
        </StackLayout>
45 45
        <Grid Grid.RowSpan="1" IsVisible="{Binding IsBusy}">
46 46
            <Border StrokeThickness="0"
47
                            Background="Black"
48
                            Opacity="0.5"
49
                            Padding="20"
50
                            WidthRequest="160"
51
                            HeightRequest="160"
52
                            HorizontalOptions="Center"
53
                            VerticalOptions="Center"
54
                            StrokeShape="RoundRectangle 20">
47
                Background="Black"
48
                Opacity="0.5"
49
                Padding="20"
50
                WidthRequest="160"
51
                HeightRequest="160"
52
                HorizontalOptions="Center"
53
                VerticalOptions="Center"
54
                StrokeShape="RoundRectangle 20">
55 55

  
56 56
                <VerticalStackLayout HorizontalOptions="Center" VerticalOptions="Center">
57 57
                    <ActivityIndicator IsRunning="True" Color="White" />
58 58
                    <Label Text="Chargement..."
59
                            FontSize="14"
60
                            TextColor="white"
61
                            HorizontalOptions="Center"/>
59
                        FontSize="14"
60
                        TextColor="white"
61
                        HorizontalOptions="Center"/>
62 62
                </VerticalStackLayout>
63 63
            </Border>
64 64
        </Grid>
GES_PAC/View/MainView.xaml.cs
7 7
        public MainView(MainViewModel mv)
8 8
        {
9 9
            InitializeComponent();
10
            this.BindingContext = mv;
10
            BindingContext = mv;
11 11
        }
12 12
    }
13 13
}
GES_PAC/View/SetListView.xaml
13 13
            <ScrollView>
14 14
                <StackLayout Spacing="100">
15 15

  
16
                    <Label Text="Pas de série disponible"
16
                    <Label Text="{Binding LastSetText}"
17 17
                        FontSize="18"
18 18
                        HorizontalOptions="Center"/>
19 19

  
20 20

  
21 21
                </StackLayout>
22 22
            </ScrollView>
23
            <StackLayout
24
                Margin="10"
25
                HorizontalOptions="CenterAndExpand"
26
                Orientation="Horizontal"
27
                VerticalOptions="FillAndExpand">
28

  
29
                <Button 
30
                    Text="Créer une série"
31
                    Command="{Binding GoToCreateSetCommand}"
32
                    Style="{StaticResource btnNormal}"
33
                    VerticalOptions="End"/>
34
            </StackLayout>
23
            <Grid ColumnDefinitions="*,Auto,*,Auto,*"  
24
                  HorizontalOptions="Center"  
25
                  VerticalOptions="FillAndExpand">
26

  
27
                <Button  
28
                    Grid.Column="1"  
29
                    Text="Reprendre la série"  
30
                    Command="{Binding GoToLastSetCommand}"  
31
                    Style="{StaticResource btnNormal}"  
32
                    VerticalOptions="End"  
33
                    HorizontalOptions="Start"  
34
                    IsVisible="{Binding HasLastSet}" 
35
                    Margin="0,0,20,20"/>
36

  
37
                <Button  
38
                    Grid.Column="3"  
39
                    Text="Créer une série"  
40
                    Command="{Binding GoToCreateSetCommand}"  
41
                    Style="{StaticResource btnNormal}"  
42
                    VerticalOptions="End"  
43
                    HorizontalOptions="End" 
44
                    Margin="20,0,0,20"/>
45
            </Grid>
46

  
35 47
        </StackLayout>
36 48
        <Grid Grid.RowSpan="1" IsVisible="{Binding IsBusy}">
37 49
            <Border StrokeThickness="0"
GES_PAC/ViewModel/ChambersViewModel.cs
1 1
using GES_PAC.Model;
2
using GES_PAC.View;
2 3
using System.Windows.Input;
3 4

  
4 5
namespace GES_PAC.ViewModel
......
15 16
        #endregion
16 17

  
17 18
        #region Propriétés
18
        public Serie CurrentSet { get; set; }
19 19

  
20 20
        #endregion
21 21

  
22 22
        #region Constructeurs
23 23
        public ChambersViewModel()
24 24
        {
25
            CurrentSet = JourneeViewModel.Instance.GetCurrentSet();
25
            TerminateSetCommand = new Command(async () => await TerminateSet());
26 26
        }
27 27
        #endregion
28 28

  
29 29
        #region Méthodes
30
        
30
        private async Task TerminateSet()
31
        {
32
            if (IsBusy) return;
33
            IsBusy = true;
34
            await Shell.Current.GoToAsync(nameof(EndSetView));
35
            IsBusy = false;
36
        }
31 37
        #endregion
32 38
    }
33 39
}
GES_PAC/ViewModel/EndSetViewModel.cs
1
using GES_PAC.Model;
2
using GES_PAC.Services;
3
using GES_PAC.View;
4

  
5
namespace GES_PAC.ViewModel
6
{
7
    public class EndSetViewModel : BaseViewModel
8
    {
9
        #region Attributs
10
        private int _numberAnimal;
11
        private int _numberMeasure;
12
        private int _numberBehaviour;
13
        #endregion
14

  
15
        #region Commandes
16
        public Command GoToCreateDayCommand { get; }
17
        #endregion
18

  
19
        #region Propriétés
20
        public int NumberAnimal
21
        {
22
            get => _numberAnimal;
23
            set { 
24
                SetProperty(ref _numberAnimal, value); 
25
                OnPropertyChanged();
26
            }
27
        }
28
        public int NumberMeasure
29
        {
30
            get => _numberMeasure;
31
            set
32
            {
33
                SetProperty(ref _numberMeasure, value);
34
                OnPropertyChanged();
35
            }
36
        }
37
        public int NumberBehaviour
38
        {
39
            get => _numberBehaviour;
40
            set
41
            {
42
                SetProperty(ref _numberBehaviour, value);
43
                OnPropertyChanged();
44
            }
45
        }
46
        #endregion
47

  
48
        #region Constructeur
49
        public EndSetViewModel()
50
        {
51
            var serieActuelle = JourneeViewModel.Instance.GetCurrentSet();
52
            NumberAnimal = serieActuelle.GetAnimalCount();
53
            NumberMeasure = serieActuelle.GetMeasureCount();
54
            NumberBehaviour = serieActuelle.GetBehaviourCount();
55
            GoToCreateDayCommand = new Command(async () => await GoToCreateDayPage());
56
        }
57
        #endregion
58

  
59
        #region Méthodes
60
        private async Task GoToCreateDayPage()
61
        {
62
            if (IsBusy) return;
63
            IsBusy = true;
64
            await Shell.Current.GoToAsync(nameof(SetListView));
65
            IsBusy = false;
66
        }
67
        #endregion
68
    }
69
}
GES_PAC/ViewModel/MainViewModel.cs
18 18
        public MainViewModel(ConnexionService connService)
19 19
        {
20 20
            //ONLY FOR TESTS
21
            var date = DateTime.Now;
22
            var newDay = new Journee(date, PersonViewModel.Instance.Persons[0], PlaceViewModel.Instance.Places[0], "");
23
            newDay.AddSet(new Serie(date, date, 25, 25, 25));
24
            newDay.GetCurrentSet().AddSerieAnimal(new SerieAnimal(1, 500, date, ""));
25
            newDay.GetCurrentSet().AddMeasure(new Mesure(date, 50, 50, 50), 1, false);
26
            JourneeViewModel.Instance.Journees.Add(newDay);
21
            //var date = DateTime.Now;
22
            //var newDay = new Journee(date, PersonViewModel.Instance.Persons[0], PlaceViewModel.Instance.Places[0], "");
23
            //newDay.AddSet(new Serie(date, date, 25, 25, 25));
24
            //newDay.GetCurrentSet().AddSerieAnimal(new SerieAnimal(1, 500, date, ""));
25
            //newDay.GetCurrentSet().AddMeasure(new Mesure(date, 50, 50, 50), 1, false);
26
            //JourneeViewModel.Instance.Journees.Add(newDay);
27 27
            //ONLY FOR TESTS
28 28

  
29 29
            this.connService = connService;
GES_PAC/ViewModel/SetListViewModel.cs
1 1
using System.Windows.Input;
2
using GES_PAC.Services;
3 2
using GES_PAC.View;
4 3

  
5 4

  
......
7 6
{
8 7
    public class SetListViewModel : BaseViewModel
9 8
    {
10
        #region Services
11
        private readonly ConnexionService connService;
9
        #region Attributs
10
        private bool _hasLastSet = false;
11
        #endregion
12

  
13
        #region Propriétés
14
        public bool HasLastSet
15
        {
16
            get => _hasLastSet;
17
            set
18
            {
19
                SetProperty(ref _hasLastSet, value);
20
                OnPropertyChanged();
21
            }
22
        }
23

  
24
        public string LastSetText => HasLastSet ? "Série existante. La reprendre ?" : "Aucune série trouvée";
12 25
        #endregion
13 26

  
14 27
        #region Commandes
15 28
        public ICommand GoToCreateSetCommand { get; }
29
        public ICommand GoToLastSetCommand { get; }
16 30
        #endregion
17 31

  
18 32
        #region Constructeur
19 33
        public SetListViewModel()
20 34
        {
21 35
            GoToCreateSetCommand = new Command(async () => await GoToCreateSetPage());
36
            GoToLastSetCommand = new Command(async () => await GoToLastSetPage());
37

  
38
            HasLastSet = JourneeViewModel.Instance.GetCurrentDay().HasAnySet();
22 39
        }
23 40
        #endregion
24 41

  
......
30 47
            await Shell.Current.GoToAsync(nameof(CreateSetView));
31 48
            IsBusy = false;
32 49
        }
50

  
51
        private async Task GoToLastSetPage()
52
        {
53
            if (IsBusy) return;
54
            IsBusy = true;
55
            await Shell.Current.GoToAsync(nameof(ChambersView));
56
            IsBusy = false;
57
        }
33 58
        #endregion
34 59
    }
35 60
}

Formats disponibles : Unified diff