Gestion du stub

pull/18/head
Leana BESSON 2 years ago
parent e42162ecd1
commit 5dae25eaa8

@ -6,9 +6,7 @@ using System.Runtime.InteropServices;
namespace MyProject;
class Program
{
public static Especetheque Especetheque { get; } = new Especetheque();
public static Zootheque Zootheque { get; set; } = new Zootheque();
static public Theque Theque { get; set; } = new ();
static void Main(string[] args)
{
MenusPrincipal();
@ -61,11 +59,11 @@ class Program
{
case 1:
Console.Clear();
Especetheque.AfficherListeEspece();
Theque.Especetheque.AfficherListeEspece();
break;
case 2:
Console.Clear();
Especetheque.SelectionnerEspece();
Theque.Especetheque.SelectionnerEspece();
break;
case 9:
Console.Clear();
@ -94,14 +92,14 @@ class Program
{
case 1:
Console.Clear();
Zootheque.AfficherListeAnimaux();
Theque.Zootheque.AfficherListeAnimaux();
break;
case 2:
Console.Clear();
Zootheque.AjouterAnimal(Especetheque);
Theque.Zootheque.AjouterAnimal(Theque.Especetheque);
break;
case 3:
Zootheque.SelectionnerAnimal(Especetheque);
Theque.Zootheque.SelectionnerAnimal(Theque.Especetheque);
break;
case 9:
Console.Clear();

@ -18,9 +18,8 @@ namespace Model
public Espece Espece { get; set; }
public Race? Race { get; set; }
public Animal(Espece espece, string nom, string dateNaissance = "", string sexe = "", string dateAdpotion = "", float? taille = null, float? poids = null, string alimentation = "", Race? race = null)
public Animal(string nom, string dateNaissance = "", string sexe = "", string dateAdpotion = "", float? taille = null, float? poids = null, string alimentation = "", Race? race = null)
{
Espece = espece;
Nom = nom;
DateNaissance = dateNaissance;
Sexe = sexe;

@ -10,16 +10,16 @@ namespace Model
{
public class Especetheque
{
public ReadOnlyCollection<Espece> ListeEspeces { get; private set; }
private readonly List<Espece> listeEspeces = new List<Espece>();
//public ReadOnlyCollection<Espece> ListeEspeces { get; private set; }
//private readonly List<Espece> listeEspeces = new List<Espece>();
public List<Espece> ListeEspeces { get; set; } = Stub.LoadEspecetheque();
public Especetheque()
{
ListeEspeces = new ReadOnlyCollection<Espece>(listeEspeces);
LoadEspecetheque();
//ListeEspeces = new ReadOnlyCollection<Espece>(listeEspeces);
}
private void LoadEspecetheque()
/*private void LoadEspecetheque()
{
HashSet<Race> Races = new HashSet<Race>();
Races.Add(new("Abyssin"));
@ -29,7 +29,7 @@ namespace Model
listeEspeces.Add(new("Chat", "Felis catus", "chat.jpg", "15 à 20 ans", "15 à 20 kg", "10 à 15 cm", Races, "Les chats ont un comportement très solitaire", "Les chats ont une bonne santé", "Les chats s'éduque assez facilement", "Il faut changé leur caisse mais il se nettoie seul, sauf les chatons", "Vétérinaire, alimentation adapté, jouet", "Un conseil"));
listeEspeces.Add(new("Hamster", "Cricetinae"));
listeEspeces.Add(new("Lapin", "Oryctolagus cuniculus"));
}
}*/
public void AfficherListeEspece()
{

@ -8,6 +8,29 @@ namespace Model
{
public class Stub
{
public static List<Espece> LoadEspecetheque()
{
List<Espece> ListeEspeces = new List<Espece>();
HashSet<Race> Races = new HashSet<Race>();
Races.Add(new("Abyssin"));
Races.Add(new("American curl"));
ListeEspeces.Add(new("Chien", "Canis lupus familiaris", "chien.jpg"));
ListeEspeces.Add(new("Chat", "Felis catus", "chat.jpg", "15 à 20 ans", "15 à 20 kg", "10 à 15 cm", Races, "Les chats ont un comportement très solitaire", "Les chats ont une bonne santé", "Les chats s'éduque assez facilement", "Il faut changé leur caisse mais il se nettoie seul, sauf les chatons", "Vétérinaire, alimentation adapté, jouet", "Un conseil"));
ListeEspeces.Add(new("Hamster", "Cricetinae"));
ListeEspeces.Add(new("Lapin", "Oryctolagus cuniculus"));
return ListeEspeces;
}
public static List<Animal> LoadZootheque()
{
List<Animal> listeAnimaux = new List<Animal>();
listeAnimaux.Add(new("Kiki"));
listeAnimaux.Add(new("PouetPouet"));
return listeAnimaux;
}
}
}

@ -0,0 +1,17 @@
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Model
{
public class Theque
{
public Especetheque Especetheque { get; } = new Especetheque();
public Zootheque Zootheque { get; set; } = new Zootheque();
public Theque() { }
}
}

@ -1,19 +1,24 @@
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using System.Runtime.InteropServices.Marshalling;
using System.Text;
using System.Threading.Tasks;
namespace Model
{
public class Zootheque {
public HashSet<Animal> ListeAnimaux = new HashSet<Animal>();
public class Zootheque {
//public ReadOnlyCollection<Animal> ListeAnimaux { get; private set; }
//private readonly List<Animal> listeAnimaux = new List<Animal>();
public List<Animal> ListeAnimaux { get; set; } = Stub.LoadZootheque();
public Zootheque()
{
//ListeAnimaux = new ReadOnlyCollection<Animal>(listeAnimaux);
//LoadZootheque();
}
public void AfficherListeAnimaux()
{
Console.WriteLine("VOS ANIMAUX : ");
@ -36,7 +41,7 @@ namespace Model
animal.ModifierTaille();
animal.ModifierPoids();
ListeAnimaux.Add(animal);
ListeAnimaux.Append(animal);
Console.Clear();
}
@ -74,7 +79,7 @@ namespace Model
public void SupprimerAnimal(Animal animal)
{
ListeAnimaux.Remove(animal);
//ListeAnimaux.Remove(animal);
}
}
}

@ -2,44 +2,50 @@
<ContentPage xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
x:Class="Views.Animaux"
Title="Animaux">
<Grid RowDefinitions="Auto, *"
RowSpacing="20"
Padding="20">
<Label Text="Les espèces"
FontSize="Large"/>
<ListView ItemsSource="{Binding ListeAnimal}"
Grid.Row="1">
<ListView.ItemTemplate>
<DataTemplate>
<ViewCell>
<Grid Margin="0,0,0,4">
<Border Stroke="{StaticResource Secondary}"
StrokeThickness="2"
Margin="10"
Padding="10"
BackgroundColor="{StaticResource Primary}">
<Grid ColumnDefinitions="Auto, *"
RowDefinitions="3*, *, *"
ColumnSpacing="15">
<Frame Grid.RowSpan="3"
WidthRequest="80"
HeightRequest="80"
Padding="0"
Margin="10"
BorderColor="{StaticResource Primary}" >
<Image Source="{Binding Image}"/>
</Frame>
<Label Text="{Binding Nom}"
Grid.Column="1"
Grid.Row="0"
FontSize="Medium"/>
</Grid>
</Border>
</Grid>
</ViewCell>
</DataTemplate>
</ListView.ItemTemplate>
</ListView>
</Grid>
Title="Vos animaux">
<VerticalStackLayout>
<Grid RowDefinitions="Auto, *"
RowSpacing="20"
Padding="20">
<ListView ItemsSource="{Binding ListeAnimaux}"
Grid.Row="1">
<ListView.ItemTemplate>
<DataTemplate>
<ViewCell>
<Grid Margin="0,0,0,4">
<Border Stroke="{StaticResource Secondary}"
StrokeThickness="2"
Margin="10"
Padding="10"
BackgroundColor="{StaticResource Primary}">
<Grid ColumnDefinitions="Auto, *"
RowDefinitions="3*, *, *"
ColumnSpacing="15">
<Frame Grid.RowSpan="3"
WidthRequest="80"
HeightRequest="80"
Padding="0"
Margin="10"
BorderColor="{StaticResource Primary}" >
<Image Source="{Binding Image}"/>
</Frame>
<Label Text="{Binding Nom}"
Grid.Column="1"
Grid.Row="0"
FontSize="Medium"/>
</Grid>
</Border>
</Grid>
</ViewCell>
</DataTemplate>
</ListView.ItemTemplate>
</ListView>
</Grid>
<Button Text="+"
FontSize="Large"
Background="{StaticResource Primary}"
VerticalOptions="End"
HorizontalOptions="End"
Margin="20"/>
</VerticalStackLayout>
</ContentPage>

@ -4,10 +4,10 @@ namespace Views;
public partial class Animaux : ContentPage
{
public Zootheque Zootheque { get; set; } = new Zootheque();
public Animaux()
{
InitializeComponent();
BindingContext = Zootheque;
BindingContext = (App.Current as App).Theque.Zootheque;
}
}

@ -6,15 +6,17 @@ namespace Views
{
public partial class App : Application, INotifyPropertyChanged
{
public Especetheque Especetheque { get; private set; } = new Especetheque();
public Theque Theque { get; set; } = new Theque();
public Animal AnimalSelectionner;
public Espece EspeceSelectionner;
public Race RaceSelectionner;
public App()
{
InitializeComponent();
MainPage = new AppShell();
BindingContext = Especetheque;
}
}
}

@ -6,48 +6,45 @@
<ScrollView>
<VerticalStackLayout>
<Image Source="{Binding Image}"
MaximumWidthRequest="300"
Margin="20"
HorizontalOptions="Center"/>
MaximumWidthRequest="300"
Margin="20"
HorizontalOptions="Center"/>
<Border Stroke="{StaticResource Secondary}"
StrokeThickness="2"
Margin="20"
Padding="10"
Background="{StaticResource Primary}"
StrokeThickness="2"
Margin="20"
Padding="10"
Background="{StaticResource Primary}"
VerticalOptions="Start"
Grid.Column="1">
<Grid RowDefinitions="Auto, *, *, *, *"
ColumnDefinitions="*, *"
RowSpacing="10">
<Grid RowDefinitions="Auto, Auto, Auto, Auto, Auto"
ColumnDefinitions="*, *"
RowSpacing="8">
<Label FontAttributes="Bold"
Text="Nom Scientifique"/>
Text="Nom scientifique"/>
<Label Grid.Column="1"
HorizontalOptions="End"
Text="{Binding NomScientifique}"/>
Text="{Binding NomScientifique}"/>
<Label Grid.Row="1"
FontAttributes="Bold"
Text="Espérance de vie"/>
FontAttributes="Bold"
Text="Espérance de vie"/>
<Label Grid.Column="2"
Grid.Row="1"
Grid.Row="1"
HorizontalOptions="End"
Text="{Binding EsperanceVie}"/>
Text="{Binding EsperanceVie}"/>
<Label Grid.Row="2"
FontAttributes="Bold"
Text="Poids moyen"/>
FontAttributes="Bold"
Text="Poids moyen"/>
<Label Grid.Column="2"
Grid.Row="2"
Grid.Row="2"
HorizontalOptions="End"
Text="{Binding PoidsMoyen}"/>
Text="{Binding PoidsMoyen}"/>
<Label Grid.Row="3"
FontAttributes="Bold"
Text="Taille moyenne"/>
FontAttributes="Bold"
Text="Taille moyenne"/>
<Label Grid.Column="2"
Grid.Row="3"
Grid.Row="3"
HorizontalOptions="End"
Text="{Binding TailleMoyenne}"/>
Text="{Binding TailleMoyenne}"/>
</Grid>
</Border>
@ -55,92 +52,106 @@
Margin="20">
<Label Text="Comportement"
FontSize="Large"/>
<Label Text="{Binding Comportement}"
Padding="10"
Background="{StaticResource Primary}"/>
<Border Stroke="{StaticResource Secondary}"
StrokeThickness="2"
Padding="10"
Background="{StaticResource Primary}">
<Label Text="{Binding Comportement}"/>
</Border>
</VerticalStackLayout>
<VerticalStackLayout
Margin="20">
<Label Text="Santé"
FontSize="Large"/>
<Label Text="{Binding Sante}"
Padding="10"
Background="{StaticResource Primary}"/>
<Border Stroke="{StaticResource Secondary}"
StrokeThickness="2"
Padding="10"
Background="{StaticResource Primary}">
<Label Text="{Binding Sante}"/>
</Border>
</VerticalStackLayout>
<VerticalStackLayout
Margin="20">
<Label Text="Education"
FontSize="Large"/>
<Label Text="{Binding Education}"
Padding="10"
Background="{StaticResource Primary}"/>
<Border Stroke="{StaticResource Secondary}"
StrokeThickness="2"
Padding="10"
Background="{StaticResource Primary}">
<Label Text="{Binding Education}"/>
</Border>
</VerticalStackLayout>
<VerticalStackLayout
Margin="20">
<Label Text="Entretien"
FontSize="Large"/>
<Label Text="{Binding Entretien}"
Padding="10"
Background="{StaticResource Primary}"/>
<Border Stroke="{StaticResource Secondary}"
StrokeThickness="2"
Padding="10"
Background="{StaticResource Primary}">
<Label Text="{Binding Entretien}"/>
</Border>
</VerticalStackLayout>
<VerticalStackLayout
Margin="20">
<VerticalStackLayout Margin="20">
<Label Text="Coût potentiel"
FontSize="Large"/>
<Label Text="{Binding Cout}"
Padding="10"
Background="{StaticResource Primary}"/>
<Border Stroke="{StaticResource Secondary}"
StrokeThickness="2"
Padding="10"
Background="{StaticResource Primary}">
<Label Text="{Binding Cout}"/>
</Border>
</VerticalStackLayout>
<VerticalStackLayout
Margin="20">
<VerticalStackLayout Margin="20">
<Label Text="Conseils"
FontSize="Large"/>
<Label Text="{Binding Conseil}"
Padding="10"
Background="{StaticResource Primary}"/>
FontSize="Large"/>
<Border Stroke="{StaticResource Secondary}"
StrokeThickness="2"
Padding="10"
Background="{StaticResource Primary}">
<Label Text="{Binding Conseil}"/>
</Border>
</VerticalStackLayout>
<Grid RowDefinitions="Auto, *"
RowSpacing="20"
Padding="20">
<Label Text="Les races"
FontSize="Large"/>
RowSpacing="20"
Padding="20">
<Label Text="Les races"
FontSize="Large"/>
<ListView ItemsSource="{Binding ListeRaces}"
Grid.Row="1"
Grid.Row="1"
ItemSelected="OnClick">
<ListView.ItemTemplate>
<DataTemplate>
<ViewCell>
<Grid Margin="0,0,0,4">
<Border Stroke="{StaticResource Secondary}"
StrokeThickness="2"
Margin="10"
Padding="10"
BackgroundColor="{StaticResource Primary}">
StrokeThickness="2"
Margin="10"
Padding="10"
BackgroundColor="{StaticResource Primary}">
<Grid ColumnDefinitions="Auto, *"
RowDefinitions="3*, *, *"
ColumnSpacing="15">
RowDefinitions="3*"
ColumnSpacing="15">
<Frame Grid.RowSpan="3"
WidthRequest="80"
HeightRequest="80"
Padding="0"
Margin="10"
BorderColor="{StaticResource Primary}" >
HeightRequest="60"
WidthRequest="60"
Padding="0"
Margin="10"
BorderColor="{StaticResource Primary}">
<Image Source="{Binding Image}"/>
</Frame>
<Label Text="{Binding Nom}"
Grid.Column="1"
Grid.Row="0"
FontSize="Medium"/>
<Label Text="{Binding NomScientifique}"
Grid.Column="1"
Grid.Row="1"
FontSize="15"/>
<VerticalStackLayout Grid.Column="1">
<Label Text="{Binding Nom}"
FontSize="Large"/>
<Label Text="{Binding NomScientifique}"
FontSize="12"/>
</VerticalStackLayout>
</Grid>
</Border>
</Grid>

@ -14,29 +14,27 @@
<ViewCell>
<Grid Margin="0,0,0,4">
<Border Stroke="{StaticResource Secondary}"
StrokeThickness="2"
Margin="10"
Padding="10"
BackgroundColor="{StaticResource Primary}">
StrokeThickness="2"
Margin="10"
Padding="10"
BackgroundColor="{StaticResource Primary}">
<Grid ColumnDefinitions="Auto, *"
RowDefinitions="3*, *, *"
ColumnSpacing="15">
RowDefinitions="3*"
ColumnSpacing="15">
<Frame Grid.RowSpan="3"
WidthRequest="80"
HeightRequest="80"
Padding="0"
Margin="10"
BorderColor="{StaticResource Primary}" >
HeightRequest="60"
WidthRequest="60"
Padding="0"
Margin="10"
BorderColor="{StaticResource Primary}">
<Image Source="{Binding Image}"/>
</Frame>
<Label Text="{Binding Nom}"
Grid.Column="1"
Grid.Row="0"
FontSize="Medium"/>
<Label Text="{Binding NomScientifique}"
Grid.Column="1"
Grid.Row="1"
FontSize="15"/>
<VerticalStackLayout Grid.Column="1">
<Label Text="{Binding Nom}"
FontSize="Large"/>
<Label Text="{Binding NomScientifique}"
FontSize="12"/>
</VerticalStackLayout>
</Grid>
</Border>
</Grid>

@ -9,12 +9,12 @@ public partial class Especes : ContentPage
public Especes()
{
InitializeComponent();
BindingContext = (App.Current as App).Especetheque;
BindingContext = (App.Current as App).Theque.Especetheque;
}
public async void OnClick(object sender, SelectedItemChangedEventArgs e)
public void OnClick(object sender, SelectedItemChangedEventArgs e)
{
(App.Current as App).EspeceSelectionner = e.SelectedItem as Espece;
await Navigation.PushAsync(new DetailEspece());
(App.Current as App).EspeceSelectionner = e.SelectedItem as Espece;
Navigation.PushAsync(new DetailEspece());
}
}

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8" ?>
<ContentPage xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:local="clr-namespace:Views"
x:Class="Views.MainPage">
<Label Text="Bienvenue !"/>
</ContentPage>

Loading…
Cancel
Save