From e80b34bc31082f727806d8542f2c9d020fbe323b Mon Sep 17 00:00:00 2001 From: "yannis.doumir_fernandes" Date: Fri, 9 Jun 2023 22:27:35 +0200 Subject: [PATCH] =?UTF-8?q?Ajout=20d'un=20monstre=20de=20base=20dans=20la?= =?UTF-8?q?=20liste=20monstreDejaVu=20dans=20le=20stub=20+=20Binding=20pag?= =?UTF-8?q?e=20Collection=20pas=20encore=20compl=C3=A9tement=20foctionnel?= =?UTF-8?q?=20(probl=C3=A8me=20StringFormat?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Sources/Persistance/LoaderStub.cs | 9 +++++---- Sources/Vues/Collection.xaml | 12 ++++++++---- Sources/Vues/Collection.xaml.cs | 21 ++++++++++++++++----- Sources/Vues/SearchMob.xaml.cs | 6 ++---- 4 files changed, 31 insertions(+), 17 deletions(-) diff --git a/Sources/Persistance/LoaderStub.cs b/Sources/Persistance/LoaderStub.cs index 0961663..6f66884 100644 --- a/Sources/Persistance/LoaderStub.cs +++ b/Sources/Persistance/LoaderStub.cs @@ -18,9 +18,10 @@ namespace Persistance public LoaderStub() { } public List loadUsers() ///CHANGER VISIBILITEE, CAR PAS BIEN DE LAISSER A TOUT LE MONDE { + Monstre monstre = new Monstre(1, "Poule", "passif", "Les poules sont des créatures passives. Elles fournissent des plumes et des oeufs.En moyenne, une poule laisse tomber un oeuf toutes des 5 à 10 minutes.", new List { "Quand une poule est tuée, il y a une faible chance qu'elle laisse tomber un Å“uf.", "Parfois, les poules apparaissent avec un bébé zombie sur le dos, on l'appelle alors une poule jockey. Il est aussi possible d'avoir un bébé cochon zombie sur son dos, mais seulement par commande." }, new List { "Poule", "Poule jockey", "Poule jockey cochon" }, new ObservableCollection { }); List lu = new List(); - lu.Add(new User("DedeDu42", "dede", "dodo", "mdp", new List { })); - lu.Add(new User("Moi", "Monchanin", "Liam", "feur", new List { })); + lu.Add(new User("DedeDu42", "dede", "dodo", "mdp", new List { monstre })); + lu.Add(new User("Moi", "Monchanin", "Liam", "feur", new List { monstre })); lu.Add(new User("Nikoala", "Blondeau", "Nicolas", "niblondeau", new List { new Monstre(2, "Mouton", "passif", "Je suis présent un peu partout, sauf dnas le desert.", @@ -28,8 +29,8 @@ namespace Persistance new List { "Apparence1", "App2", "App3" } , new ObservableCollection {}) })); - lu.Add(new User("Yadoumir", "Doumir", "Yannis", "mdp", new List { })); - lu.Add(new User("osuplayer123", "Bonetti", "Martin", "oSu!727", new List { })); + lu.Add(new User("Yadoumir", "Doumir", "Yannis", "mdp", new List { monstre })); + lu.Add(new User("osuplayer123", "Bonetti", "Martin", "oSu!727", new List { monstre })); return lu; } diff --git a/Sources/Vues/Collection.xaml b/Sources/Vues/Collection.xaml index 41302da..dc3289a 100644 --- a/Sources/Vues/Collection.xaml +++ b/Sources/Vues/Collection.xaml @@ -18,15 +18,19 @@ CheckedChanged="CheckedPasVu"> - - + + - + + + + + - + \ No newline at end of file diff --git a/Sources/Vues/Collection.xaml.cs b/Sources/Vues/Collection.xaml.cs index e04a015..51aaf4d 100644 --- a/Sources/Vues/Collection.xaml.cs +++ b/Sources/Vues/Collection.xaml.cs @@ -7,18 +7,24 @@ namespace Vues; public partial class Collection : ContentPage, INotifyPropertyChanged { public ObservableCollection MnstrTemp = (Application.Current as App).monsterManager.ListMonsters; + public ObservableCollection MonstresDejaVu { get; set; } public Collection() - { - InitializeComponent(); - BindingContext = this; - } + { + InitializeComponent(); + User toto = (Application.Current as App).User; + MonstresDejaVu = new ObservableCollection(toto.monstresDejaVu); + + ListViewMonsters.BindingContext = this; + } + private void UpdateListMobs() { var monstresDejaVu = MnstrTemp.Where(monstre => (Application.Current as App).User.monstresDejaVu.Contains(monstre)).ToList(); var monstresPasVu = MnstrTemp.Except((Application.Current as App).User.monstresDejaVu).ToList(); var listMobs = new ObservableCollection(); listMobs.Clear(); + if (CheckboxdejaVu.IsChecked && CheckboxpasVu.IsChecked) { @@ -49,5 +55,10 @@ public partial class Collection : ContentPage, INotifyPropertyChanged UpdateListMobs(); } - + private string imageLinkConverter(string imageLink) + { + imageLink = String.Concat(imageLink.Where(c => !Char.IsWhiteSpace(c))); + imageLink = "collection" + imageLink.ToLower() + ".png"; + return imageLink; + } } \ No newline at end of file diff --git a/Sources/Vues/SearchMob.xaml.cs b/Sources/Vues/SearchMob.xaml.cs index 8ceea19..b75055a 100644 --- a/Sources/Vues/SearchMob.xaml.cs +++ b/Sources/Vues/SearchMob.xaml.cs @@ -164,12 +164,11 @@ public partial class SearchMob : ContentPage, INotifyPropertyChanged private void CheckBox_CheckedChanged(object sender, CheckedChangedEventArgs e) { - /* + if (CheckDejaVu.IsChecked) { if ((App.Current as App).User != null) { - (Application.Current as App).MonstreSelectionne.IsChecked = true; (Application.Current as App).User.monstresDejaVu.Add((Application.Current as App).MonstreSelectionne); } } @@ -177,11 +176,10 @@ public partial class SearchMob : ContentPage, INotifyPropertyChanged { if ((App.Current as App).User != null) { - (Application.Current as App).MonstreSelectionne.IsChecked = false; (Application.Current as App).User.monstresDejaVu.Remove((Application.Current as App).MonstreSelectionne); } } - */ + ///Si checkbox check ///add le monstre courant à la liste des monstre du user