Debut Binding + modif Vues

pull/32/head
Nicolas BLONDEAU 2 years ago
parent 9bde12ce33
commit d30ec5ede9

@ -424,5 +424,8 @@ Monstre monstre = new Monstre(1, "Dragon", "Dangereux", "Un redoutable dragon cr
Conseil conseil = new Conseil(auteur, "Soyez prudent lors de votre rencontre avec le dragon.", monstre);
// Affichage du conseil
conseil.affichConseil();
menuAccueil();
/*conseil.affichConseil();
menuAccueil();*/
Monstre uiui = new Monstre(1, "Poule", "passif", "Je suis un animal présent un peu partout, sauf dans le desert car il fait beaucoup trop chaud. Mais j'aime beaucoup la jungle !", new List<string> { "Quand une poule est tué il y a 3.12% de chance que la poule laisse tomber un oeuf " }, new List<string> { "Apparence1", "App2", "App3" }, new List<Conseil> { });
Console.WriteLine(uiui.ImageLink);

@ -8,13 +8,35 @@ namespace Model
{
[DataContract]
public class Monstre
public class Monstre : INotifyPropertyChanged
{
public event PropertyChangedEventHandler? PropertyChanged;
void OnPropertyChanged(string propertyName)
{
if (PropertyChanged != null)
{
PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
}
}
[DataMember(Order = 1)]
public int Id { get; set; } // ID
[DataMember(Order = 2)]
public string Name { get; set; } // Nom
public string Name
{
get => name;
set
{
if (name == value)
return;
name = value;
OnPropertyChanged("Name");
}
}
private string name; // Nom
[DataMember(Order = 3)]
public string Dangerosite { get; private init; } // Dangerosité
@ -22,8 +44,19 @@ namespace Model
//l'affichage de la liste des monstres une couleur selon ça,
//genre rouge dangereux, violet hyper dangereux, et vert passif
[DataMember(Order = 4)]
public string Description { get; set; } // Description
[DataMember(Order = 4)]
public string Description
{
get => description;
set
{
if (description == value)
return;
description = value;
OnPropertyChanged("Description");
}
}
private string description; // Description
[DataMember(Order = 5)]
public List<string> CharacteristicsList // Liste des caractéristiques
@ -36,7 +69,10 @@ namespace Model
{
get; init;
}
public List<Conseil> ListConseils { get; set; }
public string ImageLink { get; init ; }
public Monstre(int id, string name, string danger, string desc, List<string> characList, List<string> appearList, List<Conseil> conseilList)
{
Id = id;
@ -46,6 +82,8 @@ namespace Model
CharacteristicsList = characList;
AppearanceList = appearList;
ListConseils = conseilList;
ImageLink = name.ToLower() + ".png";
if (string.IsNullOrWhiteSpace(Name) || string.IsNullOrWhiteSpace(Description) || string.IsNullOrWhiteSpace(danger))
{
throw new ArgumentException("Un monstre doit avoir un nom, une description et une dangerosité!");

@ -1,11 +1,15 @@
namespace Vues
using Model;
using Persistance;
namespace Vues
{
public partial class App : Application
{
MonsterManager mnstrMngr = new MonsterManager(new LoaderXml());
public App()
{
InitializeComponent();
MainPage = new AppShell();
}
}

@ -3,158 +3,22 @@
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:toolkit="http://schemas.microsoft.com/dotnet/2022/maui/toolkit"
xmlns:shape="Microsoft.Maui.Controls.Shapes"
x:Class="Vues.SearchMob"
BackgroundImageSource="backcollection.jpg"
>
<toolkit:DockLayout>
x:Class="Vues.SearchMob">
<!--BackgroundImageSource="backcollection.jpg"-->
<Grid ColumnDefinitions="Auto,*">
<ListView x:Name="ListeMonstres" ItemsSource="{Binding lesMonstres}" Grid.Column="0">
<ListView.ItemTemplate>
<DataTemplate>
<StackLayout Orientation="Horizontal">
<ImageButton Source="{Binding ImageLink}" WidthRequest="303"/>
</StackLayout>
</DataTemplate>
</ListView.ItemTemplate>
</ListView>
<StackLayout BindingContext="{Binding SelectedItem, Source={x:Reference ListeMonstres}}">
</StackLayout>
</Grid>
<VerticalStackLayout
BackgroundColor="{StaticResource BleuFonce}"
toolkit:DockLayout.DockPosition="Left"
WidthRequest="300"
>
<HorizontalStackLayout>
<ImageButton
Source="exit.png"
WidthRequest="10"
HeightRequest="10"
BackgroundColor="{StaticResource BleuFonce}"
/>
<SearchBar Placeholder="Rechercher un monstre"
PlaceholderColor="DimGray"
CancelButtonColor="DimGray"
WidthRequest="300"/>
</HorizontalStackLayout>
<ScrollView VerticalScrollBarVisibility="Always" >
<VerticalStackLayout>
<!-- Mob Hostile Overworld -->
<ImageButton Source="zombie.png"
WidthRequest="303"/>
<ImageButton Source="squelette.png"
WidthRequest="303"/>
<ImageButton Source="creeper.png"
WidthRequest="303"/>
<ImageButton Source="araignee.png"
WidthRequest="303"/>
<ImageButton Source="phantom.png"
WidthRequest="303"/>
<ImageButton Source="enderman.png"
WidthRequest="303"/>
<ImageButton Source="slime.png"
WidthRequest="303"/>
<!-- Mob Passif -->
<ImageButton Source="cow.png"
WidthRequest="303"/>
<ImageButton Source="sheep.png"
WidthRequest="303"/>
<ImageButton Source="pig.png"
WidthRequest="303"/>
<ImageButton Source="poule.png"
WidthRequest="303"/>
<ImageButton Source="loup.png"
WidthRequest="303"/>
<ImageButton Source="chat.png"
WidthRequest="303"/>
<!-- Boss -->
<ImageButton Source="wither.png"
WidthRequest="303"/>
<ImageButton Source="dragon.png"
WidthRequest="303"/>
<ImageButton Source="warden.png"
WidthRequest="303"/>
</VerticalStackLayout>
</ScrollView>
</VerticalStackLayout>
<!-- -->
<toolkit:DockLayout
toolkit:DockLayout.DockPosition="Right"
WidthRequest="500"
>
<!-- Image du mob -->
<Image Source="zoombie.png"
HeightRequest="400"
Margin="-10, 50, 0, 0"
toolkit:DockLayout.DockPosition="Top"/>
<!-- Particularité -->
<Frame
Margin="40">
<Label
toolkit:DockLayout.DockPosition="Bottom"
Text="Particularité :"
FontSize="Medium">
</Label>
</Frame>
</toolkit:DockLayout>
<VerticalStackLayout
toolkit:DockLayout.DockPosition="Top">
<HorizontalStackLayout>
<Label Text="Déjà vu ?"
FontSize="20"
TextColor="White"
Margin="7"></Label>
<CheckBox
Color="{StaticResource BleuFonce}"></CheckBox>
</HorizontalStackLayout>
<Frame
Margin="40">
<Label
BackgroundColor="White"
toolkit:DockLayout.DockPosition="Bottom"
Text="Description :"
FontSize="Medium">
</Label>
</Frame>
<Frame
Margin="40">
<Label
BackgroundColor="White"
toolkit:DockLayout.DockPosition="Bottom"
Text="Caractéristiques :"
FontSize="Medium">
</Label>
</Frame>
<Frame
Margin="40">
<Label
BackgroundColor="White"
toolkit:DockLayout.DockPosition="Bottom"
Text="Conseil :"
FontSize="Medium">
</Label>
</Frame>
<Frame
Margin="40">
<Label
BackgroundColor="White"
toolkit:DockLayout.DockPosition="Bottom"
Text="Apparence :"
FontSize="Medium">
</Label>
</Frame>
</VerticalStackLayout>
</toolkit:DockLayout>
</ContentPage>

@ -1,3 +1,5 @@
using Model;
namespace Vues;
public partial class SearchMob : ContentPage
@ -5,10 +7,7 @@ public partial class SearchMob : ContentPage
public SearchMob()
{
InitializeComponent();
}
private void Label_SizeChanged(object sender, EventArgs e)
{
BindingContext = (App.Current as App).mnstrMngr;
}
}
Loading…
Cancel
Save