Compare commits
2 Commits
33200d002a
...
cb196b1e3d
Author | SHA1 | Date |
---|---|---|
|
cb196b1e3d | 2 years ago |
|
e80b34bc31 | 2 years ago |
@ -1,53 +1,71 @@
|
||||
using Model;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.ComponentModel;
|
||||
using System.Linq;
|
||||
|
||||
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();
|
||||
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();
|
||||
|
||||
InitializeComponent();
|
||||
User toto = (Application.Current as App).User;
|
||||
MonstresDejaVu = new ObservableCollection<Monstre>(toto.monstresDejaVu);
|
||||
var MnstrTemp = new ObservableCollection<Monstre> { };
|
||||
MnstrTemp = new ObservableCollection<Monstre>((Application.Current as App).monsterManager.ListMonsters.Except(MonstresDejaVu));
|
||||
ListViewMonsters.BindingContext = this;
|
||||
}
|
||||
|
||||
private void UpdateListMobs(ObservableCollection<Monstre> Monstres) // /!\ Qd on décoche Monstre déjà vu et re coche ils ne veulent pas réapparaître sauf si on clique aussi sur monstre pas vu
|
||||
{
|
||||
var monstresDejaVu = Monstres.Where(monstre => (Application.Current as App).User.monstresDejaVu.Contains(monstre)).ToList();
|
||||
var monstresPasVu = (Application.Current as App).monsterManager.ListMonsters.Except(monstresDejaVu).ToList();
|
||||
Monstres.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);
|
||||
foreach (var monstre in monstresDejaVu.Concat(monstresPasVu))
|
||||
{
|
||||
Monstres.Add(monstre);
|
||||
}
|
||||
}
|
||||
else if (CheckboxpasVu.IsChecked)
|
||||
// Si monstres déjà vu checked et monstres pas vu pas checked alors on l'ajoute à la collection et on supprime les monstres pas vu
|
||||
else if (CheckboxdejaVu.IsChecked && !CheckboxpasVu.IsChecked)
|
||||
{
|
||||
listMobs = new ObservableCollection<Monstre>(monstresPasVu);
|
||||
foreach (var monstre in monstresDejaVu)
|
||||
{
|
||||
Monstres.Add(monstre);
|
||||
}
|
||||
}
|
||||
else
|
||||
// Si monstres pas vu checked alors on l'ajoute à la collection
|
||||
else if (CheckboxpasVu.IsChecked && !CheckboxdejaVu.IsChecked)
|
||||
{
|
||||
listMobs = new ObservableCollection<Monstre>();
|
||||
foreach (var monstre in monstresPasVu)
|
||||
{
|
||||
if (!monstresDejaVu.Contains(monstre))
|
||||
{
|
||||
Monstres.Add(monstre);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void CheckedVu(object sender, CheckedChangedEventArgs e)
|
||||
{
|
||||
UpdateListMobs();
|
||||
UpdateListMobs(MonstresDejaVu);
|
||||
}
|
||||
|
||||
private void CheckedPasVu(object sender, CheckedChangedEventArgs e)
|
||||
{
|
||||
UpdateListMobs();
|
||||
UpdateListMobs(MonstresDejaVu);
|
||||
}
|
||||
|
||||
|
||||
private async void ImageButton_Clicked(object sender, EventArgs e)
|
||||
{
|
||||
await Navigation.PopAsync();
|
||||
}
|
||||
}
|
After Width: | Height: | Size: 39 KiB |
Loading…
Reference in new issue