Révision acb5dd8c
GES_PAC/AppShell.xaml | ||
---|---|---|
24 | 24 |
Route="CreatePlace" |
25 | 25 |
ContentTemplate="{DataTemplate local:CreatePlaceView}" /> |
26 | 26 |
|
27 |
<!-- ONLY FOR TESTS --> |
|
28 |
<ShellContent |
|
29 |
Title="Chambres (test)" |
|
30 |
Route="Chambers" |
|
31 |
ContentTemplate="{DataTemplate local:ChambersView}" /> |
|
32 |
|
|
33 | 27 |
<Shell.FlyoutFooter> |
34 | 28 |
<Grid Padding="10" ColumnDefinitions="auto,auto"> |
35 | 29 |
<Grid.GestureRecognizers> |
GES_PAC/Model/Calibration.cs | ||
---|---|---|
28 | 28 |
|
29 | 29 |
public bool IsComplete() |
30 | 30 |
{ |
31 |
return Mesures.Count == 3; |
|
31 |
return Mesures.Select(m => m.Type).Distinct().ToList().Count == 3;
|
|
32 | 32 |
} |
33 | 33 |
|
34 | 34 |
public List<TypeCalibration> GetTypesDone() |
GES_PAC/Model/Journee.cs | ||
---|---|---|
70 | 70 |
|
71 | 71 |
public Serie GetCurrentSet() |
72 | 72 |
{ |
73 |
return Series.Last(); |
|
73 |
return Series.LastOrDefault();
|
|
74 | 74 |
} |
75 | 75 |
public bool HasAnySet() |
76 | 76 |
{ |
... | ... | |
100 | 100 |
} |
101 | 101 |
internal Calibration GetDebutCalibration() |
102 | 102 |
{ |
103 |
return Calibrations.First(c => c.Phase == PhaseCalibration.Debut); |
|
103 |
return Calibrations.FirstOrDefault(c => c.Phase == PhaseCalibration.Debut); |
|
104 |
} |
|
105 |
internal bool IsCalibrationComplete(PhaseCalibration pc) |
|
106 |
{ |
|
107 |
return Calibrations.FirstOrDefault(c => c.Phase == pc)?.IsComplete() ?? false; |
|
108 |
} |
|
109 |
internal bool IsComplete() |
|
110 |
{ |
|
111 |
return Calibrations.FirstOrDefault(c => c.Phase == PhaseCalibration.Fin)?.IsComplete() ?? false; |
|
104 | 112 |
} |
105 | 113 |
#endregion |
106 | 114 |
} |
GES_PAC/Model/PhaseCalibration.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 PhaseCalibration |
GES_PAC/View/MainView.xaml | ||
---|---|---|
18 | 18 |
FontAttributes="Bold" |
19 | 19 |
HorizontalOptions="Center"/> |
20 | 20 |
|
21 |
<Label Text="Pas de journée disponible"
|
|
21 |
<Label Text="{Binding CurrentDayText}"
|
|
22 | 22 |
FontSize="18" |
23 | 23 |
HorizontalOptions="Center"/> |
24 | 24 |
|
25 |
<Label Text="Créez une journée pour commencer" |
|
26 |
FontSize="16" |
|
27 |
HorizontalOptions="Center" |
|
28 |
Padding="10"/> |
|
29 |
|
|
30 | 25 |
</StackLayout> |
31 | 26 |
</ScrollView> |
32 |
<StackLayout |
|
33 |
Margin="10" |
|
34 |
HorizontalOptions="CenterAndExpand" |
|
35 |
Orientation="Horizontal" |
|
36 |
VerticalOptions="FillAndExpand"> |
|
27 |
<StackLayout HorizontalOptions="Center" VerticalOptions="EndAndExpand" Spacing="75" Margin="0, 0, 0, 50"> |
|
28 |
<Button |
|
29 |
Text="Reprendre la journée" |
|
30 |
Command="{Binding ResumeDayCommand}" |
|
31 |
Style="{StaticResource btnNormal}" |
|
32 |
VerticalOptions="End" |
|
33 |
HorizontalOptions="Center" |
|
34 |
IsVisible="{Binding HasLastDay}"/> |
|
37 | 35 |
|
38 | 36 |
<Button |
39 | 37 |
Text="Créer une journée" |
GES_PAC/View/MainView.xaml.cs | ||
---|---|---|
9 | 9 |
InitializeComponent(); |
10 | 10 |
BindingContext = mv; |
11 | 11 |
} |
12 |
|
|
13 |
protected override void OnAppearing() |
|
14 |
{ |
|
15 |
base.OnAppearing(); |
|
16 |
|
|
17 |
if (BindingContext is MainViewModel viewModel) |
|
18 |
{ |
|
19 |
viewModel.GetLastDay(); |
|
20 |
} |
|
21 |
} |
|
12 | 22 |
} |
13 | 23 |
} |
GES_PAC/View/SetListView.xaml | ||
---|---|---|
11 | 11 |
|
12 | 12 |
<tools:ConnectionIndicatorView /> |
13 | 13 |
<ScrollView> |
14 |
<StackLayout Spacing="100"> |
|
15 |
|
|
16 |
<Label Text="{Binding LastSetText}" |
|
14 |
<StackLayout Spacing="100"> |
|
15 |
|
|
16 |
<Label Text="Sélectionnez une série" |
|
17 |
FontSize="22" |
|
18 |
FontAttributes="Bold" |
|
19 |
HorizontalOptions="Center"/> |
|
20 |
|
|
21 |
<Label Text="{Binding LastSetText}" |
|
17 | 22 |
FontSize="18" |
18 | 23 |
HorizontalOptions="Center"/> |
19 | 24 |
|
GES_PAC/View/SetListView.xaml.cs | ||
---|---|---|
9 | 9 |
InitializeComponent(); |
10 | 10 |
BindingContext = new SetListViewModel(); |
11 | 11 |
} |
12 |
protected override void OnAppearing() |
|
13 |
{ |
|
14 |
base.OnAppearing(); |
|
15 |
if (BindingContext is SetListViewModel viewModel) |
|
16 |
{ |
|
17 |
viewModel.GetLastSet(); |
|
18 |
} |
|
19 |
} |
|
12 | 20 |
} |
GES_PAC/ViewModel/JourneeViewModel.cs | ||
---|---|---|
22 | 22 |
public Journee GetCurrentDay() |
23 | 23 |
{ |
24 | 24 |
DateTime today = DateTime.Today; |
25 |
return Journees.FirstOrDefault(j => j.Date.Date == today);
|
|
25 |
return Journees.LastOrDefault(j => j.Date.Date == today);
|
|
26 | 26 |
} |
27 | 27 |
public PhaseCalibration GetCurrentPhase() |
28 | 28 |
{ |
GES_PAC/ViewModel/MainViewModel.cs | ||
---|---|---|
1 | 1 |
using GES_PAC.Model; |
2 | 2 |
using GES_PAC.Services; |
3 | 3 |
using GES_PAC.View; |
4 |
using System.Windows.Input; |
|
4 | 5 |
|
5 | 6 |
namespace GES_PAC.ViewModel |
6 | 7 |
{ |
7 |
public class MainViewModel : BaseViewModel |
|
8 |
public class MainViewModel : BaseViewModel
|
|
8 | 9 |
{ |
10 |
#region Attributs |
|
11 |
private bool _hasLastDay = false; |
|
12 |
private Journee _currentDay; |
|
13 |
private string _currentDayText; |
|
14 |
#endregion |
|
15 |
|
|
9 | 16 |
#region Services |
10 | 17 |
private readonly ConnexionService connService; |
11 | 18 |
#endregion |
12 | 19 |
|
13 | 20 |
#region Commandes |
14 |
public Command GoToCreateDayCommand { get; } |
|
21 |
public ICommand GoToCreateDayCommand { get; } |
|
22 |
public ICommand ResumeDayCommand { get; } |
|
23 |
#endregion |
|
24 |
|
|
25 |
#region Propriétés |
|
26 |
public bool HasLastDay |
|
27 |
{ |
|
28 |
get => _hasLastDay; |
|
29 |
set |
|
30 |
{ |
|
31 |
SetProperty(ref _hasLastDay, value); |
|
32 |
OnPropertyChanged(); |
|
33 |
} |
|
34 |
} |
|
35 |
public Journee CurrentDay |
|
36 |
{ |
|
37 |
get => _currentDay; |
|
38 |
set |
|
39 |
{ |
|
40 |
SetProperty(ref _currentDay, value); |
|
41 |
OnPropertyChanged(); |
|
42 |
} |
|
43 |
} |
|
44 |
public string CurrentDayText |
|
45 |
{ |
|
46 |
get => _currentDayText; |
|
47 |
set |
|
48 |
{ |
|
49 |
SetProperty(ref _currentDayText, value); |
|
50 |
OnPropertyChanged(); |
|
51 |
} |
|
52 |
} |
|
15 | 53 |
#endregion |
16 | 54 |
|
17 | 55 |
#region Constructeur |
18 | 56 |
public MainViewModel(ConnexionService connService) |
19 | 57 |
{ |
20 | 58 |
//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.AddCalibration(new MesureCalibration(date, 50, 40, 500, TypeCalibration.Air, ""), PhaseCalibration.Debut); |
|
25 |
newDay.AddCalibration(new MesureCalibration(date, 0, 0, 1000000, TypeCalibration.Methane, "dazdazd"), PhaseCalibration.Debut); |
|
26 |
newDay.AddCalibration(new MesureCalibration(date, 30, 30, 3000, TypeCalibration.Melange, "deqsfsdf"), PhaseCalibration.Debut); |
|
27 |
newDay.GetCurrentSet().AddSerieAnimal(new SerieAnimal(1, 500, date, "")); |
|
28 |
newDay.GetCurrentSet().AddMeasure(new Mesure(date, 50, 50, 50), 1, false); |
|
29 |
JourneeViewModel.Instance.Journees.Add(newDay); |
|
59 |
//var date = DateTime.Now;
|
|
60 |
//var newDay = new Journee(date, PersonViewModel.Instance.Persons[0], PlaceViewModel.Instance.Places[0], "");
|
|
61 |
//newDay.AddSet(new Serie(date, date, 25, 25, 25));
|
|
62 |
//newDay.AddCalibration(new MesureCalibration(date, 50, 40, 500, TypeCalibration.Air, ""), PhaseCalibration.Debut);
|
|
63 |
//newDay.AddCalibration(new MesureCalibration(date, 0, 0, 1000000, TypeCalibration.Methane, "dazdazd"), PhaseCalibration.Debut);
|
|
64 |
//newDay.AddCalibration(new MesureCalibration(date, 30, 30, 3000, TypeCalibration.Melange, "deqsfsdf"), PhaseCalibration.Debut);
|
|
65 |
//newDay.GetCurrentSet().AddSerieAnimal(new SerieAnimal(1, 500, date, ""));
|
|
66 |
//newDay.GetCurrentSet().AddMeasure(new Mesure(date, 50, 50, 50), 1, false);
|
|
67 |
//JourneeViewModel.Instance.Journees.Add(newDay);
|
|
30 | 68 |
//ONLY FOR TESTS |
31 | 69 |
|
32 |
this.connService = connService; |
|
33 | 70 |
GoToCreateDayCommand = new Command(async () => await GoToCreateDayPage()); |
71 |
ResumeDayCommand = new Command(async () => await ResumeDay()); |
|
72 |
|
|
73 |
this.connService = connService; |
|
74 |
|
|
75 |
GetLastDay(); |
|
34 | 76 |
} |
35 | 77 |
#endregion |
36 | 78 |
|
37 | 79 |
#region Méthodes |
80 |
|
|
81 |
public void GetLastDay() |
|
82 |
{ |
|
83 |
CurrentDay = JourneeViewModel.Instance.GetCurrentDay(); |
|
84 |
HasLastDay = !CurrentDay?.IsComplete() ?? false; |
|
85 |
CurrentDayText = HasLastDay ? "Une journée en cours, la reprendre ?" : "Aucune journée trouvée, en créer une ?"; |
|
86 |
|
|
87 |
} |
|
38 | 88 |
private async Task GoToCreateDayPage() |
39 | 89 |
{ |
40 | 90 |
if (IsBusy) return; |
... | ... | |
42 | 92 |
await Shell.Current.GoToAsync(nameof(CreateDayView)); |
43 | 93 |
IsBusy = false; |
44 | 94 |
} |
95 |
|
|
96 |
private async Task ResumeDay() |
|
97 |
{ |
|
98 |
if (IsBusy) return; |
|
99 |
IsBusy = true; |
|
100 |
|
|
101 |
CurrentDay = JourneeViewModel.Instance.GetCurrentDay(); |
|
102 |
var targetView = nameof(CreateCalibrationView); |
|
103 |
if (CurrentDay.IsCalibrationComplete(PhaseCalibration.Debut)) |
|
104 |
targetView = nameof(SetListView); |
|
105 |
|
|
106 |
await Shell.Current.GoToAsync(targetView); |
|
107 |
IsBusy = false; |
|
108 |
} |
|
45 | 109 |
#endregion |
46 | 110 |
} |
47 | 111 |
} |
GES_PAC/ViewModel/SetListViewModel.cs | ||
---|---|---|
8 | 8 |
{ |
9 | 9 |
#region Attributs |
10 | 10 |
private bool _hasLastSet = false; |
11 |
public string _lastSetText; |
|
11 | 12 |
#endregion |
12 | 13 |
|
13 | 14 |
#region Propriétés |
... | ... | |
20 | 21 |
OnPropertyChanged(); |
21 | 22 |
} |
22 | 23 |
} |
23 |
|
|
24 |
public string LastSetText => HasLastSet ? "Série existante. La reprendre ?" : "Aucune série trouvée"; |
|
24 |
public string LastSetText |
|
25 |
{ |
|
26 |
get => _lastSetText; |
|
27 |
set |
|
28 |
{ |
|
29 |
SetProperty(ref _lastSetText, value); |
|
30 |
OnPropertyChanged(); |
|
31 |
} |
|
32 |
} |
|
25 | 33 |
#endregion |
26 | 34 |
|
27 | 35 |
#region Commandes |
... | ... | |
37 | 45 |
GoToLastSetCommand = new Command(async () => await GoToLastSetPage()); |
38 | 46 |
GoToEndDayCommand = new Command(async () => await GoToEndDayPage()); |
39 | 47 |
|
40 |
HasLastSet = JourneeViewModel.Instance.GetCurrentDay().HasAnySet();
|
|
48 |
GetLastSet();
|
|
41 | 49 |
} |
42 | 50 |
#endregion |
43 | 51 |
|
... | ... | |
64 | 72 |
await Shell.Current.GoToAsync(nameof(EndDayView)); |
65 | 73 |
IsBusy = false; |
66 | 74 |
} |
75 |
public void GetLastSet() |
|
76 |
{ |
|
77 |
HasLastSet = JourneeViewModel.Instance.GetCurrentDay()?.HasAnySet() ?? false; |
|
78 |
LastSetText = HasLastSet ? "Une série en cours, la reprendre ?" : "Aucune série trouvée, en créer une ?"; |
|
79 |
} |
|
67 | 80 |
#endregion |
68 | 81 |
} |
69 | 82 |
} |
GES_PAC/ViewModel/TypeCalibrationViewModel.cs | ||
---|---|---|
1 |
using GES_PAC.Model; |
|
2 |
using System; |
|
3 |
using System.Collections.Generic; |
|
4 |
using System.Collections.ObjectModel; |
|
5 |
using System.Linq; |
|
6 |
using System.Text; |
|
7 |
using System.Threading.Tasks; |
|
8 |
|
|
9 |
namespace GES_PAC.ViewModel |
|
10 |
{ |
|
11 |
public class TypeCalibrationViewModel |
|
12 |
{ |
|
13 |
public ObservableCollection<TypeCalibration> Calibrations { get; } |
|
14 |
|
|
15 |
public TypeCalibrationViewModel() |
|
16 |
{ |
|
17 |
Calibrations = new ObservableCollection<TypeCalibration>(TypeCalibration.All); |
|
18 |
} |
|
19 |
} |
|
20 |
} |
Formats disponibles : Unified diff