diff --git a/Sources/Modèle/Monstre.cs b/Sources/Modèle/Monstre.cs index 24bb8f6..46ba061 100644 --- a/Sources/Modèle/Monstre.cs +++ b/Sources/Modèle/Monstre.cs @@ -76,6 +76,19 @@ namespace Model public string ImageLink { get; init ; } + public bool IsChecked + { + get { return isChecked; } + set + { + if (isChecked != value) + { + isChecked = value; + OnPropertyChanged(nameof(IsChecked)); + } + } + } + private bool isChecked; public Monstre(int id, string name, string danger, string desc, List characList, List appearList, ObservableCollection conseilList) { if (string.IsNullOrWhiteSpace(name) || string.IsNullOrWhiteSpace(desc) || string.IsNullOrWhiteSpace(danger)) diff --git a/Sources/Vues/Collection.xaml b/Sources/Vues/Collection.xaml index 48c1d61..41302da 100644 --- a/Sources/Vues/Collection.xaml +++ b/Sources/Vues/Collection.xaml @@ -4,51 +4,29 @@ x:Class="Vues.Collection" BackgroundImageSource="backcollection.jpg" > - + - + - + - - - - - - - - - - - - - + + + + + + + + - - + \ No newline at end of file diff --git a/Sources/Vues/Collection.xaml.cs b/Sources/Vues/Collection.xaml.cs index c66c5d2..e04a015 100644 --- a/Sources/Vues/Collection.xaml.cs +++ b/Sources/Vues/Collection.xaml.cs @@ -1,9 +1,53 @@ +using Model; +using System.Collections.ObjectModel; +using System.ComponentModel; + namespace Vues; -public partial class Collection : ContentPage +public partial class Collection : ContentPage, INotifyPropertyChanged { - public Collection() + public ObservableCollection MnstrTemp = (Application.Current as App).monsterManager.ListMonsters; + + public Collection() { InitializeComponent(); + 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) + { + var concatMonstres = monstresDejaVu.Concat(monstresPasVu); + listMobs = new ObservableCollection(concatMonstres); + } + else if (CheckboxdejaVu.IsChecked) + { + listMobs = new ObservableCollection(monstresDejaVu); + } + else if (CheckboxpasVu.IsChecked) + { + listMobs = new ObservableCollection(monstresPasVu); + } + else + { + listMobs = new ObservableCollection(); + } + } + + private void CheckedVu(object sender, CheckedChangedEventArgs e) + { + UpdateListMobs(); + } + + private void CheckedPasVu(object sender, CheckedChangedEventArgs e) + { + UpdateListMobs(); + } + + } \ No newline at end of file diff --git a/Sources/Vues/Resources/Images/book.png b/Sources/Vues/Resources/Images/book.png new file mode 100644 index 0000000..43cf9ce Binary files /dev/null and b/Sources/Vues/Resources/Images/book.png differ diff --git a/Sources/Vues/SearchMob.xaml b/Sources/Vues/SearchMob.xaml index 8ff09ac..0108dda 100644 --- a/Sources/Vues/SearchMob.xaml +++ b/Sources/Vues/SearchMob.xaml @@ -63,7 +63,8 @@ BackgroundColor="{StaticResource buttonBackgroundColor}"> - + + - + diff --git a/Sources/Vues/SearchMob.xaml.cs b/Sources/Vues/SearchMob.xaml.cs index 5e81902..e1aa67e 100644 --- a/Sources/Vues/SearchMob.xaml.cs +++ b/Sources/Vues/SearchMob.xaml.cs @@ -55,6 +55,7 @@ public partial class SearchMob : ContentPage, INotifyPropertyChanged (App.Current as App).MonstreSelectionne = e.Item as Monstre; imageCollection.Source = imageLinkConverter((App.Current as App).MonstreSelectionne.AppearanceList.First()); AddConseilLayout.IsVisible = false; + CheckDejaVu.IsChecked = (App.Current as App).MonstreSelectionne.IsChecked; // Mets la checkbox "Déjà vu" en true ou false selon la propriété IsChecked du monstre sélectionné refreshScrollView(); } private void OnAddConseilClicked(object sender, EventArgs e) @@ -151,4 +152,38 @@ public partial class SearchMob : ContentPage, INotifyPropertyChanged } + private async void CollectionClicked(object sender, EventArgs e) + { + await Navigation.PushAsync(new Collection()); + } + + private async void QuitClicked(object sender, EventArgs e) + { + (Application.Current as App).User = null; + await Navigation.PushAsync(new Accueil()); + } + + 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); + } + } + else + { + 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 + ///si unchecked, retirer le monsrte + } } \ No newline at end of file