You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
SAE_2.01_-_Developpement_du.../Sources/Vues/Collection.xaml.cs

64 lines
2.0 KiB

using Model;
using System.Collections.ObjectModel;
using System.ComponentModel;
namespace Vues;
public partial class Collection : ContentPage, INotifyPropertyChanged
{
public ObservableCollection<Monstre> MnstrTemp = (Application.Current as App).monsterManager.ListMonsters;
public ObservableCollection<Monstre> MonstresDejaVu { get; set; }
public Collection()
{
InitializeComponent();
User toto = (Application.Current as App).User;
MonstresDejaVu = new ObservableCollection<Monstre>(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<Monstre>();
listMobs.Clear();
if (CheckboxdejaVu.IsChecked && CheckboxpasVu.IsChecked)
{
var concatMonstres = monstresDejaVu.Concat(monstresPasVu);
listMobs = new ObservableCollection<Monstre>(concatMonstres);
}
else if (CheckboxdejaVu.IsChecked)
{
listMobs = new ObservableCollection<Monstre>(monstresDejaVu);
}
else if (CheckboxpasVu.IsChecked)
{
listMobs = new ObservableCollection<Monstre>(monstresPasVu);
}
else
{
listMobs = new ObservableCollection<Monstre>();
}
}
private void CheckedVu(object sender, CheckedChangedEventArgs e)
{
UpdateListMobs();
}
private void CheckedPasVu(object sender, CheckedChangedEventArgs e)
{
UpdateListMobs();
}
private string imageLinkConverter(string imageLink)
{
imageLink = String.Concat(imageLink.Where(c => !Char.IsWhiteSpace(c)));
imageLink = "collection" + imageLink.ToLower() + ".png";
return imageLink;
}
}