diff --git a/README.md b/README.md index 33a34ab..e007e4d 100644 --- a/README.md +++ b/README.md @@ -158,7 +158,6 @@ Class StubPersonnage { } - FruitDuDemon --> "+ Utilisateur" Personnage Personnage --> "+ Equipage" Equipage Personnage --> "+ Fruit" FruitDuDemon diff --git a/Sources/Model/Classes/Bateau.cs b/Sources/Model/Classes/Bateau.cs index 8803e65..6000aa2 100644 --- a/Sources/Model/Classes/Bateau.cs +++ b/Sources/Model/Classes/Bateau.cs @@ -59,5 +59,32 @@ namespace Model.Classes { Affiliation = affiliation; } + + public override bool Equals(object? obj) + { + + if (obj == null) return false; + if (this.GetType() != obj.GetType()) + { + return false; + } + else + { + Bateau o = (Bateau)obj; + return o.Nom == Nom; + } + + } + + public override int GetHashCode() + { + + return HashCode.Combine(NomRomanise, Affiliation, PremierChap, PremierEp, Description, Caracteristique); + } + + public override string ToString() + { + 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 1a65e85..ba09fdc 100644 --- a/Sources/Model/Classes/Bestiaire.cs +++ b/Sources/Model/Classes/Bestiaire.cs @@ -19,8 +19,6 @@ namespace Model.Classes [DataMember(Name = "caracteristique")] public string Caracteristique { get; set; } - - public Bestiaire(string nom, string origine, string description, string caracteristique) : base(nom) { Origine = origine; @@ -32,7 +30,30 @@ namespace Model.Classes { Image = image; } + public override bool Equals(object? obj) + { + if (obj == null) return false; + if (this.GetType() != obj.GetType()) + { + return false; + } + else + { + Bestiaire o = (Bestiaire)obj; + return o.Nom == Nom; + } + + } + public override int GetHashCode() + { + + return HashCode.Combine(Origine, Description, Caracteristique); + } + public override string ToString() + { + return "Bestiaire :" + Nom +" "+EstFavori+ " " + Origine + " " + Description + " " + Caracteristique +" " + Image; + } } } diff --git a/Sources/Model/Classes/Equipage.cs b/Sources/Model/Classes/Equipage.cs index 1579a88..c042228 100644 --- a/Sources/Model/Classes/Equipage.cs +++ b/Sources/Model/Classes/Equipage.cs @@ -64,6 +64,30 @@ namespace Model.Classes } + public override bool Equals(object? obj) + { + if (obj == null) return false; + if (this.GetType() != obj.GetType()) + { + return false; + } + else + { + Equipage o = (Equipage)obj; + return o.Nom == Nom; + } + + } + + public override int GetHashCode() + { + return HashCode.Combine(NomRomanise, Region, PremierChap, PremierEp, Statut, Description); + } + + 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 42a6b44..38dc8ff 100644 --- a/Sources/Model/Classes/FruitDuDemon.cs +++ b/Sources/Model/Classes/FruitDuDemon.cs @@ -66,5 +66,30 @@ namespace Model.Classes { Utilisateur = utilisateur; } + + public override bool Equals(object? obj) + { + if (obj == null) return false; + if (this.GetType() != obj.GetType()) + { + return false; + } + else + { + FruitDuDemon o = (FruitDuDemon)obj; + return o.Nom == Nom; + } + + } + + public override int GetHashCode() + { + + return HashCode.Combine(NomRomanise, Type, PremierChap, PremierEp, Description, Forces, Faiblesses); + } + public override string ToString() + { + return "FruitDuDemon :" + Nom +" " +EstFavori+" " + NomRomanise + " " + Type + " " + PremierChap + " " + PremierEp + " " + Description + " " + Forces +" "+Faiblesses+ " " + Image; + } } } diff --git a/Sources/Model/Classes/Ile.cs b/Sources/Model/Classes/Ile.cs index ea21d60..d89e1f6 100644 --- a/Sources/Model/Classes/Ile.cs +++ b/Sources/Model/Classes/Ile.cs @@ -57,5 +57,27 @@ namespace Model.Classes Image = image; } + + public override bool Equals(object? obj) + { + if (obj == null) return false; + else + { + Ile o = (Ile)obj; + return o.Nom == Nom; + } + + } + + public override int GetHashCode() + { + + return HashCode.Combine(NomRomanise, Region, PremierChap, PremierEp, Description, Geographie); + } + + public override string ToString() + { + return "Ile :"+ Nom +" "+NomRomanise+" "+Region+" "+PremierChap+" "+PremierEp+" "+Description+" "+Geographie+" "+Image; + } } } diff --git a/Sources/Model/Classes/ObjetOhara.cs b/Sources/Model/Classes/ObjetOhara.cs index ecfbfdd..eba17db 100644 --- a/Sources/Model/Classes/ObjetOhara.cs +++ b/Sources/Model/Classes/ObjetOhara.cs @@ -12,9 +12,11 @@ namespace Model.Classes { [DataMember(Name = "nom")] public string Nom { get; set; } + [DataMember(Name = "image")] public string? Image { get; set; } + [DataMember(Name = "estfavori")] public bool EstFavori { get; set; } public ObjetOhara(string nom, string image = "baseimage.png", bool estFavori = false) @@ -23,6 +25,31 @@ namespace Model.Classes Image = image; EstFavori = estFavori; } + + public override bool Equals(object? obj) + { + if (obj == null) return false; + if (this.GetType() != obj.GetType()) + { + return false; + } + else + { + ObjetOhara o = (ObjetOhara)obj; + return o.Nom == Nom; + } + + } + + public override int GetHashCode() + { + + return HashCode.Combine(Nom, Image,EstFavori); + } + public override string ToString() + { + return "ObjetOhara :" + Nom + " " +EstFavori+ " " + Image; + } } } diff --git a/Sources/Model/Classes/Personnage.cs b/Sources/Model/Classes/Personnage.cs index 74c65a6..60699bc 100644 --- a/Sources/Model/Classes/Personnage.cs +++ b/Sources/Model/Classes/Personnage.cs @@ -65,5 +65,31 @@ namespace Model.Classes Fruit = fruit; } + + public override bool Equals(object? obj) + { + if (obj == null) return false; + if (this.GetType() != obj.GetType()) + { + return false; + } + else + { + Personnage o = (Personnage)obj; + return o.Nom == Nom; + } + + } + + public override int GetHashCode() + { + + return HashCode.Combine(Prime, Epithete, Age, Origine,Biographie, Citation,Equipage,Fruit); + } + + public override string ToString() + { + return "Personnage :" + Nom + " " + EstFavori + " " + Prime + " " + Epithete + " " + Age + " " + Origine + " " + Biographie + " "+ Citation+" " +Equipage+" " + Fruit+" "+ Image; + } } } \ No newline at end of file diff --git a/Sources/Model/Managers/IDataManager.cs b/Sources/Model/Managers/IDataManager.cs index ccb44e0..564ca42 100644 --- a/Sources/Model/Managers/IDataManager.cs +++ b/Sources/Model/Managers/IDataManager.cs @@ -15,5 +15,11 @@ namespace Model.Managers IEnumerable GetFruits(); IEnumerable GetIles(); IEnumerable GetPersonnages(); + void SetBateau(List listeBateaux); + void SetBestiaire(List listeBest); + void SetEquipage(List listeEquip); + void SetFDD(List listeFDD); + void SetIle(List listeIle); + void SetPersonnage(List listePerso); } } diff --git a/Sources/Model/Managers/Manager.cs b/Sources/Model/Managers/Manager.cs index bfb1965..841d385 100644 --- a/Sources/Model/Managers/Manager.cs +++ b/Sources/Model/Managers/Manager.cs @@ -1,8 +1,14 @@ + using Model.Classes; +using Microsoft.VisualBasic; +using Model.Serializer; using Model.Stub; using System; using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.IO; using System.Linq; +using System.Resources; using System.Text; using System.Threading.Tasks; @@ -12,12 +18,23 @@ namespace Model.Managers public class Manager { public IDataManager DataManager { get; set; } + public ObservableCollection Bateaux { get; set; } + public ObservableCollection Personnages { get; set; } + public ObservableCollection Fruits { get; set; } + public ObservableCollection Iles { get; set; } + public ObservableCollection Bestiaire { get; set; } + public ObservableCollection Equipages { get; set; } + + public ObjetOhara? SelectedItem { get; set; } = null; - - - public Manager() - { - DataManager = new StubManager(); + public Manager(IDataManager dataManager) { + DataManager = dataManager; + Bateaux = new ObservableCollection(DataManager.GetBateaux()); + Personnages = new ObservableCollection(DataManager.GetPersonnages()); + Fruits = new ObservableCollection(DataManager.GetFruits()); + Iles = new ObservableCollection(DataManager.GetIles()); + Bestiaire = new ObservableCollection(DataManager.GetBestiaires()); + Equipages = new ObservableCollection(DataManager.GetEquipages()); } public List GetPersonnages() @@ -88,19 +105,48 @@ namespace Model.Managers } return listeFDD; } + public List RechercheObjetOhara(string text, List liste) + { + if (text == "") + { + return liste; + } + foreach (ObjetOhara f in liste.ToList()) + { + bool correspondance = false; + int textPos = 0; + for (int i = 0; i < (f.Nom.Length); i++) + { + if (string.Equals(text[textPos].ToString(), f.Nom[i].ToString(), StringComparison.OrdinalIgnoreCase)) + { + textPos++; + } + if (textPos == text.Length) + { + correspondance = true; + break; + } + } + if (!correspondance) + { + liste.Remove(f); + } + } + return liste; + } public List GetFavoris() { List listeFavoris = new List(); - listeFavoris.AddRange(GetBateaux()); - listeFavoris.AddRange(GetIles()); - listeFavoris.AddRange(GetEquipages()); - listeFavoris.AddRange(GetFruits()); - listeFavoris.AddRange(GetBestiaires()); - listeFavoris.AddRange(GetPersonnages()); - foreach (ObjetOhara obj in listeFavoris.ToList()) + listeFavoris.AddRange(Bateaux); + listeFavoris.AddRange(Equipages); + listeFavoris.AddRange(Bestiaire); + listeFavoris.AddRange(Fruits); + listeFavoris.AddRange(Iles); + listeFavoris.AddRange(Personnages); + foreach(ObjetOhara obj in listeFavoris.ToList()) { - if (obj.EstFavori == true) + if (obj.EstFavori == false) { listeFavoris.Remove(obj); } @@ -108,9 +154,72 @@ namespace Model.Managers return listeFavoris; } - public void AddBateauFavoris(Bateau bateau) + public void ModifierFavoris(ObjetOhara obj,bool value) { - bateau.EstFavori = true; + Type t = obj.GetType(); + + if (t.Equals(typeof(Bateau))) + foreach(Bateau b in Bateaux) + { + if (b.Equals(obj)) + { + b.EstFavori = value; + DataManager.SetBateau(Bateaux.ToList()); + } + } + else if (t.Equals(typeof(Equipage))) + foreach (Equipage b in Equipages) + { + if (b.Equals(obj)) + { + b.EstFavori = value; + DataManager.SetEquipage(Equipages.ToList()); + } + } + + else if (t.Equals(typeof(Personnage))) + foreach (Personnage b in Personnages) + { + if (b.Equals(obj)) + { + b.EstFavori = value; + DataManager.SetPersonnage(Personnages.ToList()); + } + } + + else if (t.Equals(typeof(Ile))) + foreach (Ile b in Iles) + { + if (b.Equals(obj)) + { + b.EstFavori = value; + DataManager.SetIle(Iles.ToList()); + } + } + + else if (t.Equals(typeof(FruitDuDemon))) + foreach (FruitDuDemon b in Fruits) + { + if (b.Equals(obj)) + { + b.EstFavori = true; + DataManager.SetFDD(Fruits.ToList()); + } + } + + else if (t.Equals(typeof(Bestiaire))) + foreach (Bestiaire b in Bestiaire) + { + if (b.Equals(obj)) + { + b.EstFavori = value; + DataManager.SetBestiaire(Bestiaire.ToList()); + } + } + } + + + } } diff --git a/Sources/Model/Serializer/XML_Serializer.cs b/Sources/Model/Serializer/XML_Serializer.cs index bed8fb9..189fd28 100644 --- a/Sources/Model/Serializer/XML_Serializer.cs +++ b/Sources/Model/Serializer/XML_Serializer.cs @@ -1,4 +1,5 @@ -using System; +using Model.Stub; +using System; using System.Collections.Generic; using System.Linq; using System.Runtime.Serialization; @@ -12,16 +13,72 @@ namespace Model.Serializer { public class XML_Serializer : IDataManager { + public string Chemin { get; set; } public XML_Serializer() { - + StubManager stubManager = new StubManager(); + Chemin = Directory.GetCurrentDirectory(); + if (File.Exists(Path.Combine(Chemin, "./personnage.xml"))==false) + { + SetPersonnage(stubManager.GetPersonnages().ToList()); + } + if (File.Exists(Path.Combine(Chemin, "./bateau.xml")) == false) + { + SetBateau(stubManager.GetBateaux().ToList()); + } + if (File.Exists(Path.Combine(Chemin, "./fruitdudemon.xml")) == false) + { + SetFDD(stubManager.GetFruits().ToList()); + } + if (File.Exists(Path.Combine(Chemin, "./bestiaire.xml")) == false) + { + SetBestiaire(stubManager.GetBestiaires().ToList()); + } + if (File.Exists(Path.Combine(Chemin, "./equipage.xml")) == false) + { + SetEquipage(stubManager.GetEquipages().ToList()); + } + if (File.Exists(Path.Combine(Chemin, "./ile.xml")) == false) + { + SetIle(stubManager.GetIles().ToList()); + } + } + + public XML_Serializer(string path) + { + Chemin= path; + StubManager stubManager = new StubManager(); + if (File.Exists(Path.Combine(Chemin, "./personnage.xml")) == false) + { + SetPersonnage(stubManager.GetPersonnages().ToList()); + } + if (File.Exists(Path.Combine(Chemin, "./bateau.xml")) == false) + { + SetBateau(stubManager.GetBateaux().ToList()); + } + if (File.Exists(Path.Combine(Chemin, "./fruitdudemon.xml")) == false) + { + SetFDD(stubManager.GetFruits().ToList()); + } + if (File.Exists(Path.Combine(Chemin, "./bestiaire.xml")) == false) + { + SetBestiaire(stubManager.GetBestiaires().ToList()); + } + if (File.Exists(Path.Combine(Chemin, "./equipage.xml")) == false) + { + SetEquipage(stubManager.GetEquipages().ToList()); + } + if (File.Exists(Path.Combine(Chemin, "./ile.xml")) == false) + { + SetIle(stubManager.GetIles().ToList()); + } } public void SetPersonnage(List listePerso) { var serializer = new DataContractSerializer(typeof(List)); string xmlFile = "personnage.xml"; - Directory.SetCurrentDirectory(Path.Combine(Directory.GetCurrentDirectory(), "./")); + Directory.SetCurrentDirectory(Path.Combine(Chemin, "./")); XmlWriterSettings settings = new XmlWriterSettings() { Indent = true }; using (TextWriter tw = File.CreateText(xmlFile)) { @@ -38,7 +95,7 @@ namespace Model.Serializer { var serializer = new DataContractSerializer(typeof(List)); string xmlFile = "fruitdudemon.xml"; - Directory.SetCurrentDirectory(Path.Combine(Directory.GetCurrentDirectory(), "./")); + Directory.SetCurrentDirectory(Path.Combine(Chemin, "./")); XmlWriterSettings settings = new XmlWriterSettings() { Indent = true }; using (TextWriter tw = File.CreateText(xmlFile)) { @@ -56,7 +113,7 @@ namespace Model.Serializer { var serializer = new DataContractSerializer(typeof(List)); string xmlFile = "bestiaire.xml"; - Directory.SetCurrentDirectory(Path.Combine(Directory.GetCurrentDirectory(), "./")); + Directory.SetCurrentDirectory(Path.Combine(Chemin, "./")); XmlWriterSettings settings = new XmlWriterSettings() { Indent = true }; using (TextWriter tw = File.CreateText(xmlFile)) { @@ -74,7 +131,7 @@ namespace Model.Serializer { var serializer = new DataContractSerializer(typeof(List)); string xmlFile = "equipage.xml"; - Directory.SetCurrentDirectory(Path.Combine(Directory.GetCurrentDirectory(), "./")); + Directory.SetCurrentDirectory(Path.Combine(Chemin, "./")); XmlWriterSettings settings = new XmlWriterSettings() { Indent = true }; using (TextWriter tw = File.CreateText(xmlFile)) { @@ -92,7 +149,7 @@ namespace Model.Serializer { var serializer = new DataContractSerializer(typeof(List)); string xmlFile = "ile.xml"; - Directory.SetCurrentDirectory(Path.Combine(Directory.GetCurrentDirectory(), "./")); + Directory.SetCurrentDirectory(Path.Combine(Chemin, "./")); XmlWriterSettings settings = new XmlWriterSettings() { Indent = true }; using (TextWriter tw = File.CreateText(xmlFile)) { @@ -110,7 +167,7 @@ namespace Model.Serializer { var serializer = new DataContractSerializer(typeof(List)); string xmlFile = "bateau.xml"; - Directory.SetCurrentDirectory(Path.Combine(Directory.GetCurrentDirectory(), "./")); + Directory.SetCurrentDirectory(Path.Combine(Chemin, "./")); XmlWriterSettings settings = new XmlWriterSettings() { Indent = true }; using (TextWriter tw = File.CreateText(xmlFile)) { @@ -126,24 +183,26 @@ namespace Model.Serializer public IEnumerable GetBateaux() { - List listeBateau = new List(); + List? listeBateau = new List(); var serializer = new DataContractSerializer(typeof(List)); string xmlFile = "bateau.xml"; - Directory.SetCurrentDirectory(Path.Combine(Directory.GetCurrentDirectory(), "./")); + Directory.SetCurrentDirectory(Path.Combine(Chemin, "./")); using (Stream s = File.OpenRead(xmlFile)) { listeBateau = serializer.ReadObject(s) as List; } + + return listeBateau; } public IEnumerable GetBestiaires() { - List listeBest = new List(); + List? listeBest = new List(); var serializer = new DataContractSerializer(typeof(List)); string xmlFile = "bestiaire.xml"; - Directory.SetCurrentDirectory(Path.Combine(Directory.GetCurrentDirectory(), "./")); + Directory.SetCurrentDirectory(Path.Combine(Chemin, "./")); using (Stream s = File.OpenRead(xmlFile)) { @@ -153,10 +212,10 @@ namespace Model.Serializer } public IEnumerable GetEquipages() { - List listeEquip = new List(); + List? listeEquip = new List(); var serializer = new DataContractSerializer(typeof(List)); string xmlFile = "equipage.xml"; - Directory.SetCurrentDirectory(Path.Combine(Directory.GetCurrentDirectory(), "./")); + Directory.SetCurrentDirectory(Path.Combine(Chemin, "./")); using (Stream s = File.OpenRead(xmlFile)) { @@ -166,10 +225,10 @@ namespace Model.Serializer } public IEnumerable GetFruits() { - List listeFDD = new List(); + List? listeFDD = new List(); var serializer = new DataContractSerializer(typeof(List)); string xmlFile = "fruitdudemon.xml"; - Directory.SetCurrentDirectory(Path.Combine(Directory.GetCurrentDirectory(), "./")); + Directory.SetCurrentDirectory(Path.Combine(Chemin, "./")); using (Stream s = File.OpenRead(xmlFile)) { @@ -179,10 +238,10 @@ namespace Model.Serializer } public IEnumerable GetIles() { - List listeIle = new List(); + List? listeIle = new List(); var serializer = new DataContractSerializer(typeof(List)); string xmlFile = "ile.xml"; - Directory.SetCurrentDirectory(Path.Combine(Directory.GetCurrentDirectory(), "./")); + Directory.SetCurrentDirectory(Path.Combine(Chemin, "./")); using (Stream s = File.OpenRead(xmlFile)) { @@ -192,10 +251,10 @@ namespace Model.Serializer } public IEnumerable GetPersonnages() { - List listePerso = new List(); + List? listePerso = new List(); var serializer = new DataContractSerializer(typeof(List)); string xmlFile = "personnage.xml"; - Directory.SetCurrentDirectory(Path.Combine(Directory.GetCurrentDirectory(), "./")); + Directory.SetCurrentDirectory(Path.Combine(Chemin, "./")); using (Stream s = File.OpenRead(xmlFile)) { diff --git a/Sources/Model/Stub/StubManager.cs b/Sources/Model/Stub/StubManager.cs index 6a61469..72d6f51 100644 --- a/Sources/Model/Stub/StubManager.cs +++ b/Sources/Model/Stub/StubManager.cs @@ -1,4 +1,5 @@ -using System; +using Model.Serializer; +using System; using System.Collections.Generic; using System.Linq; using System.Text; @@ -10,7 +11,7 @@ namespace Model.Stub { public class StubManager : IDataManager { - + public StubPersonnage StubPersonnage { get; set; } public StubFruitDuDemon StubFruitDuDemon { get; set; } public StubEquipage StubEquipage { get; set; } @@ -20,6 +21,7 @@ namespace Model.Stub public StubManager() { + StubPersonnage = new StubPersonnage(); StubFruitDuDemon = new StubFruitDuDemon(); StubEquipage = new StubEquipage(); @@ -54,5 +56,35 @@ namespace Model.Stub { return StubIle.RecupererIle(); } + + public void SetBateau(List listeBateaux) + { + throw new NotImplementedException(); + } + + public void SetBestiaire(List listeBest) + { + throw new NotImplementedException(); + } + + public void SetEquipage(List listeEquip) + { + throw new NotImplementedException(); + } + + public void SetFDD(List listeFDD) + { + throw new NotImplementedException(); + } + + public void SetIle(List listeIle) + { + throw new NotImplementedException(); + } + + public void SetPersonnage(List listePerso) + { + throw new NotImplementedException(); + } } } diff --git a/Sources/Ohara/App.xaml.cs b/Sources/Ohara/App.xaml.cs index 6044b77..d8adc4b 100644 --- a/Sources/Ohara/App.xaml.cs +++ b/Sources/Ohara/App.xaml.cs @@ -1,15 +1,18 @@ -using Model.Managers; -using Plugin.Maui.Audio; +using Model.Serializer; +using Model.Stub; +using Model.Managers; namespace Ohara; + public partial class App : Application { - public Manager manager { get; set; } = new Manager(); + + public Manager manager { get; set; } = new Manager(new XML_Serializer(FileSystem.Current.AppDataDirectory)); public App() { - InitializeComponent(); - + InitializeComponent(); + MainPage = new AppShell(); } } diff --git a/Sources/Ohara/AppShell.xaml b/Sources/Ohara/AppShell.xaml index 454e867..c6b45b5 100644 --- a/Sources/Ohara/AppShell.xaml +++ b/Sources/Ohara/AppShell.xaml @@ -5,28 +5,24 @@ xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" xmlns:local="clr-namespace:Ohara" Shell.FlyoutBehavior="Locked" - Shell.NavBarIsVisible="False" - Shell.Background="#72a3b3" + Shell.NavBarIsVisible="False" + Shell.FlyoutWidth="300" > - - - - - + + + + + - + @@ -37,6 +33,8 @@ - + + diff --git a/Sources/Ohara/MainPage.xaml b/Sources/Ohara/MainPage.xaml index a21a3e5..caceff8 100644 --- a/Sources/Ohara/MainPage.xaml +++ b/Sources/Ohara/MainPage.xaml @@ -3,25 +3,25 @@ xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" x:Class="Ohara.MainPage" BackgroundColor="#e2edf1"> + + + + + + diff --git a/Sources/Ohara/PageBateau.xaml b/Sources/Ohara/PageBateau.xaml index f50c5db..284831b 100644 --- a/Sources/Ohara/PageBateau.xaml +++ b/Sources/Ohara/PageBateau.xaml @@ -7,28 +7,19 @@ - - - - - - - - - - - + + + - + diff --git a/Sources/Ohara/PageBateau.xaml.cs b/Sources/Ohara/PageBateau.xaml.cs index c32b529..35b01ae 100644 --- a/Sources/Ohara/PageBateau.xaml.cs +++ b/Sources/Ohara/PageBateau.xaml.cs @@ -12,12 +12,18 @@ public partial class PageBateau : ContentPage public PageBateau() { InitializeComponent(); - listeBateau.ItemsSource = manager.GetBateaux(); + BindingContext = manager; } async void listeBateau_SelectionChanged(object sender, SelectionChangedEventArgs e) { - await Navigation.PushAsync(new PageInfoBateau((Bateau)listeBateau.SelectedItem)); + manager.SelectedItem = (Bateau)listeBateau.SelectedItem; + await Navigation.PushAsync(new PageInfoBateau()); + } + + private void Button_Clicked(object sender, EventArgs e) + { + } } \ No newline at end of file diff --git a/Sources/Ohara/PageBestiaire.xaml b/Sources/Ohara/PageBestiaire.xaml index b987382..b97820d 100644 --- a/Sources/Ohara/PageBestiaire.xaml +++ b/Sources/Ohara/PageBestiaire.xaml @@ -6,27 +6,22 @@ BackgroundColor="#e2edf1"> - - - - - - - - - - - - - - - + + + + + + + + + diff --git a/Sources/Ohara/PageBestiaire.xaml.cs b/Sources/Ohara/PageBestiaire.xaml.cs index 469dfd1..8839569 100644 --- a/Sources/Ohara/PageBestiaire.xaml.cs +++ b/Sources/Ohara/PageBestiaire.xaml.cs @@ -9,17 +9,16 @@ namespace Ohara; public partial class PageBestiaire : ContentPage { public Manager manager => (App.Current as App).manager; - public ICommand AjouterFavoris { get; private set; } + public PageBestiaire() { InitializeComponent(); - //AjouterFavoris = new Command((obj) => manager.AddFavoris((ObjetOhara)obj)); - listeBest.ItemsSource = manager.GetBestiaires(); + BindingContext = manager; } async void listeBest_SelectionChanged(object sender, SelectionChangedEventArgs e) { - - await Navigation.PushAsync(new PageInfoBestiaire((Bestiaire)listeBest.SelectedItem)); + manager.SelectedItem = (Bestiaire)listeBest.SelectedItem; + await Navigation.PushAsync(new PageInfoBestiaire()); } } \ No newline at end of file diff --git a/Sources/Ohara/PageEquipage.xaml b/Sources/Ohara/PageEquipage.xaml index 03c8d63..fada58d 100644 --- a/Sources/Ohara/PageEquipage.xaml +++ b/Sources/Ohara/PageEquipage.xaml @@ -5,56 +5,47 @@ Title="PageEquipage" BackgroundColor="#e2edf1"> - - - - - - - - - - - - - - - - - - - - - - - - - - + - - - - - - + + + + \ No newline at end of file diff --git a/Sources/Ohara/PageEquipage.xaml.cs b/Sources/Ohara/PageEquipage.xaml.cs index 0159aec..5966905 100644 --- a/Sources/Ohara/PageEquipage.xaml.cs +++ b/Sources/Ohara/PageEquipage.xaml.cs @@ -10,13 +10,14 @@ public partial class PageEquipage : ContentPage public PageEquipage() { InitializeComponent(); - listeEquip.ItemsSource = manager.GetEquipages(); - + BindingContext = manager; + + } async void listeEquip_SelectionChanged(object sender, SelectionChangedEventArgs e) { - - await Navigation.PushAsync(new PageInfoEquipage((Equipage)listeEquip.SelectedItem)); + manager.SelectedItem=(Equipage)listeEquip.SelectedItem; + await Navigation.PushAsync(new PageInfoEquipage()); } } \ No newline at end of file diff --git a/Sources/Ohara/PageFDD.xaml b/Sources/Ohara/PageFDD.xaml index 6ed942d..d4c30d2 100644 --- a/Sources/Ohara/PageFDD.xaml +++ b/Sources/Ohara/PageFDD.xaml @@ -1,89 +1,64 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Sources/Ohara/PageFDD.xaml.cs b/Sources/Ohara/PageFDD.xaml.cs index 559c654..ab3b70c 100644 --- a/Sources/Ohara/PageFDD.xaml.cs +++ b/Sources/Ohara/PageFDD.xaml.cs @@ -15,16 +15,16 @@ public partial class PageFDD : ContentPage { InitializeComponent(); - listeFDD.ItemsSource = manager.GetFruits(); + BindingContext = manager; void OnTextChanged(object sender, EventArgs e) { SearchBar searchBar = (SearchBar)sender; - listeFDD.ItemsSource = manager.RechercheFDD(searchBar.Text,manager.GetFruits()); + listeFDD.ItemsSource = manager.RechercheFDD(searchBar.Text,manager.Fruits.ToList()); } searchBar.TextChanged += OnTextChanged; FiltrerType = new Command((type) => listeFDD.ItemsSource = manager.FiltrerFDD(type.ToString())); - Logia.Command = FiltrerType; - Logia.CommandParameter = "Logia"; + //Logia.Command = FiltrerType; + //Logia.CommandParameter = "Logia"; } @@ -45,7 +45,7 @@ public partial class PageFDD : ContentPage async void listeFDD_SelectionChanged(object sender, SelectionChangedEventArgs e) { - - await Navigation.PushAsync(new PageInfoFdd((FruitDuDemon)listeFDD.SelectedItem)); + manager.SelectedItem=(FruitDuDemon)listeFDD.SelectedItem; + await Navigation.PushAsync(new PageInfoFdd()); } } \ No newline at end of file diff --git a/Sources/Ohara/PageFavoris.xaml b/Sources/Ohara/PageFavoris.xaml index d84c21f..cceb69f 100644 --- a/Sources/Ohara/PageFavoris.xaml +++ b/Sources/Ohara/PageFavoris.xaml @@ -1,63 +1,56 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + +