diff --git a/ParionsCuite/Modeles/Autre.cs b/ParionsCuite/Modeles/Autre.cs index 88025f8..5ddac75 100644 --- a/ParionsCuite/Modeles/Autre.cs +++ b/ParionsCuite/Modeles/Autre.cs @@ -1,28 +1,49 @@ using System; using System.Runtime.Serialization; - namespace ParionsCuite.Modeles { + /// + /// Represents an item of a different type. + /// [DataContract] public class Autre { + /// + /// Gets or sets the name of the item. + /// [DataMember] - public string Nom { get; set; } + public string Nom { get; set; } + /// + /// Gets or sets the quantity of the item. + /// [DataMember] - public int Quantite { get; set; } + public int Quantite { get; set; } + /// + /// Initializes a new instance of the class with the specified name and quantity. + /// + /// The name of the item. + /// The quantity of the item. public Autre(string nom, int qu) { Nom = nom; Quantite = qu; } + /// + /// Default constructor. + /// public Autre() { - + } + /// + /// Determines whether the specified object is equal to the current object. + /// + /// The object to compare with the current object. + /// True if the specified object is equal to the current object; otherwise, false. public override bool Equals(object obj) { if (ReferenceEquals(obj, null)) return false; @@ -31,15 +52,22 @@ namespace ParionsCuite.Modeles return Equals(obj as Autre); } + /// + /// Returns a string that represents the current object. + /// + /// A string that represents the current object. public override string ToString() { return $"nom : {Nom} \n"; } + /// + /// Serves as a hash function for a particular type. + /// + /// A hash code for the current object. public override int GetHashCode() { return HashCode.Combine(Nom); } } } - diff --git a/ParionsCuite/Modeles/Boissons.cs b/ParionsCuite/Modeles/Boissons.cs index fa114e1..4e6072c 100644 --- a/ParionsCuite/Modeles/Boissons.cs +++ b/ParionsCuite/Modeles/Boissons.cs @@ -1,29 +1,50 @@ using System; using System.Runtime.Serialization; using System.Security.Principal; - namespace ParionsCuite.Modeles { + /// + /// Represents a beverage item. + /// [DataContract] public class Boisson { + /// + /// Gets or sets the name of the beverage. + /// [DataMember] - public string Nom { get; set; } + public string Nom { get; set; } + /// + /// Gets or sets the quantity of the beverage. + /// [DataMember] - public int Quantite { get; set; } + public int Quantite { get; set; } + /// + /// Initializes a new instance of the class with the specified name and quantity. + /// + /// The name of the beverage. + /// The quantity of the beverage. public Boisson(string nom, int qu) { Nom = nom; Quantite = qu; } + /// + /// Default constructor. + /// public Boisson() { } + /// + /// Determines whether the specified object is equal to the current object. + /// + /// The object to compare with the current object. + /// True if the specified object is equal to the current object; otherwise, false. public override bool Equals(object obj) { if (ReferenceEquals(obj, null)) return false; @@ -32,15 +53,22 @@ namespace ParionsCuite.Modeles return Equals(obj as Boisson); } + /// + /// Returns a string that represents the current object. + /// + /// A string that represents the current object. public override string ToString() { return $"nom : {Nom} \n"; } + /// + /// Serves as a hash function for a particular type. + /// + /// A hash code for the current object. public override int GetHashCode() { return HashCode.Combine(Nom); } } } - diff --git a/ParionsCuite/Modeles/Evenement.cs b/ParionsCuite/Modeles/Evenement.cs index 0def1bd..0a2b3d4 100644 --- a/ParionsCuite/Modeles/Evenement.cs +++ b/ParionsCuite/Modeles/Evenement.cs @@ -12,33 +12,76 @@ using System.Threading.Tasks; namespace ParionsCuite.Modeles { + /// + /// Represents an event. + /// [DataContract] public class Evenement : INotifyPropertyChanged { + /// + /// Event that is raised when a property value changes. + /// public event PropertyChangedEventHandler? PropertyChanged; + /// + /// Raises the event for a specific property. + /// + /// The name of the property that changed. void OnPropertyChanged([CallerMemberName] string propertyName = null) => PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName)); - /* Déclaration */ + + /* Properties */ + + /// + /// Gets or private sets the name of the event. + /// [DataMember] public string Nom { get; private set; } + + /// + /// Gets or private sets the date of the event. + /// [DataMember] public string Date { get; private set; } + + /// + /// Gets or private sets the location of the event. + /// [DataMember] public string Lieu { get; private set; } + + /// + /// Gets or private sets the time of the event. + /// [DataMember] public string Heure { get; private set; } + /// + /// Gets the participation information for the event. + /// [DataMember] public Participation Participation { get; private set; } + + /// + /// Gets the list of invited guests for the event. + /// [DataMember] public List ListInviter { get; private set; } - + + /// + /// Event that is raised when a bet is added to the event. + /// public event Action PariAdd; + /// + /// Gets or private sets the list of bets for the event. + /// [DataMember] private ObservableCollection listParier; + /// + /// Gets or sets the list of bets for the event. + /// public ObservableCollection ListParier { get { return listParier; } @@ -48,19 +91,24 @@ namespace ParionsCuite.Modeles { listParier = value; OnPropertyChanged(); - OnPariAdded(value.LastOrDefault()); // Appel de la fonction après ajout d'un événement + OnPariAdded(value.LastOrDefault()); } } } + /* Methods */ - private void OnPariAdded(Parier parier) + private void OnPariAdded(Parier parier) { - // Logique à exécuter lorsque un événement est ajouté - Debug.WriteLine("Événement ajouté : "); - + // Logic to execute when a bet is added + Debug.WriteLine("Bet added: "); } + /// + /// Adds a bet to the event. + /// + /// The bet to add. + /// True if the bet was added successfully; otherwise, false. public bool Ajout_Pari(Parier pari) { ListParier.Add(pari); @@ -68,8 +116,14 @@ namespace ParionsCuite.Modeles PariAdd?.Invoke(pari); return true; } - /* Constructeur */ + /// + /// Initializes a new instance of the class with the specified name, date, location, and time. + /// + /// The name of the event. + /// The date of the event. + /// The location of the event. + /// The time of the event. public Evenement(string nom, string date, string lieu, string heure) { Nom = nom; @@ -80,6 +134,15 @@ namespace ParionsCuite.Modeles ListParier = new ObservableCollection(); Participation = new Participation(); } + + /// + /// Initializes a new instance of the class with the specified name, date, location, time, and participation information. + /// + /// The name of the event. + /// The date of the event. + /// The location of the event. + /// The time of the event. + /// The participation information for the event. public Evenement(string nom, string date, string lieu, string heure, Participation participation) { Nom = nom; @@ -91,12 +154,13 @@ namespace ParionsCuite.Modeles ListParier = new ObservableCollection(); } - public Evenement(List inviters, List participations, List pariers) - { + /* Inviter methods */ - } - - /* Méthode Inviter */ + /// + /// Adds a guest to the event's list of invited guests. + /// + /// The guest to add. + /// True if the guest was added successfully; otherwise, false. public bool Ajouter_inviter(Inviter I) { ListInviter.Add(I); @@ -108,11 +172,21 @@ namespace ParionsCuite.Modeles return false; } + /// + /// Removes a guest from the event's list of invited guests. + /// + /// The guest to remove. + /// True if the guest was removed successfully; otherwise, false. public bool Supprimer_inviter(Inviter inviter) { return ListInviter.Remove(inviter); } + /// + /// Returns the number of invited guests in the event's list. + /// + /// The list of invited guests. + /// The number of invited guests. public int LenListInvite(List list) { int len = 0; @@ -123,12 +197,22 @@ namespace ParionsCuite.Modeles return len; } + /// + /// Returns the list of invited guests for the event. + /// + /// The list of invited guests. public List ReturnListInvite() { return ListInviter; } - /* Méthode Parie */ + /* Parie methods */ + + /// + /// Adds a bet to the event's list of bets. + /// + /// The bet to add. + /// True if the bet was added successfully; otherwise, false. public bool Ajouter_parie(Parier parier) { ListParier.Add(parier); @@ -140,12 +224,25 @@ namespace ParionsCuite.Modeles return false; } + /// + /// Removes a bet from the event's list of bets. + /// + /// The bet to remove. + /// True if the bet was removed successfully; otherwise, false. public bool Supprimer_parie(Parier p) { return ListParier.Remove(p); } - /* Setter */ + /* Setter */ + + /// + /// Sets the event's information. + /// + /// The name of the event. + /// The date of the event. + /// The location of the event. + /// The time of the event. public void SetEvenement(string nom, string date, string lieu, string heure) { Nom = nom; @@ -155,6 +252,10 @@ namespace ParionsCuite.Modeles return; } + /// + /// Returns a string representation of the event. + /// + /// A string representation of the event. public override string ToString() { return $"Nom : {Nom} \nDate : {Date}\nLieu : {Lieu}\nHeure : {Heure} "; diff --git a/ParionsCuite/Modeles/IPersistanceManager.cs b/ParionsCuite/Modeles/IPersistanceManager.cs index 5e6d6a3..42ee232 100644 --- a/ParionsCuite/Modeles/IPersistanceManager.cs +++ b/ParionsCuite/Modeles/IPersistanceManager.cs @@ -2,12 +2,25 @@ using System.Collections.Generic; using System.Collections.ObjectModel; +using System.Collections.ObjectModel; + namespace ParionsCuite.Modeles { + /// + /// Defines the interface for a persistence manager. + /// public interface IPersistanceManager { - public ObservableCollection chargeDonnees(); - public void sauvegardeDonnees(ObservableCollection evenements); + /// + /// Loads the data and returns a collection of events. + /// + /// An of . + ObservableCollection chargeDonnees(); + + /// + /// Saves the data by taking a collection of events as input. + /// + /// The collection of events to be saved. + void sauvegardeDonnees(ObservableCollection evenements); } } - diff --git a/ParionsCuite/Modeles/Inviter.cs b/ParionsCuite/Modeles/Inviter.cs index 41f8482..c326a9d 100644 --- a/ParionsCuite/Modeles/Inviter.cs +++ b/ParionsCuite/Modeles/Inviter.cs @@ -1,38 +1,61 @@ using System; using System.Runtime.Serialization; + namespace ParionsCuite.Modeles { [DataContract] public class Inviter { + /// + /// Gets or sets the last name of the guest. + /// [DataMember] public string Nom { get; set; } + + /// + /// Gets or sets the first name of the guest. + /// [DataMember] public string Prenom { get; set; } + /// + /// Initializes a new instance of the class with the specified last name and first name. + /// + /// The last name of the guest. + /// The first name of the guest. public Inviter(string nom, string prenom) { Nom = nom; Prenom = prenom; } + /// + /// Initializes a new instance of the class with the specified first name. + /// + /// The first name of the guest. public Inviter(string prenom) { Prenom = prenom; } + /// + /// Initializes a new instance of the class. + /// public Inviter() { } + /// + /// Returns a string representation of the guest. + /// + /// A string representation of the guest. public override string ToString() { return $"nom : {Nom}, prenom : {Prenom} \n"; } - - } } + diff --git a/ParionsCuite/Modeles/Manageur.cs b/ParionsCuite/Modeles/Manageur.cs index 7f1bd0d..b491ca6 100644 --- a/ParionsCuite/Modeles/Manageur.cs +++ b/ParionsCuite/Modeles/Manageur.cs @@ -11,19 +11,58 @@ using System.Threading.Tasks; namespace ParionsCuite.Modeles { + /** + * @brief Manageur Class + * + * This class represents a manager that implements the INotifyPropertyChanged interface. + * It manages a collection of events and provides events and properties for data management. + */ public class Manageur : INotifyPropertyChanged { + /** + * @brief Event triggered when a property changes. + * + * This event is triggered when the value of a property in the Manageur object changes. + */ public event PropertyChangedEventHandler PropertyChanged; + /** + * @brief Event triggered when an event is added. + * + * This event is triggered when a new event is added to the event collection. + */ public event Action EvenementAdded; private ObservableCollection evenement; + /** + * @brief Gets or sets the value of the Value1 property. + */ public bool Value1; + + /** + * @brief Gets or sets the value of the Value2 property. + */ public bool Value2; + + /** + * @brief Gets or sets the value of the Value3 property. + */ public bool Value3; + + /** + * @brief Raises the PropertyChanged event. + * + * This method is used to raise the PropertyChanged event when a property changes. + * + * @param propertyName (optional) The name of the property that has changed. If not specified, the name of the calling property will be used. + */ void OnPropertyChanged([CallerMemberName] string propertyName = null) => PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName)); + + /** + * @brief Gets or sets the event collection. + */ public ObservableCollection Evenement { get { return evenement; } @@ -33,38 +72,79 @@ namespace ParionsCuite.Modeles { evenement = value; OnPropertyChanged(); - OnEvenementAdded(value.LastOrDefault()); // Appel de la fonction après ajout d'un événement + OnEvenementAdded(value.LastOrDefault()); // Call the function after adding an event + } } } - } + /** + * @brief Performs logic when an event is added. + * + * This method is called when an event is added to the event collection. + * + * @param evenement The event that was added. + */ private void OnEvenementAdded(Evenement evenement) { - // Logique à exécuter lorsque un événement est ajouté - Debug.WriteLine("Événement ajouté : "); - + // Logic to execute when an event is added + Debug.WriteLine("Event added: "); } - public List Invites { get; set; } - public IPersistanceManager Persistance { get; set; } + /** + * @brief Gets or sets the list of invitees. + */ + public List Invites { get; set; } - public Manageur(IPersistanceManager Pers) { + /** + * @brief Gets or sets the persistence manager. + */ + public IPersistanceManager Persistance { get; set; } + /** + * @brief Manageur Constructor + * + * Initializes a new instance of the Manageur class with the specified persistence manager. + * + * @param Pers The persistence manager to be used. + */ + public Manageur(IPersistanceManager Pers) + { Invites = new List(); Evenement = new ObservableCollection(); Persistance = Pers; } - public Manageur() + /** + * @brief Manageur Constructor + * + * Initializes a new instance of the Manageur class with default values. + */ + public Manageur() { Evenement = new ObservableCollection(); Invites = new List(); } + /** + * @brief Manageur Constructor + * + * Initializes a new instance of the Manageur class with the specified event collection. + * + * @param evenements The event collection to be used. + */ public Manageur(ObservableCollection evenements) { Evenement = evenements; } + /** + * @brief Adds an event to the event collection. + * + * This method adds the specified event to the event collection, triggers the PropertyChanged event, + * and invokes the EvenementAdded event. + * + * @param ev The event to be added. + * @return Returns true indicating the event was added successfully. + */ public bool Ajout_evenement(Evenement ev) { Evenement.Add(ev); @@ -73,23 +153,55 @@ namespace ParionsCuite.Modeles return true; } + /** + * @brief Removes an event from the event collection. + * + * This method removes the specified event from the event collection. + * + * @param ev The event to be removed. + * @return Returns true if the event was successfully removed; otherwise, false. + */ public bool Supprimer_evenement(Evenement ev) { return Evenement.Remove(ev); } + /** + * @brief Adds an invitee to the invitees list. + * + * This method adds the specified invitee to the list of invitees. + * + * @param invite1 The invitee to be added. + * @return Returns the updated list of invitees. + */ public List AddInvite(Inviter invite1) - { + { Invites.Add(invite1); return Invites; } + /** + * @brief Removes an invitee from the invitees list. + * + * This method removes the specified invitee from the list of invitees. + * + * @param invite1 The invitee to be removed. + * @return Returns the updated list of invitees. + */ public List RemoveInviter(Inviter invite1) { Invites.Remove(invite1); return Invites; } + /** + * @brief Returns the length of a list of invitees. + * + * This method calculates and returns the length of the specified list of invitees. + * + * @param list The list of invitees. + * @return Returns the length of the list of invitees. + */ public int LenListInvite(List list) { int len = 0; @@ -100,13 +212,17 @@ namespace ParionsCuite.Modeles return len; } - public List ReturnListInvite() - { - return Invites; - } + /** + * @brief Loads data using the persistence manager. + * + * This method loads data using the configured persistence manager. + * It retrieves data from the persistence layer and adds it to the event collection. + * + * @return Returns the loaded data as an ObservableCollection of Evenement. + */ public ObservableCollection Charge_Donnee() - { + { var donnees = Persistance.chargeDonnees(); foreach (var donnee in donnees) { @@ -115,9 +231,16 @@ namespace ParionsCuite.Modeles return donnees; } + /** + * @brief Saves data using the persistence manager. + * + * This method saves the event collection using the configured persistence manager. + * It persists the current state of the event collection to the underlying storage. + */ public void Save_Data() { Persistance.sauvegardeDonnees(Evenement); } } + } diff --git a/ParionsCuite/Modeles/Nourriture.cs b/ParionsCuite/Modeles/Nourriture.cs index 01ac45d..62d1617 100644 --- a/ParionsCuite/Modeles/Nourriture.cs +++ b/ParionsCuite/Modeles/Nourriture.cs @@ -6,24 +6,42 @@ namespace ParionsCuite.Modeles [DataContract] public class Nourriture { + /// + /// Gets or sets the name of the food. + /// [DataMember] - public string Nom { get; set; } + public string Nom { get; set; } + /// + /// Gets or sets the quantity of the food. + /// [DataMember] - public int Quantite { get; set; } + public int Quantite { get; set; } + /// + /// Initializes a new instance of the class. + /// + /// The name of the food. + /// The quantity of the food. public Nourriture(string nom, int qu) { Nom = nom; Quantite = qu; } + /// + /// Initializes a new instance of the class. + /// public Nourriture() { - - } + } + /// + /// Determines whether the current object is equal to another object. + /// + /// The object to compare with the current object. + /// true if the objects are equal; otherwise, false. public override bool Equals(object obj) { if (ReferenceEquals(obj, null)) return false; @@ -32,15 +50,22 @@ namespace ParionsCuite.Modeles return Equals(obj as Nourriture); } + /// + /// Returns a string that represents the current object. + /// + /// A string representation of the object. public override string ToString() { return $"nom : {Nom} \n"; } + /// + /// Serves as a hash function for a object. + /// + /// A hash code for the current object. public override int GetHashCode() { return HashCode.Combine(Nom); } } } - diff --git a/ParionsCuite/Modeles/Parier.cs b/ParionsCuite/Modeles/Parier.cs index 6ae0038..949db13 100644 --- a/ParionsCuite/Modeles/Parier.cs +++ b/ParionsCuite/Modeles/Parier.cs @@ -8,18 +8,40 @@ using System.Threading.Tasks; namespace ParionsCuite.Modeles { [DataContract] - public class Parier + public class Parier { + /// + /// Gets or sets the first player involved in the bet. + /// [DataMember] - public Inviter i1; + public Inviter i1 { get; set; } + + /// + /// Gets or sets the second player involved in the bet. + /// [DataMember] - public Inviter i2; + public Inviter i2 { get; set; } + /// + /// Gets or sets the goal of the bet. + /// + [DataMember] public string But { get; private set; } + /// + /// Gets or sets the stake of the bet. + /// + [DataMember] public string Enjeu { get; private set; } - public Parier(Inviter i1, Inviter i2, string but, string enjeu) + /// + /// Initializes a new instance of the class. + /// + /// The first player involved in the bet. + /// The second player involved in the bet. + /// The goal of the bet. + /// The stake of the bet. + public Parier(Inviter i1, Inviter i2, string but, string enjeu) { this.i1 = i1; this.i2 = i2; @@ -27,6 +49,10 @@ namespace ParionsCuite.Modeles Enjeu = enjeu; } + /// + /// Returns a string that represents the current object. + /// + /// A string representation of the object. public override string ToString() { return $"joueur n°1 : {i1}, \njoueur n°2 : {i2}, \nbut : {But}, enjeux : {Enjeu}"; diff --git a/ParionsCuite/Modeles/Participation.cs b/ParionsCuite/Modeles/Participation.cs index e2227fe..3bebbb3 100644 --- a/ParionsCuite/Modeles/Participation.cs +++ b/ParionsCuite/Modeles/Participation.cs @@ -15,28 +15,44 @@ namespace ParionsCuite.Modeles { [DataMember] public List Boissons { get; private set; } + [DataMember] - public List Nourriture { get; private set; } + public List Nourriture { get; private set; } + [DataMember] public List Autre { get; private set; } - public Participation(List boisson, List nourriture, List autre) - { - Boissons = boisson; - Nourriture = nourriture; - Autre = autre; - } - + /// + /// Initializes a new instance of the class. + /// public Participation() { Boissons = new List(); Nourriture = new List(); Autre = new List(); } - - /* Boisson */ - public bool Ajout_Boissons(Boisson boisson) + /// + /// Initializes a new instance of the class. + /// + /// The list of drinks. + /// The list of food. + /// The list of other items. + public Participation(List boisson, List nourriture, List autre) + { + Boissons = boisson; + Nourriture = nourriture; + Autre = autre; + } + + /* Boisson */ + + /// + /// Adds a drink to the participation. + /// + /// The drink to add. + /// true if the drink was added successfully; otherwise, false. + public bool Ajout_Boissons(Boisson boisson) { foreach (var obj in Boissons) { @@ -44,21 +60,28 @@ namespace ParionsCuite.Modeles { if (boisson.Quantite > 0) { - obj.Quantite = obj.Quantite + boisson.Quantite; + obj.Quantite += boisson.Quantite; return true; } return false; } } - Boissons.AddRange((IEnumerable)boisson); + Boissons.Add(boisson); return true; } + /// + /// Removes a specified quantity of a drink from the participation. + /// + /// The drink to remove. + /// The quantity to remove. + /// true if the drink was removed successfully; otherwise, false. public bool Sup_Boissons(Boisson boisson, int quantite) { - foreach(var obj in Boissons) + foreach (var obj in Boissons) { if (obj.Equals(boisson)) + { if (quantite > 0) { if (quantite >= boisson.Quantite) @@ -67,17 +90,22 @@ namespace ParionsCuite.Modeles return true; } - obj.Quantite = obj.Quantite + boisson.Quantite; + obj.Quantite -= quantite; return true; } - return false; + return false; + } } return false; } - /* Nourriture */ + /// + /// Adds a food item to the participation. + /// + /// The food item to add. + /// true if the food item was added successfully; otherwise, false. public bool Ajout_Nourriture(Nourriture food) { foreach (var obj in Nourriture) @@ -86,21 +114,28 @@ namespace ParionsCuite.Modeles { if (food.Quantite > 0) { - obj.Quantite = obj.Quantite + food.Quantite; + obj.Quantite += food.Quantite; return true; } return false; } } - Nourriture.AddRange((IEnumerable)food); + Nourriture.Add(food); return true; } + /// + /// Removes a specified quantity of a food item from the participation. + /// + /// The food item to remove. + /// The quantity to remove. + /// true if the food item was removed successfully; otherwise, false. public bool Sup_Nourriture(Nourriture food, int quantite) { - foreach (var obj in Boissons) + foreach (var obj in Nourriture) { if (obj.Equals(food)) + { if (quantite > 0) { if (quantite >= food.Quantite) @@ -109,16 +144,22 @@ namespace ParionsCuite.Modeles return true; } - obj.Quantite = obj.Quantite + food.Quantite; + obj.Quantite -= quantite; return true; } - return false; + return false; + } } return false; } /* Autre */ + /// + /// Adds another item to the participation. + /// + /// The other item to add. + /// true if the other item was added successfully; otherwise, false. public bool Ajout_Autre(Autre autre) { foreach (var obj in Autre) @@ -127,21 +168,28 @@ namespace ParionsCuite.Modeles { if (autre.Quantite > 0) { - obj.Quantite = obj.Quantite + autre.Quantite; + obj.Quantite += autre.Quantite; return true; } return false; } } - Autre.AddRange((IEnumerable)autre); + Autre.Add(autre); return true; } + /// + /// Removes a specified quantity of another item from the participation. + /// + /// The other item to remove. + /// The quantity to remove. + /// true if the other item was removed successfully; otherwise, false. public bool Sup_Autre(Autre autre, int quantite) { foreach (var obj in Autre) { if (obj.Equals(autre)) + { if (quantite > 0) { if (quantite >= autre.Quantite) @@ -150,13 +198,14 @@ namespace ParionsCuite.Modeles return true; } - obj.Quantite = obj.Quantite + autre.Quantite; + obj.Quantite -= quantite; return true; } - return false; + return false; + } } return false; } - } } + diff --git a/ParionsCuite/ParionsCuite/App.xaml.cs b/ParionsCuite/ParionsCuite/App.xaml.cs index e65ef2c..4c51b2b 100644 --- a/ParionsCuite/ParionsCuite/App.xaml.cs +++ b/ParionsCuite/ParionsCuite/App.xaml.cs @@ -2,21 +2,54 @@ using ParionsCuite.DataContractPersistance; namespace ParionsCuite; +/** + * @brief Represents the application instance and its entry point. + * + * The `App` class initializes the application environment, sets up the data persistence, and manages the `Manageur` instance. + */ public partial class App : Application { - //public Manageur MyManager { get; private set; } = new Manageur(new Stub.Stub()); + /** + * @brief Gets or sets the file name for data persistence. + */ + public string FileName { get; set; } = "A_Save_Data.xml"; - public Manageur MyManager { get; private set; } = new Manageur(new DataContractPersistance.DataContractPersistance()); + /** + * @brief Gets or sets the file path for data persistence. + */ + public string FilePath { get; set; } = Path.Combine(AppDomain.CurrentDomain.BaseDirectory); - public App() - { + /** + * @brief Gets the instance of the `Manageur` class used in the application. + */ + public Manageur MyManager { get; private set; } = new Manageur(new Stub.Stub()); + + /** + * @brief Initializes a new instance of the `App` class. + */ + public App() + { InitializeComponent(); + + // Check if the data file exists + if (File.Exists(Path.Combine(FilePath, FileName))) + { + MyManager = new Manageur(new DataContractPersistance.DataContractPersistance()); + } + + // Load data into the Manageur instance MyManager.Charge_Donnee(); + MainPage = new AppShell(); - MyManager.Persistance = new DataContractPersistance.DataContractPersistance(); + + // Save data + + // If the data file doesn't exist, set the persistence to DataContractPersistance + if (!File.Exists(Path.Combine(FilePath, FileName))) + { + MyManager.Persistance = new DataContractPersistance.DataContractPersistance(); + } MyManager.Save_Data(); - - - } + } } diff --git a/ParionsCuite/ParionsCuite/DataContractPersistance/DataContractPersistance.cs b/ParionsCuite/ParionsCuite/DataContractPersistance/DataContractPersistance.cs index e3d3d6f..86e2531 100644 --- a/ParionsCuite/ParionsCuite/DataContractPersistance/DataContractPersistance.cs +++ b/ParionsCuite/ParionsCuite/DataContractPersistance/DataContractPersistance.cs @@ -8,15 +8,35 @@ using ParionsCuite.Modeles; using System.Collections.ObjectModel; namespace ParionsCuite.DataContractPersistance -{ +{/** + * @brief Provides data persistence using the DataContractSerializer. + * + * The `DataContractPersistance` class implements the `IPersistanceManager` interface and provides methods for saving and loading data using the `DataContractSerializer`. + */ public class DataContractPersistance : Modeles.IPersistanceManager { + /** + * @brief Gets the name of the data file. + */ public string FileName { get; private set; } = "A_Save_Data.xml"; + + /** + * @brief Gets the path to the data file. + */ public string FilePath { get; private set; } = Path.Combine(AppDomain.CurrentDomain.BaseDirectory); - //public string FilePath2 { get; private set; } = Path.Combine(Directory.GetCurrentDirectory(), "//Doss1_XML"); + /** + * @brief Initializes a new instance of the `DataContractPersistance` class. + */ public DataContractPersistance() { } + /** + * @brief Loads the data from the data file. + * + * This method reads the data from the data file using the `DataContractSerializer` and returns the deserialized data as an `ObservableCollection`. + * + * @return The loaded data as an `ObservableCollection`. + */ public ObservableCollection chargeDonnees() { var serializer = new DataContractSerializer(typeof(ObservableCollection)); @@ -29,7 +49,13 @@ namespace ParionsCuite.DataContractPersistance return list; } - + /** + * @brief Saves the data to the data file. + * + * This method serializes the given `ObservableCollection` using the `DataContractSerializer` and saves it to the data file. + * + * @param evenements The data to be saved as an `ObservableCollection`. + */ public void sauvegardeDonnees(ObservableCollection evenements) { var serializer = new DataContractSerializer(typeof(ObservableCollection)); @@ -42,15 +68,15 @@ namespace ParionsCuite.DataContractPersistance } var settings = new XmlWriterSettings() { Indent = true }; - using (TextWriter tw = File.CreateText(Path.Combine(FilePath, FileName))) { + using (TextWriter tw = File.CreateText(Path.Combine(FilePath, FileName))) + { using (XmlWriter writer = XmlWriter.Create(tw, settings)) { serializer.WriteObject(writer, evenements); } } } - - } + } diff --git a/ParionsCuite/ParionsCuite/DataContractPersistance/DataToPersists.cs b/ParionsCuite/ParionsCuite/DataContractPersistance/DataToPersists.cs index b5215cd..9796310 100644 --- a/ParionsCuite/ParionsCuite/DataContractPersistance/DataToPersists.cs +++ b/ParionsCuite/ParionsCuite/DataContractPersistance/DataToPersists.cs @@ -8,8 +8,18 @@ using ParionsCuite.Modeles; namespace ParionsCuite.DataContractPersistance { + /** + * @brief DataToPersists Class + * + * Represents the data to be persisted. + */ public class DataToPersists { - public ObservableCollection e = new(); + /** + * @brief Gets or sets the collection of events to persist. + */ + public ObservableCollection e { get; set; } = new ObservableCollection(); } + + } diff --git a/ParionsCuite/ParionsCuite/MainPage.xaml.cs b/ParionsCuite/ParionsCuite/MainPage.xaml.cs index 1267a73..ddc8282 100644 --- a/ParionsCuite/ParionsCuite/MainPage.xaml.cs +++ b/ParionsCuite/ParionsCuite/MainPage.xaml.cs @@ -11,76 +11,104 @@ using ParionsCuite.Views.Participations.Autre; namespace ParionsCuite; +/** + * @brief Represents the main page of the application. + * + * The `MainPage` class is responsible for displaying a list of events and handling event selection. It also provides methods for restoring events from data and adding new events. + */ public partial class MainPage : ContentPage { + /** + * @brief Gets the instance of the `Manageur` class from the application. + */ public Manageur mgr => (App.Current as App).MyManager; + /** + * @brief Gets or sets the selected event. + */ Evenement EventSelect { get; set; } + /** + * @brief Initializes a new instance of the `MainPage` class. + */ public MainPage() - { + { InitializeComponent(); this.BindingContext = this; mgr.EvenementAdded += OnEvenementAdded; ObservableCollection EventCharge = mgr.Charge_Donnee(); - restoreEvent(EventCharge ); + restoreEvent(EventCharge); } + /** + * @brief Restores the events from the given collection. + * + * This method is responsible for restoring events from the given collection and adding buttons to the UI for each event. It also sets the `mgr.Evenement` property to the restored events. + * + * @param EventCharge The collection of events to be restored. + */ private void restoreEvent(ObservableCollection EventCharge) { - foreach(Evenement ev in EventCharge) { + foreach (Evenement ev in EventCharge) + { Debug.WriteLine("Événement ajoutéz : " + ev.Nom); Button newButton = new Button { Text = ev.Nom, VerticalOptions = LayoutOptions.Center, HorizontalOptions = LayoutOptions.Center, - }; newButton.Clicked += (sender, e) => { - // Appel de la méthode qui récupère l'événement associé + // Call the method that handles event selection SelectEvent(ev); var newPage = new Views.Accueil(); changeButton.Content = newPage; }; - // Ajout du bouton au ButtonStackLayout + // Add the button to the ButtonStackLayout ButtonStackLayout.Children.Add(newButton); ; } mgr.Evenement = EventCharge; - Debug.WriteLine("Taille Event " + mgr.Evenement.Count()); - - //mgr.Save_Data(); - } + + /** + * @brief Event handler for the `EvenementAdded` event. + * + * This method is called when a new event is added. It adds a button for the new event to the UI and sets the `mgr.Evenement` property accordingly. + * + * @param evenement The newly added event. + */ private void OnEvenementAdded(Evenement evenement) { - // 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, - - }; + 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é + // Call the method that handles event selection SelectEvent(evenement); var newPage = new Views.Accueil(); changeButton.Content = newPage; }; - // Ajout du bouton au ButtonStackLayout + // Add the button to the ButtonStackLayout ButtonStackLayout.Children.Add(newButton); ; - Debug.WriteLine("Taille Event " + mgr.Evenement.Count()); Debug.WriteLine(mgr.Evenement); mgr.Save_Data(); } + /** + * @brief Selects the specified event. + * + * This method is called when an event is selected. It sets the `EventSelect` property to the specified event. + * + * @param evenement The selected event. + */ public void SelectEvent(Evenement evenement) { Debug.WriteLine("Événement cliqué : " + evenement.Nom); @@ -90,59 +118,62 @@ public partial class MainPage : ContentPage EventSelect = evenement; } - - - - - // Acces View Groupe - + /** + * @brief Navigates to the Groupe view. + * + * This method is called when the Groupe button is clicked. It creates a new instance of the Groupe view and sets it as the content of the changeButton element. + */ public void Button_Clicked(object sender, EventArgs e) { - var newPage = new Views.Groupe(); - changeButton.Content = newPage; - - - } - // Acces view Invite + /** + * @brief Navigates to the Invite view. + * + * This method is called when the Invite button is clicked. It creates a new instance of the Invite view, passing the selected event as a parameter, and sets it as the content of the changeButton element. + */ private void InviteView(object sender, EventArgs e) { if (EventSelect == null) { return; } var newPage = new Views.Invite.Inviter(EventSelect); - changeButton.Content = newPage; } - // Acces view Participant + /** + * @brief Navigates to the Participant view. + * + * This method is called when the Participant button is clicked. It creates a new instance of the Participant view, passing the selected event as a parameter, and sets it as the content of the changeButton element. + */ private void ParticipantView(object sender, EventArgs e) { if (EventSelect == null) { return; } - var newPage = new Views.Participations.Nourriture(EventSelect); - changeButton.Content = newPage; } - //Acces View Pari + /** + * @brief Navigates to the Pari view. + * + * This method is called when the Pari button is clicked. It creates a new instance of the Pari view, passing the selected event as a parameter, and sets it as the content of the changeButton element. + */ private void PariView(object sender, EventArgs e) { if (EventSelect == null) { return; } - var newPage = new Views.Pari.Parier(EventSelect); - changeButton.Content = newPage; } - // Acces View Information + /** + * @brief Navigates to the Information view. + * + * This method is called when the Info button is clicked. It creates a new instance of the Information view, passing the selected event as a parameter, and sets it as the content of the changeButton element. + */ private void InfoView(object sender, EventArgs e) { if (EventSelect == null) { return; } - var newPage = new Views.Information.Info(EventSelect); - changeButton.Content = newPage; } diff --git a/ParionsCuite/ParionsCuite/Stub/Stub.cs b/ParionsCuite/ParionsCuite/Stub/Stub.cs index e89b1c1..f10852b 100644 --- a/ParionsCuite/ParionsCuite/Stub/Stub.cs +++ b/ParionsCuite/ParionsCuite/Stub/Stub.cs @@ -3,35 +3,46 @@ using System.Collections.Generic; using System.Collections.ObjectModel; using ParionsCuite.Modeles; namespace ParionsCuite.Stub; - +/// +/// Represents a stub implementation of the interface. +/// public class Stub : IPersistanceManager { - public Stub() - { - } - + /// + /// Loads the data and returns an . + /// + /// An containing the loaded data. public ObservableCollection chargeDonnees() { ObservableCollection lisEvent = new ObservableCollection(); List boissons = new List(); List nourritures = new List(); List autres = new List(); - Boisson b = new("biere", 15); - boissons.Add(b); - Nourriture n = new("pain", 15); - nourritures.Add(n); - Autre a = new("chaise", 15); - autres.Add(a); - Participation p = new(boissons,nourritures, autres); - DateTime dt = new(2018, 7, 24); - Evenement e = new ("nom", "dt", "lieu", "12", p); + + Boisson boisson = new Boisson("biere", 15); + boissons.Add(boisson); + + Nourriture nourriture = new Nourriture("pain", 15); + nourritures.Add(nourriture); + + Autre autre = new Autre("chaise", 15); + autres.Add(autre); + + Participation participation = new Participation(boissons, nourritures, autres); + DateTime dt = new DateTime(2018, 7, 24); + + Evenement e = new Evenement("nom", "dt", "lieu", "12", participation); lisEvent.Add(e); + return lisEvent; } + /// + /// Saves the data from the specified . + /// + /// The to save. public void sauvegardeDonnees(ObservableCollection evenements) { throw new NotImplementedException(); } } - diff --git a/ParionsCuite/ParionsCuite/Views/Ajout_Paris/Ajouts_Pari.xaml.cs b/ParionsCuite/ParionsCuite/Views/Ajout_Paris/Ajouts_Pari.xaml.cs index 5c6e9e7..4ff467b 100644 --- a/ParionsCuite/ParionsCuite/Views/Ajout_Paris/Ajouts_Pari.xaml.cs +++ b/ParionsCuite/ParionsCuite/Views/Ajout_Paris/Ajouts_Pari.xaml.cs @@ -2,34 +2,51 @@ using System.Diagnostics; namespace ParionsCuite.Views.Ajout_Paris; - +/** + * @brief The Ajouts_Pari class is a partial class derived from ContentView. + */ public partial class Ajouts_Pari : ContentView { + /** + * @brief The EventSelect field stores the selected event. + */ readonly Evenement EventSelect; + + /** + * @brief The mgr property returns the application's manager instance. + */ public Manageur mgr => (App.Current as App).MyManager; + /** + * @brief Initializes a new instance of the Ajouts_Pari class. + * @param EventSelect The selected event. + */ public Ajouts_Pari(Evenement EventSelect) - { - InitializeComponent(); - this.EventSelect = EventSelect; - + { + InitializeComponent(); + this.EventSelect = EventSelect; } + /** + * @brief Handles the NewPari event. + * @param sender The object that raised the event. + * @param e The event arguments. + */ private void NewPari(object sender, EventArgs e) { - string parieur1 = Parieur1.Text; - string parieur2 = Parieur2.Text; - string but = ButPari.Text; - string enjeux = EnjeuxPari.Text; - Inviter NewParieur1 = new Inviter(parieur1); + string parieur1 = Parieur1.Text; + string parieur2 = Parieur2.Text; + string but = ButPari.Text; + string enjeux = EnjeuxPari.Text; + Inviter NewParieur1 = new Inviter(parieur1); Inviter NewParieur2 = new Inviter(parieur2); - Modeles.Parier newPari = new Parier(NewParieur1, NewParieur2, but, enjeux); - //EventSelect.ListParier.Add(newPari); + Modeles.Parier newPari = new Parier(NewParieur1, NewParieur2, but, enjeux); + Debug.WriteLine("PArieur ajouter" + newPari.But); + EventSelect.Ajout_Pari(newPari); - Debug.WriteLine("Taille Liste : " + EventSelect.ListParier.Count()); mgr.Save_Data(); - } } + diff --git a/ParionsCuite/ParionsCuite/Views/Groupe.xaml.cs b/ParionsCuite/ParionsCuite/Views/Groupe.xaml.cs index ca7fb48..cd6919d 100644 --- a/ParionsCuite/ParionsCuite/Views/Groupe.xaml.cs +++ b/ParionsCuite/ParionsCuite/Views/Groupe.xaml.cs @@ -4,23 +4,46 @@ using ParionsCuite.Modeles; using static System.Runtime.InteropServices.JavaScript.JSType; namespace ParionsCuite.Views; - +/** + * @brief Represents a ContentView for creating new events. + * + * The `Groupe` class provides a form for creating new events. It has a reference to the `Manageur` instance to perform operations on the data. + */ public partial class Groupe : ContentView { + /** + * @brief Gets the instance of the `Manageur` class used in the application. + */ public Manageur mgr => (App.Current as App).MyManager; + + /** + * @brief Gets or sets the collection of events. + */ public ObservableCollection Evenements { get; set; } = new ObservableCollection(); + /** + * @brief Initializes a new instance of the `Groupe` class. + */ public Groupe() { InitializeComponent(); } + /** + * @brief Event handler for the button clicked event. + * + * This method is called when the button for creating a new event is clicked. It retrieves the input values from the form, creates a new event object, adds it to the Manageur instance, and clears the form fields. + * + * @param sender The object that raised the event. + * @param e The event arguments. + */ private void Button_Clicked(object sender, EventArgs e) { var nomEvent = nomE.Text; var dateEvent = dateE.Text; var lieuEvent = lieuE.Text; var heureEvent = heureE.Text; + if (!string.IsNullOrEmpty(nomEvent) && !string.IsNullOrEmpty(dateEvent) && !string.IsNullOrEmpty(lieuEvent) && !string.IsNullOrEmpty(heureEvent)) { var newEvent = new Evenement(nomEvent, dateEvent, lieuEvent, heureEvent); @@ -36,6 +59,5 @@ public partial class Groupe : ContentView { Debug.WriteLine("Creation Event Error PLease Check!!!"); } - } -} \ No newline at end of file +} diff --git a/ParionsCuite/ParionsCuite/Views/Information/Info.xaml.cs b/ParionsCuite/ParionsCuite/Views/Information/Info.xaml.cs index b366623..2e1a534 100644 --- a/ParionsCuite/ParionsCuite/Views/Information/Info.xaml.cs +++ b/ParionsCuite/ParionsCuite/Views/Information/Info.xaml.cs @@ -3,36 +3,49 @@ using System.Diagnostics; using System.Xml.Linq; namespace ParionsCuite.Views.Information; - +/** + * @brief The Info class is a partial class derived from ContentView. + */ public partial class Info : ContentView { + /** + * @brief The mgr property returns the application's manager instance. + */ public Manageur mgr => (App.Current as App).MyManager; + /** + * @brief Initializes a new instance of the Info class. + * @param EventSelect The selected event. + */ public Info(Evenement EventSelect) - { - InitializeComponent(); - MiseAJourInfo(EventSelect); + { + InitializeComponent(); + MiseAJourInfo(EventSelect); this.BindingContext = EventSelect; - - } + /** + * @brief The m field stores an instance of the Manageur class. + */ public Manageur m = new Manageur(); + + /** + * @brief The DefaultCellHeight constant defines the default height of a cell. + */ public const int DefaultCellHeight = 40; + + /** + * @brief Updates the information for the selected event. + * @param EventSelect The selected event. + */ public void MiseAJourInfo(Evenement EventSelect) - { - //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 = EventSelect.Heure; - + AdresseEvent.Detail = EventSelect.Lieu; + HoraireEvent.Detail = EventSelect.Heure; } - - - -} \ No newline at end of file +} diff --git a/ParionsCuite/ParionsCuite/Views/Invite/Inviter.xaml.cs b/ParionsCuite/ParionsCuite/Views/Invite/Inviter.xaml.cs index 47d0c4a..c45b0a3 100644 --- a/ParionsCuite/ParionsCuite/Views/Invite/Inviter.xaml.cs +++ b/ParionsCuite/ParionsCuite/Views/Invite/Inviter.xaml.cs @@ -2,41 +2,60 @@ using ParionsCuite.Modeles; using System.Diagnostics; using System.Windows; namespace ParionsCuite.Views.Invite; - +/** +* @brief The Inviter class is a partial class derived from ContentView. +*/ public partial class Inviter : ContentView { + /** + * @brief The mgr property returns the application's manager instance. + */ public Manageur mgr => (App.Current as App).MyManager; + /** + * @brief The EventSelect field stores the selected event. + */ private readonly Evenement EventSelect; - public Modeles.Inviter Inviters { get; private set; } = new Modeles.Inviter(); + + /** + * @brief Gets or sets the Inviters object. + */ + public Modeles.Inviter Inviters { get; private set; } = new Modeles.Inviter(); + + /** + * @brief Initializes a new instance of the Inviter class. + * @param EventSelect The selected event. + */ public Inviter(Evenement EventSelect) - { + { this.EventSelect = EventSelect; - InitializeComponent(); + InitializeComponent(); restoreListInvite(EventSelect); BindingContext = this; - } - + } + /** + * @brief Restores the list of invitees for the selected event. + * @param EventSelect The selected event. + */ public void restoreListInvite(Evenement EventSelect) { - List listInvite = EventSelect.ListInviter; Debug.WriteLine(listInvite); int len = 1; - foreach (Modeles.Inviter inviter in listInvite) { + foreach (Modeles.Inviter inviter in listInvite) + { RowDefinition row = new RowDefinition(); row.Height = new GridLength(45); GrilleInvite.RowDefinitions.Add(row); - // AJout Prenom + // Ajout Prenom Label prenomLabel = new Label(); prenomLabel.Text = inviter.Prenom; Grid.SetRow(prenomLabel, len); Grid.SetColumn(prenomLabel, 0); GrilleInvite.Children.Add(prenomLabel); - // Ajout Nom Label nomLabel = new Label(); nomLabel.Text = inviter.Nom; @@ -44,8 +63,7 @@ public partial class Inviter : ContentView Grid.SetColumn(nomLabel, 1); GrilleInvite.Children.Add(nomLabel); - // Ajout Bouton - + // Ajout Bouton Button buttonMoins = new Button(); buttonMoins.Text = "-"; buttonMoins.Clicked += BoutonSupprimer_Clicked; @@ -55,23 +73,22 @@ public partial class Inviter : ContentView len++; Debug.WriteLine("Test test"); - } - } - + /** + * @brief Handles the event when the add invite list button is clicked. + * @param sender The object that raised the event. + * @param e The event arguments. + */ private void AddInvitelist(object sender, EventArgs e) { - //restoreListInvite(); string nom = nomEditor.Text; string prenom = prenomEditor.Text; if (nom == null || prenom == null || nom == "" || prenom == "") { return; } Modeles.Inviter invite1 = new Modeles.Inviter(nom, prenom); EventSelect.ListInviter.Add(invite1); -; int len = 1; - //if (len == 0 ) { len = 1; } Debug.WriteLine("LA taille de la liste est de " + mgr.LenListInvite(EventSelect.ListInviter)); foreach (Modeles.Inviter inviter in EventSelect.ListInviter) { @@ -79,14 +96,13 @@ public partial class Inviter : ContentView row.Height = new GridLength(45); GrilleInvite.RowDefinitions.Add(row); - // AJout Prenom + // Ajout Prenom Label prenomLabel = new Label(); prenomLabel.Text = inviter.Prenom; Grid.SetRow(prenomLabel, len); Grid.SetColumn(prenomLabel, 0); GrilleInvite.Children.Add(prenomLabel); - // Ajout Nom Label nomLabel = new Label(); nomLabel.Text = inviter.Nom; @@ -94,26 +110,27 @@ public partial class Inviter : ContentView Grid.SetColumn(nomLabel, 1); GrilleInvite.Children.Add(nomLabel); - // Ajout Bouton - + // Ajout Bouton Button buttonMoins = new Button(); buttonMoins.Text = "-"; buttonMoins.Clicked += BoutonSupprimer_Clicked; Grid.SetRow(buttonMoins, len); - Grid.SetColumn(buttonMoins , 2); - GrilleInvite.Children.Add(buttonMoins ); - //GrilleInvite.HeightRequest = Height + 2; - - len = len +1 ; - + Grid.SetColumn(buttonMoins, 2); + GrilleInvite.Children.Add(buttonMoins); + len++; } + prenomEditor.Text = ""; nomEditor.Text = ""; mgr.Save_Data(); - } + /** + * @brief Handles the event when the delete button is clicked. + * @param sender The object that raised the event. + * @param e The event arguments. + */ private void BoutonSupprimer_Clicked(object sender, EventArgs e) { // Récupérer le bouton cliqué diff --git a/ParionsCuite/ParionsCuite/Views/Pari/InfoPAri.xaml.cs b/ParionsCuite/ParionsCuite/Views/Pari/InfoPAri.xaml.cs index 7d426b3..6555588 100644 --- a/ParionsCuite/ParionsCuite/Views/Pari/InfoPAri.xaml.cs +++ b/ParionsCuite/ParionsCuite/Views/Pari/InfoPAri.xaml.cs @@ -3,35 +3,46 @@ using System.Diagnostics; namespace ParionsCuite.Views.Pari; +/** + * @brief Represents a ContentView for displaying information about a specific bet (Pari). + */ public partial class InfoPAri : ContentView { - readonly Modeles.Parier PariSelect; + readonly Modeles.Parier PariSelect; public Manageur mgr => (App.Current as App).MyManager; - + /** + * @brief Initializes a new instance of the InfoPAri class. + * @param PariSelect The selected bet (Pari). + */ public InfoPAri(Modeles.Parier PariSelect) - { - InitializeComponent(); - this.PariSelect = PariSelect; - this.BindingContext = PariSelect; - MiseAJourInfo(PariSelect); - - } + { + InitializeComponent(); + this.PariSelect = PariSelect; + this.BindingContext = PariSelect; + MiseAJourInfo(PariSelect); + } - private void MiseAJourInfo(Modeles.Parier PariSelect) - { - //Debug.WriteLine("Pari Selectionner " + PariSelect); - Parieur1.Text = PariSelect.i1.Prenom; + /** + * @brief Updates the information displayed for the selected bet (Pari). + * @param PariSelect The selected bet (Pari). + */ + private void MiseAJourInfo(Modeles.Parier PariSelect) + { + Parieur1.Text = PariSelect.i1.Prenom; Parieur2.Text = PariSelect.i2.Prenom; - //butPari.Text = PariSelect.But; - //enjeuxPari.Text = PariSelect.Enjeu; ValuePari.IsToggled = mgr.Value1; j1.IsToggled = mgr.Value2; j2.IsToggled = mgr.Value3; Debug.WriteLine("Value " + mgr.Value2); - } + + /** + * @brief Handles the event when the toggle switch for ValuePari is toggled. + * @param sender The object that raised the event. + * @param e The event arguments. + */ private void ValuePari_Toggled(object sender, ToggledEventArgs e) { if (!ValuePari.IsToggled) @@ -43,11 +54,13 @@ public partial class InfoPAri : ContentView mgr.Value2 = j1.IsToggled; mgr.Value3 = j2.IsToggled; Debug.WriteLine("Value " + mgr.Value2); - - - } + /** + * @brief Handles the event when the toggle switch for j1 is toggled. + * @param sender The object that raised the event. + * @param e The event arguments. + */ private void j1_Toggled(object sender, ToggledEventArgs e) { if (j1.IsToggled && !ValuePari.IsToggled || j2.IsToggled && ValuePari.IsToggled && j1.IsToggled) @@ -58,9 +71,14 @@ public partial class InfoPAri : ContentView mgr.Value2 = j1.IsToggled; mgr.Value3 = j2.IsToggled; Debug.WriteLine("Value " + mgr.Value2); - } + /** + * @brief Handles the event when the toggle switch for j2 is toggled. + * @param sender The object that raised the event. + * @param e The event arguments. + */ + private void j2_Toggled(object sender, ToggledEventArgs e) { if (j2.IsToggled && !ValuePari.IsToggled || j2.IsToggled && ValuePari.IsToggled && j1.IsToggled) @@ -71,11 +89,9 @@ public partial class InfoPAri : ContentView mgr.Value2 = j1.IsToggled; mgr.Value3 = j2.IsToggled; Debug.WriteLine("Value " + mgr.Value2); - } - } \ No newline at end of file diff --git a/ParionsCuite/ParionsCuite/Views/Pari/Parier.xaml.cs b/ParionsCuite/ParionsCuite/Views/Pari/Parier.xaml.cs index 29e79ce..30ecd11 100644 --- a/ParionsCuite/ParionsCuite/Views/Pari/Parier.xaml.cs +++ b/ParionsCuite/ParionsCuite/Views/Pari/Parier.xaml.cs @@ -10,13 +10,20 @@ using ParionsCuite.Views.Participations.Autre; using System.Diagnostics; namespace ParionsCuite.Views.Pari; - +/** + * @brief Represents a ContentView for managing bets (Parier) related to a specific event (Evenement). + */ public partial class Parier : ContentView { public Manageur mgr => (App.Current as App).MyManager; readonly Evenement EventSelect; Parier PariSelect { get; set; } + + /** + * @brief Initializes a new instance of the Parier class. + * @param EventSelect The selected event (Evenement). + */ public Parier(Evenement EventSelect) { InitializeComponent(); @@ -26,69 +33,71 @@ public partial class Parier : ContentView EventSelect.PariAdd += OnPariAdded; } + /** + * @brief Restores the display of bets (Parier) for the selected event (Evenement). + * @param EventSelect The selected event (Evenement). + */ private void restorePari(Evenement EventSelect) { - //if (EventSelect.ListParier.Count() == 0) { return; } int len = 0; Debug.WriteLine("Taille Liste Pari" + EventSelect.ListParier); - foreach(Modeles.Parier pari in EventSelect.ListParier) + foreach (Modeles.Parier pari in EventSelect.ListParier) { + Debug.WriteLine("But du Pari" + pari.i2.Prenom); + ColumnDefinition column = new ColumnDefinition(); GridPari.ColumnDefinitions.Insert(len, column); Button button = new Button(); - button.Text = "Pari " + (len + 1); // Nommer le bouton en fonction du numéro de pari + button.Text = "Pari " + (len + 1); Grid.SetRow(button, 0); - Grid.SetColumn(button, len); // Utiliser le numéro de colonne pour positionner le bouton dans la grille + Grid.SetColumn(button, len); GridPari.Children.Add(button); len++; - // Ajout du gestionnaire de pari au bouton + button.Clicked += (sender, e) => { - // Appel de la méthode qui récupère le pari associé var newPage = new Views.Pari.InfoPAri(pari); - changeButton.Content = newPage; - }; } } + + /** + * @brief Event handler for the PariAdd event of the selected event (Evenement). + * @param obj The added bet (Modeles.Parier) object. + */ private void OnPariAdded(Modeles.Parier obj) { - int pariCount = GridPari.ColumnDefinitions.Count - 1; // Compter le nombre de colonnes déjà présentes (-1 pour ignorer la première colonne) + int pariCount = GridPari.ColumnDefinitions.Count - 1; ColumnDefinition column = new ColumnDefinition(); GridPari.ColumnDefinitions.Insert(pariCount + 1, column); Button button = new Button(); - button.Text = "Pari " + (pariCount + 1); // Nommer le bouton en fonction du numéro de pari + button.Text = "Pari " + (pariCount + 1); Grid.SetRow(button, 0); - Grid.SetColumn(button, pariCount + 1); // Utiliser le numéro de colonne pour positionner le bouton dans la grille + Grid.SetColumn(button, pariCount + 1); GridPari.Children.Add(button); - // Ajout du gestionnaire de pari au bouton button.Clicked += (sender, e) => { - // Appel de la méthode qui récupère le pari associé Debug.WriteLine(obj.But); var newPage = new Views.Pari.InfoPAri(obj); - changeButton.Content = newPage; - }; - mgr.Save_Data(); + mgr.Save_Data(); } - - + /** + * @brief Event handler for the SwitchView button. + * @param sender The object that raised the event. + * @param e The event arguments. + */ private void SwitchView(object sender, EventArgs e) { var newPage = new Views.Ajout_Paris.Ajouts_Pari(EventSelect); - changeButton.Content = newPage; - } - - -} \ No newline at end of file +} diff --git a/ParionsCuite/ParionsCuite/Views/Participations/Autre/Autres.xaml.cs b/ParionsCuite/ParionsCuite/Views/Participations/Autre/Autres.xaml.cs index 2717630..39149e8 100644 --- a/ParionsCuite/ParionsCuite/Views/Participations/Autre/Autres.xaml.cs +++ b/ParionsCuite/ParionsCuite/Views/Participations/Autre/Autres.xaml.cs @@ -4,24 +4,44 @@ using System.Diagnostics; namespace ParionsCuite.Views.Participations.Autre; +/** + * @brief Autres Class + * + * Represents a ContentView for displaying and managing "Autres" data related to an event. + */ public partial class Autres : ContentView { - readonly Evenement EventSelect; + /** + * @brief Gets the instance of the Manageur class. + */ public Manageur mgr => (App.Current as App).MyManager; + /** + * @brief Autres Constructor + * + * Initializes a new instance of the Autres class with the specified event. + * + * @param EventSelect The selected event. + */ public Autres(Evenement EventSelect) - { + { this.EventSelect = EventSelect; InitializeComponent(); restoreListAutre(EventSelect); BindingContext = this; } + /** + * @brief Restores the list of "Autres" for the selected event. + * + * This method restores and displays the list of "Autres" (other items) associated with the selected event. + * + * @param EventSelect The selected event. + */ public void restoreListAutre(Evenement EventSelect) { - List listAutre = EventSelect.Participation.Autre; Debug.WriteLine("TEst " + listAutre.Count()); int len = 1; @@ -31,7 +51,7 @@ public partial class Autres : ContentView row.Height = new GridLength(45); GridAutre.RowDefinitions.Add(row); - // AJout Nourriture + // Ajout Nourriture Label AutreLabel = new Label(); AutreLabel.Text = food.Nom.ToString(); Debug.WriteLine(AutreLabel); @@ -39,7 +59,6 @@ public partial class Autres : ContentView Grid.SetColumn(AutreLabel, 0); GridAutre.Children.Add(AutreLabel); - // Ajout Quantite Label qteLabel = new Label(); qteLabel.Text = food.Quantite.ToString(); @@ -48,7 +67,6 @@ public partial class Autres : ContentView GridAutre.Children.Add(qteLabel); // Ajout Bouton - Button buttonMoins = new Button(); buttonMoins.Text = "-"; buttonMoins.Clicked += BoutonSupprimer_Clicked; @@ -58,12 +76,17 @@ public partial class Autres : ContentView len++; Debug.WriteLine("Test test"); - } - } - private async void AddAutrelist(object sender, EventArgs e) + /** + * @brief Event handler for adding an "Autre" item to the list. + * + * This method is called when the "Add" button is clicked. + * It retrieves the entered "Autre" item and quantity, creates a new Autre object, adds it to the event's Participation.Autre list, + * and updates the UI to display the added item. + */ + private void AddAutrelist(object sender, EventArgs e) { //restoreListInvite(); string autre = AutreInput.Text; @@ -88,7 +111,6 @@ public partial class Autres : ContentView Grid.SetColumn(AutreLabel, 0); GridAutre.Children.Add(AutreLabel); - // Ajout Quantite Label qteLabel = new Label(); qteLabel.Text = autre2.Quantite.ToString(); @@ -97,7 +119,6 @@ public partial class Autres : ContentView GridAutre.Children.Add(qteLabel); // Ajout Bouton - Button buttonMoins = new Button(); buttonMoins.Text = "-"; buttonMoins.Clicked += BoutonSupprimer_Clicked; @@ -108,16 +129,23 @@ public partial class Autres : ContentView len++; Debug.WriteLine("Test test"); } + mgr.Save_Data(); } else { //await DisplayAlert("esv", "efds", "OK"); return; } - - } + /** + * @brief Event handler for removing an "Autre" item from the list. + * + * This method is called when the "-" button is clicked. + * It identifies the clicked button's parent grid, determines the row index of the clicked button, + * finds the corresponding labels in that row, removes the "Autre" item from the event's Participation.Autre list, + * and updates the UI by removing the associated UI elements for that row. + */ private void BoutonSupprimer_Clicked(object sender, EventArgs e) { // Récupérer le bouton cliqué @@ -169,5 +197,7 @@ public partial class Autres : ContentView parentGrid.RowDefinitions.RemoveAt(rowIndex); } } + mgr.Save_Data(); + } } diff --git a/ParionsCuite/ParionsCuite/Views/Participations/Boisson/Drink.xaml.cs b/ParionsCuite/ParionsCuite/Views/Participations/Boisson/Drink.xaml.cs index 15fa84f..ba0a2be 100644 --- a/ParionsCuite/ParionsCuite/Views/Participations/Boisson/Drink.xaml.cs +++ b/ParionsCuite/ParionsCuite/Views/Participations/Boisson/Drink.xaml.cs @@ -4,24 +4,40 @@ using System.Diagnostics; namespace ParionsCuite.Views.Participations.Boisson; +/** + * @brief Represents the view for managing drinks in an event. + * + * This class is a ContentView that displays the list of drinks for a specific event. + */ public partial class Drink : ContentView { - readonly Evenement EventSelect; + /** + * @brief Gets the instance of the Manageur class from the application's current instance. + */ public Manageur mgr => (App.Current as App).MyManager; + /** + * @brief Initializes a new instance of the Drink class. + * + * @param EventSelect The selected event for which the drink list is displayed. + */ public Drink(Evenement EventSelect) - { + { this.EventSelect = EventSelect; InitializeComponent(); restoreListBoisson(EventSelect); BindingContext = this; } + /** + * @brief Restores the list of drinks for the specified event and updates the UI to display the drinks. + * + * @param EventSelect The event for which the drink list is restored. + */ public void restoreListBoisson(Evenement EventSelect) { - List listDrink = EventSelect.Participation.Boissons; Debug.WriteLine("TEst " + listDrink.Count()); int len = 1; @@ -38,7 +54,6 @@ public partial class Drink : ContentView Grid.SetColumn(DrinkLabel, 0); GridDrink.Children.Add(DrinkLabel); - // Ajout Quantite Label qteLabel = new Label(); qteLabel.Text = food.Quantite.ToString(); @@ -47,7 +62,6 @@ public partial class Drink : ContentView GridDrink.Children.Add(qteLabel); // Ajout Bouton - Button buttonMoins = new Button(); buttonMoins.Text = "-"; buttonMoins.Clicked += BoutonSupprimer_Clicked; @@ -57,14 +71,19 @@ public partial class Drink : ContentView len++; Debug.WriteLine("Test test"); - } - } - + /** + * @brief Event handler for adding a new drink to the list. + * + * This method is triggered when the "Add" button is clicked. It retrieves the drink name and quantity from the input fields, + * creates a new instance of the Modeles.Boisson class, adds it to the drink list of the selected event, and updates the UI to display the new drink. + * + * @param sender The object that raised the event. + * @param e The event arguments. + */ private void AddDrinklist(object sender, EventArgs e) { - //restoreListInvite(); string drink = DrinkInput.Text; string qte = QteInput.Text; if (int.TryParse(qte, out int value)) @@ -73,7 +92,6 @@ public partial class Drink : ContentView Modeles.Boisson drink1 = new Modeles.Boisson(drink, Int32.Parse(qte)); EventSelect.Participation.Boissons.Add(drink1); int len = 1; - //if (len == 0 ) { len = 1; } foreach (Modeles.Boisson food2 in EventSelect.Participation.Boissons) { RowDefinition row = new RowDefinition(); @@ -87,7 +105,6 @@ public partial class Drink : ContentView Grid.SetColumn(DrinkLabel, 0); GridDrink.Children.Add(DrinkLabel); - // Ajout Quantite Label qteLabel = new Label(); qteLabel.Text = food2.Quantite.ToString(); @@ -96,7 +113,6 @@ public partial class Drink : ContentView GridDrink.Children.Add(qteLabel); // Ajout Bouton - Button buttonMoins = new Button(); buttonMoins.Text = "-"; buttonMoins.Clicked += BoutonSupprimer_Clicked; @@ -110,13 +126,21 @@ public partial class Drink : ContentView } else { - //await DisplayAlert("esv", "efds", "OK"); return; } - - + mgr.Save_Data(); } + /** + * @brief Event handler for removing a drink from the list. + * + * This method is triggered when the "-" button next to a drink is clicked. It retrieves the selected drink's name and quantity, + * searches for the corresponding Modeles.Boisson object in the drink list of the selected event, removes it from the list, + * and updates the UI to reflect the changes. + * + * @param sender The object that raised the event. + * @param e The event arguments. + */ private void BoutonSupprimer_Clicked(object sender, EventArgs e) { // Récupérer le bouton cliqué @@ -168,5 +192,7 @@ public partial class Drink : ContentView parentGrid.RowDefinitions.RemoveAt(rowIndex); } } + mgr.Save_Data(); + } } \ No newline at end of file diff --git a/ParionsCuite/ParionsCuite/Views/Participations/NewFolder1/Nourri.xaml.cs b/ParionsCuite/ParionsCuite/Views/Participations/NewFolder1/Nourri.xaml.cs index 9fad17b..18763de 100644 --- a/ParionsCuite/ParionsCuite/Views/Participations/NewFolder1/Nourri.xaml.cs +++ b/ParionsCuite/ParionsCuite/Views/Participations/NewFolder1/Nourri.xaml.cs @@ -3,25 +3,33 @@ using ParionsCuite.Views.Participations; using System.Diagnostics; namespace ParionsCuite.Views.Participations.NewFolder1; - +/** + * @brief Represents a ContentView for managing food items (Nourriture) related to a specific event (Evenement). + */ public partial class Nourri : ContentView { readonly Evenement EventSelect; public Manageur mgr => (App.Current as App).MyManager; + /** + * @brief Initializes a new instance of the Nourri class. + * @param EventSelect The selected event (Evenement). + */ public Nourri(Evenement EventSelect) - { + { this.EventSelect = EventSelect; InitializeComponent(); restoreListFood(EventSelect); BindingContext = this; } - + /** + * @brief Restores the display of food items (Nourriture) for the selected event (Evenement). + * @param EventSelect The selected event (Evenement). + */ public void restoreListFood(Evenement EventSelect) { - List listFood = EventSelect.Participation.Nourriture; Debug.WriteLine("TEst " + listFood.Count()); int len = 1; @@ -31,7 +39,6 @@ public partial class Nourri : ContentView row.Height = new GridLength(45); GridFood.RowDefinitions.Add(row); - // AJout Nourriture Label foodLabel = new Label(); foodLabel.Text = food.Nom.ToString(); Debug.WriteLine(foodLabel); @@ -39,16 +46,12 @@ public partial class Nourri : ContentView Grid.SetColumn(foodLabel, 0); GridFood.Children.Add(foodLabel); - - // Ajout Quantite Label qteLabel = new Label(); qteLabel.Text = 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; @@ -58,14 +61,16 @@ public partial class Nourri : ContentView len++; Debug.WriteLine("Test test"); - } - } + /** + * @brief Event handler for the AddFoodlist button. + * @param sender The object that raised the event. + * @param e The event arguments. + */ private void AddFoodlist(object sender, EventArgs e) { - //restoreListInvite(); string food = FoodInput.Text; string qte = QteInput.Text; if (int.TryParse(qte, out int value)) @@ -74,30 +79,24 @@ public partial class Nourri : ContentView 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 Nourriture Label foodLabel = new Label(); foodLabel.Text = food2.Nom; Grid.SetRow(foodLabel, len); Grid.SetColumn(foodLabel, 0); GridFood.Children.Add(foodLabel); - - // Ajout Quantite Label qteLabel = new Label(); qteLabel.Text = 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; @@ -109,33 +108,27 @@ public partial class Nourri : ContentView Debug.WriteLine("Test test"); } } - else { - //await DisplayAlert("esv", "efds", "OK"); + else + { return; } mgr.Save_Data(); - - - } + /** + * @brief Event handler for the BoutonSupprimer_Clicked event. + * @param sender The object that raised the event. + * @param e The event arguments. + */ 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 foodLabel = null; Label qteLabel = 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); @@ -151,19 +144,15 @@ public partial class Nourri : ContentView if (foodLabel != null && qteLabel != null) { - // Récupérer le prénom et le nom de l'invité à supprimer string nom = foodLabel.Text; string qte = qteLabel.Text; - // Rechercher l'invité correspondant dans la liste Modeles.Nourriture nourriture = EventSelect.Participation.Nourriture.FirstOrDefault(i => i.Nom == nom && i.Quantite.ToString() == qte); if (nourriture != null) { - // Supprimer l'invité de la liste EventSelect.Participation.Nourriture.Remove(nourriture); - // Supprimer les éléments de la ligne de la grille parentGrid.Children.Remove(foodLabel); parentGrid.Children.Remove(qteLabel); parentGrid.Children.Remove(button); @@ -171,6 +160,5 @@ public partial class Nourri : ContentView } } mgr.Save_Data(); - } -} \ No newline at end of file +} diff --git a/ParionsCuite/ParionsCuite/Views/Participations/Nourriture.xaml.cs b/ParionsCuite/ParionsCuite/Views/Participations/Nourriture.xaml.cs index 5ec7c92..3fd6538 100644 --- a/ParionsCuite/ParionsCuite/Views/Participations/Nourriture.xaml.cs +++ b/ParionsCuite/ParionsCuite/Views/Participations/Nourriture.xaml.cs @@ -2,18 +2,30 @@ using ParionsCuite.Views.Participations; namespace ParionsCuite.Views.Participations; - +/** + * @brief Represents a ContentView for managing food-related actions. + */ public partial class Nourriture : ContentView { public Manageur mgr => (App.Current as App).MyManager; Evenement EventSelect; + + /** + * @brief Initializes a new instance of the Nourriture class. + * @param EventSelect The selected event (Evenement). + */ public Nourriture(Evenement EventSelect) - { + { InitializeComponent(); this.EventSelect = EventSelect; - } + } + /** + * @brief Event handler for the NourritureView button. + * @param sender The object that raised the event. + * @param e The event arguments. + */ private void NourritureView(object sender, EventArgs e) { if (EventSelect == null) { return; } @@ -23,6 +35,11 @@ public partial class Nourriture : ContentView changeButton.Content = newPage; } + /** + * @brief Event handler for the BoissonView button. + * @param sender The object that raised the event. + * @param e The event arguments. + */ private void BoissonView(object sender, EventArgs e) { if (EventSelect == null) { return; } @@ -32,6 +49,11 @@ public partial class Nourriture : ContentView changeButton.Content = newPage; } + /** + * @brief Event handler for the AutreView button. + * @param sender The object that raised the event. + * @param e The event arguments. + */ private void AutreView(object sender, EventArgs e) { if (EventSelect == null) { return; }