From f76cc48ea63c94de11a7297eb5c7b1725f21a017 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Yoan=20BRUGI=C3=88RE?= Date: Sat, 3 Jun 2023 09:34:56 +0200 Subject: [PATCH] =?UTF-8?q?Cr=C3=A9er=20FDD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Sources/Model/Classes/FruitDuDemon.cs | 15 +++- Sources/Model/Classes/ObjetOhara.cs | 42 ++++++++++- Sources/Model/Managers/Manager.cs | 8 ++ Sources/Ohara/ModalFDD.xaml | 103 +++++++++++++++++++++++++- Sources/Ohara/ModalFDD.xaml.cs | 18 ++++- 5 files changed, 174 insertions(+), 12 deletions(-) diff --git a/Sources/Model/Classes/FruitDuDemon.cs b/Sources/Model/Classes/FruitDuDemon.cs index 38dc8ff..80c3f2f 100644 --- a/Sources/Model/Classes/FruitDuDemon.cs +++ b/Sources/Model/Classes/FruitDuDemon.cs @@ -1,5 +1,6 @@ using System; using System.Collections.Generic; +using System.ComponentModel; using System.Linq; using System.Runtime.Serialization; using System.Text; @@ -9,7 +10,7 @@ using System.Xml.Linq; namespace Model.Classes { [DataContract(Name = "fruitdudemon")] - public class FruitDuDemon : ObjetOhara + public class FruitDuDemon : ObjetOhara,INotifyPropertyChanged { [DataMember(Name = "nomromanise")] public string NomRomanise { get; set; } @@ -28,7 +29,7 @@ namespace Model.Classes [DataMember(Name = "utilisateur", EmitDefaultValue = false)] public List Utilisateur { get; set; } = new List(); - + public event PropertyChangedEventHandler? PropertyChanged; public FruitDuDemon(string nom, string nomRomanise, string type, int premierChap, int premierEp, string description, string forces, string faiblesses) : base(nom) { @@ -67,6 +68,8 @@ namespace Model.Classes Utilisateur = utilisateur; } + + public override bool Equals(object? obj) { if (obj == null) return false; @@ -91,5 +94,13 @@ namespace Model.Classes { return "FruitDuDemon :" + Nom +" " +EstFavori+" " + NomRomanise + " " + Type + " " + PremierChap + " " + PremierEp + " " + Description + " " + Forces +" "+Faiblesses+ " " + Image; } + + void OnPropertyChanged(string propertyName) + { + if (PropertyChanged != null) + { + PropertyChanged(this, new PropertyChangedEventArgs(propertyName)); + } + } } } diff --git a/Sources/Model/Classes/ObjetOhara.cs b/Sources/Model/Classes/ObjetOhara.cs index eba17db..aa1f204 100644 --- a/Sources/Model/Classes/ObjetOhara.cs +++ b/Sources/Model/Classes/ObjetOhara.cs @@ -1,24 +1,55 @@ 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; +using System.Xml.Linq; namespace Model.Classes { [DataContract(Name = "objetohara")] - public class ObjetOhara + public class ObjetOhara : INotifyPropertyChanged { + + public event PropertyChangedEventHandler? PropertyChanged; [DataMember(Name = "nom")] - public string Nom { get; set; } + private string nom; + public string Nom { + get => nom; + set + { + if (nom == value) + { + return; + } + nom = value; + OnPropertyChanged(); + } + } [DataMember(Name = "image")] - public string? Image { get; set; } + private string? image; + public string? Image { + get => image; + set + { + + if (image == value) + return; + image = value; + OnPropertyChanged(); + + } + } [DataMember(Name = "estfavori")] public bool EstFavori { get; set; } + + public ObjetOhara(string nom, string image = "baseimage.png", bool estFavori = false) { Nom = nom; @@ -26,6 +57,8 @@ namespace Model.Classes EstFavori = estFavori; } + + public override bool Equals(object? obj) { if (obj == null) return false; @@ -50,6 +83,9 @@ namespace Model.Classes { return "ObjetOhara :" + Nom + " " +EstFavori+ " " + Image; } + + void OnPropertyChanged([CallerMemberName] string propertyName = null) + => PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName)); } } diff --git a/Sources/Model/Managers/Manager.cs b/Sources/Model/Managers/Manager.cs index 10b0656..34952f1 100644 --- a/Sources/Model/Managers/Manager.cs +++ b/Sources/Model/Managers/Manager.cs @@ -227,7 +227,15 @@ namespace Model.Managers } + public void AjouterFDD(FruitDuDemon fruit) + { + if (fruit == null) + { + return; + } + Fruits.Add(fruit); + } } } diff --git a/Sources/Ohara/ModalFDD.xaml b/Sources/Ohara/ModalFDD.xaml index 7d52063..18a04d7 100644 --- a/Sources/Ohara/ModalFDD.xaml +++ b/Sources/Ohara/ModalFDD.xaml @@ -3,9 +3,104 @@ xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" x:Class="Ohara.ModalFDD" Title="ModalFDD" - BackgroundColor="#e2edf1"> - -