diff --git a/ParionsCuite/ParionsCuite/MainPage.xaml b/ParionsCuite/ParionsCuite/MainPage.xaml
index b1e5b71..102d226 100644
--- a/ParionsCuite/ParionsCuite/MainPage.xaml
+++ b/ParionsCuite/ParionsCuite/MainPage.xaml
@@ -16,12 +16,16 @@
-
+
+
+
+
+
@@ -29,27 +33,20 @@
-
-
-
-
-
+
+
+
+
-
+
diff --git a/ParionsCuite/ParionsCuite/MainPage.xaml.cs b/ParionsCuite/ParionsCuite/MainPage.xaml.cs
index 2308431..fa40c91 100644
--- a/ParionsCuite/ParionsCuite/MainPage.xaml.cs
+++ b/ParionsCuite/ParionsCuite/MainPage.xaml.cs
@@ -1,5 +1,6 @@
using System;
using System.Collections.ObjectModel;
+using System.Diagnostics;
using Microsoft.Maui.Controls;
using Microsoft.Maui.Platform;
using Microsoft.VisualBasic;
@@ -12,57 +13,102 @@ namespace ParionsCuite;
public partial class MainPage : ContentPage
{
+ public Manageur mgr => (App.Current as App).MyManager;
+
+ Evenement EventSelect { get; set; }
+
public MainPage()
{
InitializeComponent();
this.BindingContext = this;
- }
+ mgr.EvenementAdded += OnEvenementAdded;
-
- public void VueInfo(object sender, EventArgs e)
+ }
+ private void OnEvenementAdded(Evenement evenement)
{
- //changervue
+ // Logique à exécuter lorsque un événement est ajouté
+ Debug.WriteLine("Événement ajoutéz : " + evenement.Nom);
+ Button newButton = new Button
+ {
+ Text = evenement.Nom,
+ VerticalOptions = LayoutOptions.Center,
+ HorizontalOptions = LayoutOptions.Center,
+
+ };
+ newButton.Clicked += (sender, e) =>
+ {
+ // Appel de la méthode qui récupère l'événement associé
+ SelectEvent(evenement);
+ var newPage = new Views.Accueil();
+
+ changeButton.Content = newPage;
+ };
+
+ // Ajout du bouton au ButtonStackLayout
+ ButtonStackLayout.Children.Add(newButton); ;
}
+ public void SelectEvent(Evenement evenement)
+ {
+ Debug.WriteLine("Événement cliqué : " + evenement.Nom);
+ Debug.WriteLine("Date : " + evenement.Date);
+ Debug.WriteLine("Lieu : " + evenement.Lieu);
+ Debug.WriteLine("Heure : " + evenement.Heure);
+ EventSelect = evenement;
+ }
+
+
+
+
+
+ // Acces View Groupe
public void Button_Clicked(object sender, EventArgs e)
{
var newPage = new Views.Groupe();
- // Définissez le contenu de la ContentView sur la nouvelle page
changeButton.Content = newPage;
}
+ // Acces view Invite
private void InviteView(object sender, EventArgs e)
{
- var newPage = new Views.Invite.Inviter();
+ if (EventSelect == null) { return; }
+ var newPage = new Views.Invite.Inviter(EventSelect);
- // Définissez le contenu de la ContentView sur la nouvelle page
changeButton.Content = newPage;
}
+ // Acces view Participant
private void ParticipantView(object sender, EventArgs e)
{
- var newPage = new Views.Participations.Nourriture();
+ if (EventSelect == null) { return; }
+
+ var newPage = new Views.Participations.Nourriture(EventSelect);
- // Définissez le contenu de la ContentView sur la nouvelle page
changeButton.Content = newPage;
}
+
+ //Acces View Pari
private void PariView(object sender, EventArgs e)
{
+ //if (EventSelect == null) { return; }
+
var newPage = new Views.Pari.Parier();
- // Définissez le contenu de la ContentView sur la nouvelle page
changeButton.Content = newPage;
}
+
+ // Acces View Information
private void InfoView(object sender, EventArgs e)
{
- var newPage = new Views.Information.Info();
+ if (EventSelect == null) { return; }
+
+ var newPage = new Views.Information.Info(EventSelect);
- // Définissez le contenu de la ContentView sur la nouvelle page
changeButton.Content = newPage;
}
diff --git a/ParionsCuite/ParionsCuite/Modeles/Evenement.cs b/ParionsCuite/ParionsCuite/Modeles/Evenement.cs
index 85080e5..1109526 100644
--- a/ParionsCuite/ParionsCuite/Modeles/Evenement.cs
+++ b/ParionsCuite/ParionsCuite/Modeles/Evenement.cs
@@ -1,7 +1,9 @@
using ParionsCuite.Views.Invite;
using System;
using System.Collections.Generic;
+using System.ComponentModel;
using System.Linq;
+using System.Runtime.CompilerServices;
using System.Runtime.Serialization;
using System.Text;
using System.Threading.Tasks;
@@ -9,8 +11,12 @@ using System.Threading.Tasks;
namespace ParionsCuite.Modeles
{
[DataContract]
- public class Evenement
+ public class Evenement : INotifyPropertyChanged
{
+ public event PropertyChangedEventHandler? PropertyChanged;
+
+ void OnPropertyChanged([CallerMemberName] string propertyName = null)
+ => PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
/* Déclaration */
[DataMember]
public string Nom { get; private set; }
diff --git a/ParionsCuite/ParionsCuite/Modeles/Manageur.cs b/ParionsCuite/ParionsCuite/Modeles/Manageur.cs
index fbe4718..02a9ee9 100644
--- a/ParionsCuite/ParionsCuite/Modeles/Manageur.cs
+++ b/ParionsCuite/ParionsCuite/Modeles/Manageur.cs
@@ -2,7 +2,9 @@
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.ComponentModel;
+using System.Diagnostics;
using System.Linq;
+using System.Runtime.CompilerServices;
using System.Security.Cryptography.X509Certificates;
using System.Text;
using System.Threading.Tasks;
@@ -13,7 +15,32 @@ namespace ParionsCuite.Modeles
{
public event PropertyChangedEventHandler PropertyChanged;
- public ObservableCollection Evenement { get; private set; }
+ public event Action EvenementAdded;
+
+ private ObservableCollection evenement;
+
+ void OnPropertyChanged([CallerMemberName] string propertyName = null)
+ => PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
+ public ObservableCollection Evenement
+ {
+ get { return evenement; }
+ set
+ {
+ if (evenement != value)
+ {
+ evenement = value;
+ OnPropertyChanged();
+ OnEvenementAdded(value.LastOrDefault()); // Appel de la fonction après ajout d'un événement
+ }
+ }
+ }
+
+ private void OnEvenementAdded(Evenement evenement)
+ {
+ // Logique à exécuter lorsque un événement est ajouté
+ Debug.WriteLine("Événement ajouté : ");
+
+ }
public List Invites { get; set; }
public IPersistanceManager Persistance { get; set; }
@@ -37,13 +64,10 @@ namespace ParionsCuite.Modeles
public bool Ajout_evenement(Evenement ev)
{
- Evenement.Add(ev);
- foreach (Evenement e in Evenement)
- {
- if (e == ev)
- return true;
- }
- return false;
+ Evenement.Add(ev);
+ OnPropertyChanged(nameof(Evenement));
+ EvenementAdded?.Invoke(ev);
+ return true;
}
public bool Supprimer_evenement(Evenement ev)
diff --git a/ParionsCuite/ParionsCuite/ParionsCuite.csproj b/ParionsCuite/ParionsCuite/ParionsCuite.csproj
index 78663ed..202f7a8 100644
--- a/ParionsCuite/ParionsCuite/ParionsCuite.csproj
+++ b/ParionsCuite/ParionsCuite/ParionsCuite.csproj
@@ -44,6 +44,14 @@
+
+
+
+
+
+
+
+
@@ -63,6 +71,9 @@
MSBuild:Compile
+
+ MSBuild:Compile
+
@@ -82,7 +93,6 @@
-
diff --git a/ParionsCuite/ParionsCuite/Views/Groupe.xaml.cs b/ParionsCuite/ParionsCuite/Views/Groupe.xaml.cs
index 1a988f0..4c664d4 100644
--- a/ParionsCuite/ParionsCuite/Views/Groupe.xaml.cs
+++ b/ParionsCuite/ParionsCuite/Views/Groupe.xaml.cs
@@ -7,7 +7,7 @@ namespace ParionsCuite.Views;
public partial class Groupe : ContentView
{
- public Manageur mgr = new Manageur();
+ public Manageur mgr => (App.Current as App).MyManager;
public ObservableCollection Evenements { get; set; } = new ObservableCollection();
public Groupe()
diff --git a/ParionsCuite/ParionsCuite/Views/Information/Info.xaml b/ParionsCuite/ParionsCuite/Views/Information/Info.xaml
index f4f6ab0..6f45c8f 100644
--- a/ParionsCuite/ParionsCuite/Views/Information/Info.xaml
+++ b/ParionsCuite/ParionsCuite/Views/Information/Info.xaml
@@ -2,23 +2,25 @@
-
+
-
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
diff --git a/ParionsCuite/ParionsCuite/Views/Information/Info.xaml.cs b/ParionsCuite/ParionsCuite/Views/Information/Info.xaml.cs
index fe41faf..fffdd10 100644
--- a/ParionsCuite/ParionsCuite/Views/Information/Info.xaml.cs
+++ b/ParionsCuite/ParionsCuite/Views/Information/Info.xaml.cs
@@ -1,5 +1,6 @@
using ParionsCuite.Modeles;
using System.Diagnostics;
+using System.Xml.Linq;
namespace ParionsCuite.Views.Information;
@@ -7,20 +8,29 @@ public partial class Info : ContentView
{
public Manageur mgr => (App.Current as App).MyManager;
- public Info()
+ public Info(Evenement EventSelect)
{
InitializeComponent();
- MiseAJourInfo();
+ MiseAJourInfo(EventSelect);
BindingContext = this;
- }
+
- public Manageur m = new Manageur();
+ }
- public void MiseAJourInfo()
+ public Manageur m = new Manageur();
+ public const int DefaultCellHeight = 40;
+ public void MiseAJourInfo(Evenement EventSelect)
{
- int NbInvite = m.LenListInvite(m.Invites);
- Debug.WriteLine(NbInvite);
- }
+ NomEvent.Detail = EventSelect.Nom;
+ DateEvent.Detail = EventSelect.Date;
+ int i = EventSelect.ListInviter.Count();
+ NbInvite.Detail = i.ToString();
+ int v = EventSelect.ListParier.Count();
+ NbPari.Detail = v.ToString();
+ AdresseEvent.Detail = EventSelect.Lieu;
+ HoraireEvent.Detail = v.ToString();
+
+ }
diff --git a/ParionsCuite/ParionsCuite/Views/Invite/Inviter.xaml.cs b/ParionsCuite/ParionsCuite/Views/Invite/Inviter.xaml.cs
index 4cfd0af..b66c55e 100644
--- a/ParionsCuite/ParionsCuite/Views/Invite/Inviter.xaml.cs
+++ b/ParionsCuite/ParionsCuite/Views/Invite/Inviter.xaml.cs
@@ -7,23 +7,23 @@ public partial class Inviter : ContentView
{
public Manageur mgr => (App.Current as App).MyManager;
+ private readonly Evenement EventSelect;
public Modeles.Inviter Inviters { get; private set; } = new Modeles.Inviter();
- public Inviter()
+ public Inviter(Evenement EventSelect)
{
+ this.EventSelect = EventSelect;
InitializeComponent();
- restoreListInvite();
+ restoreListInvite(EventSelect);
BindingContext = this;
}
- void ColumnDefinition_SizeChanged(System.Object sender, System.EventArgs e)
- {
- }
- public void restoreListInvite()
+
+ public void restoreListInvite(Evenement EventSelect)
{
- List listInvite = mgr.ReturnListInvite();
+ List listInvite = EventSelect.ListInviter;
Debug.WriteLine(listInvite);
- int len = listInvite.Count;
+ int len = 1;
foreach (Modeles.Inviter inviter in listInvite) {
RowDefinition row = new RowDefinition();
row.Height = new GridLength(45);
@@ -48,12 +48,16 @@ public partial class Inviter : ContentView
Button buttonMoins = new Button();
buttonMoins.Text = "-";
+ buttonMoins.Clicked += BoutonSupprimer_Clicked;
Grid.SetRow(buttonMoins, len);
Grid.SetColumn(buttonMoins, 2);
GrilleInvite.Children.Add(buttonMoins);
len++;
+ Debug.WriteLine("Test test");
+
}
+
}
private void AddInvitelist(object sender, EventArgs e)
@@ -61,14 +65,15 @@ public partial class Inviter : ContentView
//restoreListInvite();
string nom = nomEditor.Text;
string prenom = prenomEditor.Text;
- if (nom == null || prenom == null) { return; }
+ if (nom == null || prenom == null || nom == "" || prenom == "") { return; }
Modeles.Inviter invite1 = new Modeles.Inviter(nom, prenom);
- List invites = mgr.AddInvite(invite1);
+ EventSelect.ListInviter.Add(invite1);
+;
int len = 1;
//if (len == 0 ) { len = 1; }
- Debug.WriteLine("LA taille de la liste est de " + mgr.LenListInvite(invites));
- foreach (Modeles.Inviter inviter in invites)
+ Debug.WriteLine("LA taille de la liste est de " + mgr.LenListInvite(EventSelect.ListInviter));
+ foreach (Modeles.Inviter inviter in EventSelect.ListInviter)
{
RowDefinition row = new RowDefinition();
row.Height = new GridLength(45);
@@ -100,7 +105,11 @@ public partial class Inviter : ContentView
//GrilleInvite.HeightRequest = Height + 2;
len = len +1 ;
+
+
}
+ prenomEditor.Text = "";
+ nomEditor.Text = "";
}
private void BoutonSupprimer_Clicked(object sender, EventArgs e)
@@ -115,9 +124,7 @@ public partial class Inviter : ContentView
int rowIndex = Grid.GetRow(button);
// Vérifier que l'indice rowIndex est valide
- if (rowIndex >= 0 && rowIndex < parentGrid.RowDefinitions.Count)
- {
- // Récupérer les labels correspondants à la ligne
+
Label prenomLabel = null;
Label nomLabel = null;
@@ -142,12 +149,12 @@ public partial class Inviter : ContentView
string nom = nomLabel.Text;
// Rechercher l'invité correspondant dans la liste
- Modeles.Inviter inviter = mgr.ReturnListInvite().FirstOrDefault(i => i.Prenom == prenom && i.Nom == nom);
+ Modeles.Inviter inviter = EventSelect.ListInviter.FirstOrDefault(i => i.Prenom == prenom && i.Nom == nom);
if (inviter != null)
{
- // Supprimer l'invité de la liste
- mgr.RemoveInviter(inviter);
+ // Supprimer l'invité de la liste
+ EventSelect.ListInviter.Remove(inviter);
// Supprimer les éléments de la ligne de la grille
parentGrid.Children.Remove(prenomLabel);
@@ -156,7 +163,6 @@ public partial class Inviter : ContentView
parentGrid.RowDefinitions.RemoveAt(rowIndex);
}
}
- }
}
}
diff --git a/ParionsCuite/ParionsCuite/Views/Participations/NewFolder1/Nourri.xaml b/ParionsCuite/ParionsCuite/Views/Participations/NewFolder1/Nourri.xaml
new file mode 100644
index 0000000..152e888
--- /dev/null
+++ b/ParionsCuite/ParionsCuite/Views/Participations/NewFolder1/Nourri.xaml
@@ -0,0 +1,37 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/ParionsCuite/ParionsCuite/Views/Participations/NewFolder1/Nourri.xaml.cs b/ParionsCuite/ParionsCuite/Views/Participations/NewFolder1/Nourri.xaml.cs
new file mode 100644
index 0000000..fda0f40
--- /dev/null
+++ b/ParionsCuite/ParionsCuite/Views/Participations/NewFolder1/Nourri.xaml.cs
@@ -0,0 +1,163 @@
+using ParionsCuite.Modeles;
+using ParionsCuite.Views.Participations;
+using System.Diagnostics;
+
+namespace ParionsCuite.Views.Participations.NewFolder1;
+
+public partial class Nourri : ContentView
+{
+ readonly Evenement EventSelect;
+
+ public Manageur mgr => (App.Current as App).MyManager;
+
+ public Nourri(Evenement EventSelect)
+ {
+ this.EventSelect = EventSelect;
+ InitializeComponent();
+ //restoreListInvite(EventSelect);
+ BindingContext = this;
+ }
+
+
+ public void restoreListInvite(Evenement EventSelect)
+ {
+
+ var listFood = EventSelect.Participation.Nourriture;
+ Debug.WriteLine(listFood);
+ int len = 1;
+ foreach (Modeles.Nourriture food in listFood)
+ {
+ RowDefinition row = new RowDefinition();
+ row.Height = new GridLength(45);
+ GridFood.RowDefinitions.Add(row);
+
+ // AJout Prenom
+ Label foodLabel = new Label();
+ foodLabel.Text = food.Nom;
+ Grid.SetRow(foodLabel, len);
+ Grid.SetColumn(foodLabel, 0);
+ GridFood.Children.Add(foodLabel);
+
+
+ // Ajout Nom
+ Label qteLabel = new Label();
+ food.Nom = food.Quantite.ToString();
+ Grid.SetRow(qteLabel, len);
+ Grid.SetColumn(qteLabel, 1);
+ GridFood.Children.Add(qteLabel);
+
+ // Ajout Bouton
+
+ Button buttonMoins = new Button();
+ buttonMoins.Text = "-";
+ buttonMoins.Clicked += BoutonSupprimer_Clicked;
+ Grid.SetRow(buttonMoins, len);
+ Grid.SetColumn(buttonMoins, 2);
+ GridFood.Children.Add(buttonMoins);
+
+ len++;
+ Debug.WriteLine("Test test");
+
+ }
+
+ }
+
+ private void AddFoodlist(object sender, EventArgs e)
+ {
+ //restoreListInvite();
+ string food = FoodInput.Text;
+ string qte = QteInput.Text;
+ if (food == null || qte == null) { return; }
+ Modeles.Nourriture food1 = new Modeles.Nourriture(food, Int32.Parse(qte));
+ EventSelect.Participation.Nourriture.Add(food1);
+ int len = 1;
+ //if (len == 0 ) { len = 1; }
+ foreach (Modeles.Nourriture food2 in EventSelect.Participation.Nourriture)
+ {
+ RowDefinition row = new RowDefinition();
+ row.Height = new GridLength(45);
+ GridFood.RowDefinitions.Add(row);
+
+ // AJout Prenom
+ Label foodLabel = new Label();
+ foodLabel.Text = food2.Nom;
+ Grid.SetRow(foodLabel, len);
+ Grid.SetColumn(foodLabel, 0);
+ GridFood.Children.Add(foodLabel);
+
+
+ // Ajout Nom
+ Label qteLabel = new Label();
+ food2.Nom = food2.Quantite.ToString();
+ Grid.SetRow(qteLabel, len);
+ Grid.SetColumn(qteLabel, 1);
+ GridFood.Children.Add(qteLabel);
+
+ // Ajout Bouton
+
+ Button buttonMoins = new Button();
+ buttonMoins.Text = "-";
+ buttonMoins.Clicked += BoutonSupprimer_Clicked;
+ Grid.SetRow(buttonMoins, len);
+ Grid.SetColumn(buttonMoins, 2);
+ GridFood.Children.Add(buttonMoins);
+
+ len++;
+ Debug.WriteLine("Test test");
+ }
+
+ }
+
+ private void BoutonSupprimer_Clicked(object sender, EventArgs e)
+ {
+ // Récupérer le bouton cliqué
+ Button button = (Button)sender;
+
+ // Récupérer la grille parente du bouton
+ Grid parentGrid = (Grid)button.Parent;
+
+ // Récupérer la ligne parente du bouton
+ int rowIndex = Grid.GetRow(button);
+
+ // Vérifier que l'indice rowIndex est valide
+
+ Label prenomLabel = null;
+ Label nomLabel = null;
+
+ // Parcourir les enfants de la grille pour trouver les labels de la ligne
+ foreach (View child in parentGrid.Children)
+ {
+ int childRowIndex = Grid.GetRow(child);
+
+ if (childRowIndex == rowIndex)
+ {
+ if (Grid.GetColumn(child) == 0)
+ prenomLabel = (Label)child;
+ else if (Grid.GetColumn(child) == 1)
+ nomLabel = (Label)child;
+ }
+ }
+
+ if (prenomLabel != null && nomLabel != null)
+ {
+ // Récupérer le prénom et le nom de l'invité à supprimer
+ string prenom = prenomLabel.Text;
+ string nom = nomLabel.Text;
+
+ // Rechercher l'invité correspondant dans la liste
+ Modeles.Inviter inviter = EventSelect.ListInviter.FirstOrDefault(i => i.Prenom == prenom && i.Nom == nom);
+
+ if (inviter != null)
+ {
+ // Supprimer l'invité de la liste
+ EventSelect.ListInviter.Remove(inviter);
+
+ // Supprimer les éléments de la ligne de la grille
+ parentGrid.Children.Remove(prenomLabel);
+ parentGrid.Children.Remove(nomLabel);
+ parentGrid.Children.Remove(button);
+ parentGrid.RowDefinitions.RemoveAt(rowIndex);
+ }
+ }
+ }
+}
\ No newline at end of file
diff --git a/ParionsCuite/ParionsCuite/Views/Participations/Nourriture.xaml b/ParionsCuite/ParionsCuite/Views/Participations/Nourriture.xaml
index bf1734c..ce72971 100644
--- a/ParionsCuite/ParionsCuite/Views/Participations/Nourriture.xaml
+++ b/ParionsCuite/ParionsCuite/Views/Participations/Nourriture.xaml
@@ -2,68 +2,26 @@
+ x:Class="ParionsCuite.Views.Participations.Nourriture"
+ xmlns:nourriture="clr-namespace:ParionsCuite.Views.Participations.NewFolder1"
+>
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
-
+
+
-
+
+
+
diff --git a/ParionsCuite/ParionsCuite/Views/Participations/Nourriture.xaml.cs b/ParionsCuite/ParionsCuite/Views/Participations/Nourriture.xaml.cs
index 8b764b2..bd80c6b 100644
--- a/ParionsCuite/ParionsCuite/Views/Participations/Nourriture.xaml.cs
+++ b/ParionsCuite/ParionsCuite/Views/Participations/Nourriture.xaml.cs
@@ -1,19 +1,43 @@
using ParionsCuite.Modeles;
+using ParionsCuite.Views.Participations;
namespace ParionsCuite.Views.Participations;
public partial class Nourriture : ContentView
{
- public Manageur Mng => (App.Current as App).MyManager;
+ public Manageur mgr => (App.Current as App).MyManager;
- public Nourriture()
+ Evenement EventSelect;
+ public Nourriture(Evenement EventSelect)
{
- BindingContext = Mng.Evenement[0].Participation;
- InitializeComponent();
+ InitializeComponent();
+ this.EventSelect = EventSelect;
}
- private void AjoutNourriture(object sender, EventArgs e)
+ private void NourritureView(object sender, EventArgs e)
{
+ if (EventSelect == null) { return; }
+ var newPage = new Views.Participations.NewFolder1.Nourri(EventSelect);
+
+ changeButton.Content = newPage;
+ }
+
+ private void BoissonView(object sender, EventArgs e)
+ {
+ if (EventSelect == null) { return; }
+
+ var newPage = new Views.Participations.NewFolder1.Nourri(EventSelect);
+
+ changeButton.Content = newPage;
+ }
+
+ private void AutreView(object sender, EventArgs e)
+ {
+ if (EventSelect == null) { return; }
+
+ var newPage = new Views.Participations.NewFolder1.Nourri(EventSelect);
+
+ changeButton.Content = newPage;
}
}