Ajout page collention et fonctionnalités

Collection
parent 2d081b6730
commit 67a9ee529f

@ -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<string> characList, List<string> appearList, ObservableCollection<Conseil> conseilList)
{
if (string.IsNullOrWhiteSpace(name) || string.IsNullOrWhiteSpace(desc) || string.IsNullOrWhiteSpace(danger))

@ -4,51 +4,29 @@
x:Class="Vues.Collection"
BackgroundImageSource="backcollection.jpg"
>
<VerticalStackLayout
>
<VerticalStackLayout>
<HorizontalStackLayout BackgroundColor="{StaticResource buttonBackgroundColor}">
<Label Text=" Monstre déjà vu"></Label>
<CheckBox
Color="{StaticResource BleuFonce}"></CheckBox>
<CheckBox x:Name="CheckboxdejaVu"
Color="{StaticResource BleuFonce}"
IsChecked="True"
CheckedChanged="CheckedVu"></CheckBox>
<Label Text=" Monstre jamais vu"></Label>
<CheckBox Color="{StaticResource BleuFonce}"></CheckBox>
<CheckBox x:Name="CheckboxpasVu"
Color="{StaticResource BleuFonce}"
CheckedChanged="CheckedPasVu"></CheckBox>
</HorizontalStackLayout>
<Line X1="0" Y1="0" X2="1500" Y2="0" Stroke="Black" StrokeThickness="2"/>
<FlexLayout
Wrap="Wrap">
<Image Source="cartedragon.png"
HeightRequest="300"
Margin="5, 5, 0, 0"></Image>
<Image Source="cartedragon.png"
HeightRequest="300"
Margin="5, 5, 0, 0"></Image>
<Image Source="cartedragon.png"
HeightRequest="300"
Margin="5, 5, 0, 0"></Image>
<Image Source="cartedragon.png"
HeightRequest="300"
Margin="5, 5, 0, 0"></Image>
<Image Source="cartedragon.png"
HeightRequest="300"
Margin="5, 5, 0, 0"></Image>
<Image Source="cartedragon.png"
HeightRequest="300"
Margin="5, 5, 0, 0"></Image>
<Image Source="cartedragon.png"
HeightRequest="300"
Margin="5, 5, 0, 0"></Image>
<Image Source="cartedragon.png"
HeightRequest="300"
Margin="5, 5, 0, 0"></Image>
<Image Source="cartedragon.png"
HeightRequest="300"
Margin="5, 5, 0, 0"></Image>
<FlexLayout>
<ListView ItemsSource="{Binding listMobs}" BackgroundColor="White">
<ListView.ItemTemplate>
<DataTemplate>
<TextCell Text="{Binding Nom}" />
</DataTemplate>
</ListView.ItemTemplate>
</ListView>
</FlexLayout>
</VerticalStackLayout>
</ContentPage>

@ -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<Monstre> 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<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();
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 10 KiB

@ -63,7 +63,8 @@
BackgroundColor="{StaticResource buttonBackgroundColor}">
<VerticalStackLayout>
<HorizontalStackLayout Grid.Row="0">
<ImageButton Source="exit.png" WidthRequest="20" BackgroundColor="{StaticResource buttonBackgroundColor}"/>
<ImageButton Source="exit.png" WidthRequest="20" BackgroundColor="{StaticResource buttonBackgroundColor}" Clicked="QuitClicked"/>
<ImageButton Source="book.png" WidthRequest="20" BackgroundColor="{StaticResource buttonBackgroundColor}" Clicked="CollectionClicked"/>
<SearchBar x:Name="searchBar" Placeholder="Rechercher un monstre"
PlaceholderColor="DimGray"
CancelButtonColor="DimGray"
@ -135,10 +136,10 @@
<!-- Grid du Detail contenant toutes les informations du monstre -->
<Grid RowDefinitions="Auto,Auto,Auto,Auto" BindingContext="{Binding SelectedItem, Source={x:Reference ListViewMonsters}}">
<Grid ColumnDefinitions="3*, *" Grid.Row="0">
<!-- Checkbox "Déjà Vu-->
<HorizontalStackLayout Grid.Column="0" VerticalOptions="Start">
<Label Text="Déjà vu ?" FontSize="20" TextColor="White" Margin="7"/>
<CheckBox Color="Green"/>
<CheckBox Color="Green" CheckedChanged="CheckBox_CheckedChanged" x:Name="CheckDejaVu"/>
</HorizontalStackLayout>
<VerticalStackLayout VerticalOptions="Center" Grid.Column="0">

@ -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
}
}
Loading…
Cancel
Save