diff --git a/Sources/Model/Classes/Bateau.cs b/Sources/Model/Classes/Bateau.cs index decfaae..a06162b 100644 --- a/Sources/Model/Classes/Bateau.cs +++ b/Sources/Model/Classes/Bateau.cs @@ -1,6 +1,8 @@ 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; @@ -10,15 +12,16 @@ namespace Model.Classes { [DataContract(Name = "bateau")] public class Bateau : ObjetOhara - { + { [DataMember(Name = "nomromanise")] - private string nomromanise; - public string NomRomanise { + private string? nomromanise; + public string? NomRomanise { get=>nomromanise; set - { + { if(nomromanise == value) return; nomromanise = value; + OnPropertyChanged(); } } [DataMember(Name = "affiliation", EmitDefaultValue = false)] @@ -29,6 +32,7 @@ namespace Model.Classes { if(equipage == value) return; equipage = value; + OnPropertyChanged(); } } [DataMember(Name = "premierchap")] @@ -40,6 +44,7 @@ namespace Model.Classes { if (premierchap == value) return; premierchap = value; + OnPropertyChanged(); } } [DataMember(Name = "premierep")] @@ -51,37 +56,42 @@ namespace Model.Classes { if (premierep == value) return; premierep = value; + OnPropertyChanged(); } } [DataMember(Name = "description")] - private string description; - public string Description + private string? description; + public string? Description { get => description; set - { + { if (description == value) return; description = value; + OnPropertyChanged(); } } [DataMember(Name = "caracteristique")] - private string caracteristique; - public string Caracteristique { + private string? caracteristique; + public string? Caracteristique { get=> caracteristique; set { if(caracteristique == value) return; caracteristique = value; + OnPropertyChanged(); } } - public Bateau(string nom, string nomRomanise, int premierChap, int premierEp, string description, string caracteristique) : base(nom) + public Bateau(string nom, string nomRomanise, int premierChap, int premierEp, string description, string? caracteristique) : base(nom) { - - NomRomanise = nomRomanise; - + + if (String.IsNullOrEmpty(nomRomanise)) + NomRomanise = ""; + else + NomRomanise = nomRomanise; if (premierEp < 0) { PremierEp = 0; @@ -90,28 +100,33 @@ namespace Model.Classes { PremierEp = premierEp; } - if (premierChap < 0) + if (premierChap < 0 ) { - premierChap = 0; + PremierChap = 0; } + else { PremierChap = premierChap; } - Description = description; - Caracteristique = caracteristique; + if (String.IsNullOrEmpty(description)) + Description = "Description du bateau ..."; + else + Description = description; + + if (String.IsNullOrEmpty(caracteristique)) + Caracteristique = "Caracteristiques du bateau ..."; + else + Caracteristique = caracteristique; } public Bateau(string nom, string nomRomanise, int premierChap, int premierEp, string description, string caracteristique, string image) : this(nom, nomRomanise, premierChap, premierEp, description, caracteristique) { + if (String.IsNullOrEmpty(image)) + image = "baseimage.png"; Image = image; } - public Bateau(string nom, string nomRomanise, Equipage affiliation, int premierChap, int premierEp, string description, string caracteristique, string image) : this(nom, nomRomanise, premierChap, premierEp, description, caracteristique, image) - { - Affiliation = affiliation; - } - public override bool Equals(object? obj) { @@ -138,5 +153,7 @@ namespace Model.Classes { return "Bateau :" + Nom +" "+EstFavori +" " + NomRomanise + " " + Affiliation + " " + PremierChap + " " + PremierEp + " " + Description + " " + Caracteristique +" "+ Image; } + + } } diff --git a/Sources/Model/Classes/Bestiaire.cs b/Sources/Model/Classes/Bestiaire.cs index 3438e5a..d8e34c0 100644 --- a/Sources/Model/Classes/Bestiaire.cs +++ b/Sources/Model/Classes/Bestiaire.cs @@ -12,13 +12,11 @@ using System.Xml.Linq; namespace Model.Classes { [DataContract(Name = "bestiaire")] - public class Bestiaire : ObjetOhara, INotifyPropertyChanged - { - public event PropertyChangedEventHandler? PropertyChanged; - + public class Bestiaire : ObjetOhara + { [DataMember(Name = "origine")] - private string origine; - public string Origine { + private string? origine; + public string? Origine { get=>origine; set { @@ -28,8 +26,8 @@ namespace Model.Classes } } [DataMember(Name = "description")] - private string description; - public string Description { + private string? description; + public string? Description { get=>description; set { @@ -39,8 +37,8 @@ namespace Model.Classes } } [DataMember(Name = "caracteristique")] - private string caracteristique; - public string Caracteristique { + private string? caracteristique; + public string? Caracteristique { get=>caracteristique; set { @@ -52,13 +50,21 @@ namespace Model.Classes public Bestiaire(string nom, string origine, string description, string caracteristique) : base(nom) { + if (String.IsNullOrEmpty(origine)) + origine = "Grand Line"; Origine = origine; + if (String.IsNullOrEmpty(description)) + description = "Pour décrire ..."; Description = description; + if (String.IsNullOrEmpty(caracteristique)) + caracteristique = "Les caracteristiques ..."; Caracteristique = caracteristique; } public Bestiaire(string nom, string origine, string description, string caracteristique, string image) : this(nom, origine, description, caracteristique) { + if (String.IsNullOrWhiteSpace(image)) + image = "baseimage.png"; Image = image; } public override bool Equals(object? obj) @@ -75,18 +81,13 @@ namespace Model.Classes } } - public override int GetHashCode() { - return HashCode.Combine(Origine, Description, Caracteristique); } public override string ToString() { return "Bestiaire :" + Nom +" "+EstFavori+ " " + Origine + " " + Description + " " + Caracteristique +" " + Image; - } - - void OnPropertyChanged([CallerMemberName] string propertyName = null) - => PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName)); + } } } diff --git a/Sources/Model/Classes/Equipage.cs b/Sources/Model/Classes/Equipage.cs index c042228..02cd050 100644 --- a/Sources/Model/Classes/Equipage.cs +++ b/Sources/Model/Classes/Equipage.cs @@ -1,6 +1,8 @@ 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; @@ -12,17 +14,72 @@ namespace Model.Classes public class Equipage : ObjetOhara { [DataMember(Name = "nomromanise")] - public string NomRomanise { get; set; } + private string? nomromanise; + public string? NomRomanise + { + get => nomromanise; + set + { + if (nomromanise == value) return; + nomromanise = value; + OnPropertyChanged(); + } + } [DataMember(Name = "region")] - public string Region { get; set; } + private string? region; + public string? Region { + get=> region; + set + { + if (region == value) return; + region = value; + OnPropertyChanged(); + } + } [DataMember(Name = "premierchap")] - public int PremierChap { get; set; } + private int premierchap; + public int PremierChap { + get=>premierchap; + set + { + if(premierchap == value) return; + premierchap = value; + OnPropertyChanged(); + } + } [DataMember(Name = "premierep")] - public int PremierEp { get; set; } + private int premierep; + public int PremierEp { + get=>premierep; + set + { + if(premierep == value) return; + premierep = value; + OnPropertyChanged(); + } + } [DataMember(Name = "statut")] - public bool Statut { get; set; } + private bool statut; + public bool Statut { + get=>statut; + set + { + if (statut == value) return; + statut = value; + OnPropertyChanged(); + } + } [DataMember(Name = "description")] - public string Description { get; set; } + private string? description; + public string? Description { + get=>description; + set + { + if(description == value) return; + description = value; + OnPropertyChanged(); + } + } [DataMember(Name = "capitaine")] public Personnage? Capitaine { get; set; } [DataMember(Name = "membre")] @@ -59,7 +116,10 @@ namespace Model.Classes public Equipage(string nom, string nomRomanise, string region, int premierChap, int premierEp, bool statut, string description, string image) : this(nom, nomRomanise, region, premierChap, premierEp, statut, description) { - + if (String.IsNullOrWhiteSpace(image)) + { + image = "baseimage.png"; + } Image = image; } @@ -88,6 +148,6 @@ namespace Model.Classes public override string ToString() { return "Equipage :" + Nom +" "+EstFavori+ " " + NomRomanise + " " + Region + " " + PremierChap + " " + PremierEp + " " + Statut + " " + Description + " " + Image; - } + } } } diff --git a/Sources/Model/Classes/FruitDuDemon.cs b/Sources/Model/Classes/FruitDuDemon.cs index 80c3f2f..0e09e02 100644 --- a/Sources/Model/Classes/FruitDuDemon.cs +++ b/Sources/Model/Classes/FruitDuDemon.cs @@ -2,6 +2,7 @@ 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; @@ -10,27 +11,89 @@ using System.Xml.Linq; namespace Model.Classes { [DataContract(Name = "fruitdudemon")] - public class FruitDuDemon : ObjetOhara,INotifyPropertyChanged + public class FruitDuDemon : ObjetOhara { [DataMember(Name = "nomromanise")] - public string NomRomanise { get; set; } + private string? nomromanise; + public string? NomRomanise { + get=>nomromanise; + set + { + if(nomromanise==value) return; + nomromanise = value; + OnPropertyChanged(); + } + } [DataMember(Name = "type")] - public string Type { get; set; } + private string? type; + public string? Type { + get=>type; + set + { + if(type==value) return; + type = value; + OnPropertyChanged(); + } + } [DataMember(Name = "premierchap")] - public int PremierChap { get; set; } + private int premierchap; + public int PremierChap { + get=>premierchap; + set + { + if(premierchap==value) return; + premierchap = value; + OnPropertyChanged(); + } + } [DataMember(Name = "premierep")] - public int PremierEp { get; set; } + private int premierep; + public int PremierEp { + get=>premierep; + set + { + if (premierep==value) return; + premierep=value; + OnPropertyChanged(); + } + } [DataMember(Name = "description")] - public string Description { get; set; } + private string? description; + public string? Description { + get=>description; + set + { + if (description==value) return; + description = value; + OnPropertyChanged(); + } + } [DataMember(Name = "forces")] - public string Forces { get; set; } + private string? forces; + public string? Forces { + get=>forces; + set + { + if (forces==value) return; + forces = value; + OnPropertyChanged(); + } + } [DataMember(Name = "faiblesses")] - public string Faiblesses { get; set; } + private string? faiblesses; + public string? Faiblesses { + get=>faiblesses; + set + { + if (faiblesses == value) return; + faiblesses = value; + OnPropertyChanged(); + } + } [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) { @@ -46,7 +109,7 @@ namespace Model.Classes } if (premierChap < 0) { - premierChap = 0; + PremierChap = 0; } else { @@ -59,17 +122,10 @@ namespace Model.Classes public FruitDuDemon(string nom, string nomRomanise, string type, int premierChap, int premierEp, string description, string forces, string faiblesses, string image) : this(nom, nomRomanise, type, premierChap, premierEp, description, forces, faiblesses) { - + if (String.IsNullOrWhiteSpace(image)) + image = "baseimage.png"; Image = image; } - - public FruitDuDemon(string nom, string nomRomanise, string type, int premierChap, int premierEp, string description, string forces, string faiblesses, string image, List utilisateur) : this(nom, nomRomanise, type, premierChap, premierEp, description, forces, faiblesses, image) - { - Utilisateur = utilisateur; - } - - - public override bool Equals(object? obj) { if (obj == null) return false; @@ -93,14 +149,6 @@ namespace Model.Classes public override string ToString() { 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/Ile.cs b/Sources/Model/Classes/Ile.cs index 51eabfd..8ca1cb6 100644 --- a/Sources/Model/Classes/Ile.cs +++ b/Sources/Model/Classes/Ile.cs @@ -11,14 +11,11 @@ using System.Xml.Linq; namespace Model.Classes { [DataContract(Name = "ile")] - public class Ile : ObjetOhara, INotifyPropertyChanged + public class Ile : ObjetOhara { - - public event PropertyChangedEventHandler? PropertyChanged; - [DataMember(Name = "nomromanise")] - private string nomromanise; - public string NomRomanise + private string? nomromanise; + public string? NomRomanise { get => nomromanise; set @@ -30,8 +27,8 @@ namespace Model.Classes } [DataMember(Name = "region")] - private string region; - public string Region { + private string? region; + public string? Region { get=>region; set { @@ -63,8 +60,8 @@ namespace Model.Classes } } [DataMember(Name = "description")] - private string description; - public string Description { + private string? description; + public string? Description { get=>description; set { @@ -74,8 +71,8 @@ namespace Model.Classes } } [DataMember(Name = "geographie")] - private string geographie; - public string Geographie { + private string? geographie; + public string? Geographie { get=>geographie; set { @@ -89,8 +86,11 @@ namespace Model.Classes public Ile(string nom, string nomRomanise, string region, int premierChap, int premierEp, string description, string geographie) : base(nom) { - + if (String.IsNullOrWhiteSpace(nomRomanise)) + nomRomanise = "Nom romanisé de l'île..."; NomRomanise = nomRomanise; + if (String.IsNullOrWhiteSpace(region)) + region = "Grand Line"; Region = region; if (premierEp < 0) { @@ -102,20 +102,26 @@ namespace Model.Classes } if (premierChap < 0) { - premierChap = 0; + PremierChap = 0; } else { PremierChap = premierChap; } + if (String.IsNullOrWhiteSpace(description)) + description = "Description de l'île ..."; Description = description; + if (String.IsNullOrWhiteSpace(geographie)) + geographie = "Situation géographique de l'ile..."; Geographie = geographie; } public Ile(string nom, string nomRomanise, string region, int premierChap, int premierEp, string description, string geographie, string image) : this(nom, nomRomanise, region, premierChap, premierEp, description, geographie) { - + if(String.IsNullOrWhiteSpace(image)) { + image = "baseimage.png"; + } Image = image; } @@ -144,8 +150,5 @@ namespace Model.Classes { return "Ile :"+ Nom +" "+NomRomanise+" "+Region+" "+PremierChap+" "+PremierEp+" "+Description+" "+Geographie+" "+Image; } - - void OnPropertyChanged([CallerMemberName] string propertyName = null) - => PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName)); } } diff --git a/Sources/Model/Classes/ObjetOhara.cs b/Sources/Model/Classes/ObjetOhara.cs index 10dd036..f0fd9f4 100644 --- a/Sources/Model/Classes/ObjetOhara.cs +++ b/Sources/Model/Classes/ObjetOhara.cs @@ -16,8 +16,8 @@ namespace Model.Classes public event PropertyChangedEventHandler? PropertyChanged; [DataMember(Name = "nom")] - private string nom; - public string Nom { + private string? nom; + public string? Nom { get => nom; set { @@ -95,7 +95,7 @@ namespace Model.Classes return "ObjetOhara :" + Nom + " " +EstFavori+ " " + Image; } - void OnPropertyChanged([CallerMemberName] string propertyName = null) + protected void OnPropertyChanged([CallerMemberName] string? propertyName = null) => PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName)); } } diff --git a/Sources/Model/Classes/Personnage.cs b/Sources/Model/Classes/Personnage.cs index fa3fb72..2bb784e 100644 --- a/Sources/Model/Classes/Personnage.cs +++ b/Sources/Model/Classes/Personnage.cs @@ -1,4 +1,6 @@ -using System.Runtime.Serialization; +using System.ComponentModel; +using System.Runtime.CompilerServices; +using System.Runtime.Serialization; namespace Model.Classes { @@ -17,11 +19,12 @@ namespace Model.Classes return; } prime = value; + OnPropertyChanged(); } } [DataMember(Name = "epithete")] - private string epithete; - public string Epithete { + private string? epithete; + public string? Epithete { get=>epithete; set { @@ -43,6 +46,7 @@ namespace Model.Classes return; } age = value; + OnPropertyChanged(); } } [DataMember(Name = "taille")] @@ -56,11 +60,12 @@ namespace Model.Classes return; } taille = value; + OnPropertyChanged(); } } [DataMember(Name = "origine")] - private string origine; - public string Origine { + private string? origine; + public string? Origine { get=>origine; set { @@ -69,11 +74,12 @@ namespace Model.Classes return; } origine = value; + OnPropertyChanged(); } } [DataMember(Name = "biographie")] - private string biographie; - public string Biographie { + private string? biographie; + public string? Biographie { get=>biographie; set { @@ -82,11 +88,12 @@ namespace Model.Classes return; } biographie = value; + OnPropertyChanged(); } } [DataMember(Name = "citation")] - private string citation; - public string Citation { + private string? citation; + public string? Citation { get=>citation; set { @@ -95,11 +102,12 @@ namespace Model.Classes return; } citation = value; + OnPropertyChanged(); } } [DataMember(Name = "equipage", EmitDefaultValue = false)] - private Equipage equipage; - public Equipage Equipage { + private Equipage? equipage; + public Equipage? Equipage { get => equipage; set { @@ -108,6 +116,7 @@ namespace Model.Classes return; } equipage = value; + OnPropertyChanged(); } } [DataMember(Name = "fruit", EmitDefaultValue = false)] @@ -146,15 +155,10 @@ namespace Model.Classes public Personnage(string nom, double prime, string epithete, int age, double taille, string origine, string biographie, string citation, string image) : this(nom, prime, epithete, age, taille, origine, biographie, citation) { + if (String.IsNullOrWhiteSpace(image)) + image = "baseimage.png"; Image = image; } - public Personnage(string nom, double prime, string epithete, int age, double taille, string origine, string biographie, string citation, string image, Equipage equipage, List fruit) : this(nom, prime, epithete, age, taille, origine, biographie, citation, image) - { - Equipage = equipage; - Fruit = fruit; - - } - public override bool Equals(object? obj) { if (obj == null) return false; @@ -172,7 +176,6 @@ namespace Model.Classes public override int GetHashCode() { - return HashCode.Combine(Prime, Epithete, Age, Origine,Biographie, Citation,Equipage,Fruit); } diff --git a/Sources/Model/Managers/Manager.cs b/Sources/Model/Managers/Manager.cs index 68c13e7..f367347 100644 --- a/Sources/Model/Managers/Manager.cs +++ b/Sources/Model/Managers/Manager.cs @@ -99,7 +99,7 @@ namespace Model.Managers { bool correspondance = false; int textPos = 0; - for (int i = 0; i < (f.Nom.Length); i++) + for (int i = 0; i < (f.Nom?.Length); i++) { if (string.Equals(text[textPos].ToString(), f.Nom[i].ToString(), StringComparison.OrdinalIgnoreCase)) { @@ -290,5 +290,12 @@ namespace Model.Managers Fruits.Remove(ancienFDD); Fruits.Add(fruit); } + public void ModifierPerso(Personnage perso, string ancienNom) + { + Personnage? ancienPerso = Personnages.FirstOrDefault(p => p.Nom == ancienNom); + if (ancienPerso == null) return; + Personnages.Remove(ancienPerso); + Personnages.Add(perso); + } } } diff --git a/Sources/Model/Serializer/XML_Serializer.cs b/Sources/Model/Serializer/XML_Serializer.cs index 189fd28..de81bac 100644 --- a/Sources/Model/Serializer/XML_Serializer.cs +++ b/Sources/Model/Serializer/XML_Serializer.cs @@ -18,27 +18,27 @@ namespace Model.Serializer { StubManager stubManager = new StubManager(); Chemin = Directory.GetCurrentDirectory(); - if (File.Exists(Path.Combine(Chemin, "./personnage.xml"))==false) + if (!File.Exists(Path.Combine(Chemin, "./personnage.xml"))) { SetPersonnage(stubManager.GetPersonnages().ToList()); } - if (File.Exists(Path.Combine(Chemin, "./bateau.xml")) == false) + if (!File.Exists(Path.Combine(Chemin, "./bateau.xml"))) { SetBateau(stubManager.GetBateaux().ToList()); } - if (File.Exists(Path.Combine(Chemin, "./fruitdudemon.xml")) == false) + if (!File.Exists(Path.Combine(Chemin, "./fruitdudemon.xml"))) { SetFDD(stubManager.GetFruits().ToList()); } - if (File.Exists(Path.Combine(Chemin, "./bestiaire.xml")) == false) + if (!File.Exists(Path.Combine(Chemin, "./bestiaire.xml"))) { SetBestiaire(stubManager.GetBestiaires().ToList()); } - if (File.Exists(Path.Combine(Chemin, "./equipage.xml")) == false) + if (!File.Exists(Path.Combine(Chemin, "./equipage.xml"))) { SetEquipage(stubManager.GetEquipages().ToList()); } - if (File.Exists(Path.Combine(Chemin, "./ile.xml")) == false) + if (!File.Exists(Path.Combine(Chemin, "./ile.xml"))) { SetIle(stubManager.GetIles().ToList()); } @@ -48,27 +48,27 @@ namespace Model.Serializer { Chemin= path; StubManager stubManager = new StubManager(); - if (File.Exists(Path.Combine(Chemin, "./personnage.xml")) == false) + if (!File.Exists(Path.Combine(Chemin, "./personnage.xml"))) { SetPersonnage(stubManager.GetPersonnages().ToList()); } - if (File.Exists(Path.Combine(Chemin, "./bateau.xml")) == false) + if (!File.Exists(Path.Combine(Chemin, "./bateau.xml"))) { SetBateau(stubManager.GetBateaux().ToList()); } - if (File.Exists(Path.Combine(Chemin, "./fruitdudemon.xml")) == false) + if (!File.Exists(Path.Combine(Chemin, "./fruitdudemon.xml"))) { SetFDD(stubManager.GetFruits().ToList()); } - if (File.Exists(Path.Combine(Chemin, "./bestiaire.xml")) == false) + if (!File.Exists(Path.Combine(Chemin, "./bestiaire.xml"))) { SetBestiaire(stubManager.GetBestiaires().ToList()); } - if (File.Exists(Path.Combine(Chemin, "./equipage.xml")) == false) + if (!File.Exists(Path.Combine(Chemin, "./equipage.xml"))) { SetEquipage(stubManager.GetEquipages().ToList()); } - if (File.Exists(Path.Combine(Chemin, "./ile.xml")) == false) + if (!File.Exists(Path.Combine(Chemin, "./ile.xml"))) { SetIle(stubManager.GetIles().ToList()); } diff --git a/Sources/Model/Stub/StubEquipage.cs b/Sources/Model/Stub/StubEquipage.cs index ec24837..cd41237 100644 --- a/Sources/Model/Stub/StubEquipage.cs +++ b/Sources/Model/Stub/StubEquipage.cs @@ -9,7 +9,7 @@ namespace Model.Stub { public class StubEquipage { - public List Equipages { get; set; } + public List? Equipages { get; set; } public void ChargerEquipage(List persos) { diff --git a/Sources/Ohara/ModalPersonnage.xaml b/Sources/Ohara/ModalPersonnage.xaml index 14a4693..52c1da8 100644 --- a/Sources/Ohara/ModalPersonnage.xaml +++ b/Sources/Ohara/ModalPersonnage.xaml @@ -3,7 +3,8 @@ xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" x:Class="Ohara.ModalPersonnage" Title="ModalPersonnage" - BackgroundColor="#e2edf1"> + BackgroundColor="#e2edf1" + Shell.PresentationMode="ModalAnimated"> @@ -21,12 +22,7 @@