Binding début
continuous-integration/drone/push Build is failing Details

pull/18/head
Leana BESSON 2 years ago
parent 93aec4f370
commit 3cb6d50b7e

@ -6,7 +6,7 @@ using System.Runtime.InteropServices;
namespace MyProject;
class Program
{
public static Especetheque Especetheque { get; } = Stub.LaodEspecetheque();
public static Especetheque Especetheque { get; } = new Especetheque();
public static Zootheque Zootheque { get; set; } = new Zootheque();
static void Main(string[] args)

@ -12,6 +12,7 @@ namespace Model
{
public string Nom { get; }
public string NomScientifique { get; }
public string Image { get; }
public string EsperanceVie { get; }
public string PoidsMoyen { get; }
public string TailleMoyenne { get; }
@ -24,10 +25,11 @@ namespace Model
public string Conseil { get; }
public Espece(string nom = "", string nomScientifique = "", string esperanceVie = "", string poidsMoyen = "", string tailleMoyenne = "", HashSet<Race>? races = null, string comportement = "", string sante = "", string education = "", string entretien = "", string cout = "", string conseil = "")
public Espece(string nom = "", string nomScientifique = "", string image = "", string esperanceVie = "", string poidsMoyen = "", string tailleMoyenne = "", HashSet<Race>? races = null, string comportement = "", string sante = "", string education = "", string entretien = "", string cout = "", string conseil = "")
{
Nom = nom;
NomScientifique = nomScientifique;
Image = image;
EsperanceVie = esperanceVie;
PoidsMoyen = poidsMoyen;
TailleMoyenne = tailleMoyenne;

@ -1,5 +1,6 @@
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Globalization;
using System.Linq;
using System.Text;
@ -9,11 +10,25 @@ namespace Model
{
public class Especetheque
{
public HashSet<Espece> ListeEspeces = new HashSet<Espece>();
public ReadOnlyCollection<Espece> ListeEspeces { get; private set; }
private readonly List<Espece> listeEspeces = new List<Espece>();
public Especetheque(HashSet<Espece> listeEspece)
public Especetheque()
{
ListeEspeces = listeEspece;
ListeEspeces = new ReadOnlyCollection<Espece>(listeEspeces);
LoadEspecetheque();
}
private void LoadEspecetheque()
{
HashSet<Race> Races = new HashSet<Race>();
Races.Add(new("Abyssin"));
Races.Add(new("American curl"));
listeEspeces.Add(new("Chien", "Canis lupus familiaris", "chien.png"));
listeEspeces.Add(new("Chat", "Felis catus", "chat.png", "15 à 20 ans", "15 à 20 kg", "10 à 15 cm", Races));
listeEspeces.Add(new("Hamster", "Cricetinae"));
listeEspeces.Add(new("Lapin", "Oryctolagus cuniculus"));
}
public void AfficherListeEspece()

@ -8,20 +8,6 @@ namespace Model
{
public class Stub
{
public static Especetheque LaodEspecetheque()
{
HashSet<Race> Races = new HashSet<Race>();
Races.Add(new("Abyssin"));
Races.Add(new("American curl"));
HashSet<Espece> ListeEspeces = new HashSet<Espece>();
ListeEspeces.Add(new("Chien", "Canis lupus familiaris"));
ListeEspeces.Add(new("Chat", "Felis catus", "15 à 20 ans", "15 à 20 kg", "10 à 15 cm", Races));
ListeEspeces.Add(new("Hamster", "Cricetinae"));
ListeEspeces.Add(new("Lapin", "Oryctolagus cuniculus"));
return (new(ListeEspeces));
}
}
}

@ -6,8 +6,8 @@ using System.Threading.Tasks;
namespace Model
{
public class Zootheque
{
public class Zootheque {
public HashSet<Animal> ListeAnimaux = new HashSet<Animal>();
public Zootheque()

@ -4,7 +4,7 @@
xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:local="clr-namespace:Views"
Shell.FlyoutBehavior="Disabled">
Shell.FlyoutBehavior="Flyout">
<ShellContent
Title="Acceuil"
@ -15,5 +15,4 @@
Title="Les espèces"
ContentTemplate="{DataTemplate local:Especes}"
Route="Especes" />
</Shell>

@ -3,10 +3,41 @@
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
x:Class="Views.Especes"
Title="Especes">
<VerticalStackLayout>
<Label
Text="Les espèces"
VerticalOptions="Center"
HorizontalOptions="Center" />
</VerticalStackLayout>
<Grid RowDefinitions="Auto, *" RowSpacing="20" Padding="20">
<Label Text="Les espèces" FontSize="Large"/>
<CollectionView ItemsSource="{Binding ListeEspeces}" Grid.Row="1">
<CollectionView.ItemTemplate>
<DataTemplate>
<Grid Margin="0,0,0,4">
<Border Stroke="{StaticResource Secondary}"
StrokeThickness="2"
Margin="10"
Padding="10"
BackgroundColor="{StaticResource Primary}">
<Grid ColumnDefinitions="Auto, *"
RowDefinitions="2*, *, *"
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"
FontSize="Medium"
VerticalTextAlignment="Center"/>
<Label Text="{Binding NomScientifique}"
Grid.Column="1"
Grid.Row="1"
FontSize="15"/>
</Grid>
</Border>
</Grid>
</DataTemplate>
</CollectionView.ItemTemplate>
</CollectionView>
</Grid>
</ContentPage>

@ -1,9 +1,14 @@
using System.Diagnostics;
using Model;
namespace Views;
public partial class Especes : ContentPage
{
public Especes()
public Especetheque Especetheque { get; private set; } = new Especetheque();
public Especes()
{
InitializeComponent();
BindingContext = Especetheque;
}
}

@ -1,34 +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"
x:Class="Views.MainPage">
<ScrollView>
<VerticalStackLayout
Spacing="25"
Padding="30,0"
VerticalOptions="Center">
<Image
Source="dotnet_bot.png"
SemanticProperties.Description="Cute dot net bot waving hi to you!"
HeightRequest="200"
HorizontalOptions="Center" />
<Label
Text="Wikipet's"
SemanticProperties.HeadingLevel="Level1"
FontSize="32"
HorizontalOptions="Center" />
<Label
Text="Bienvenue dans le monde des animaux domestiques"
SemanticProperties.HeadingLevel="Level2"
SemanticProperties.Description="Welcome to dot net Multi platform App U I"
FontSize="18"
HorizontalOptions="Center" />
</VerticalStackLayout>
</ScrollView>
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
x:Class="Views.MainPage">
<Label Text="Bienvenue !"/>
</ContentPage>

@ -1,8 +1,10 @@
namespace Views
using Model;
namespace Views
{
public partial class MainPage : ContentPage
{
int count = 0;
public MainPage()
{

Binary file not shown.

After

Width:  |  Height:  |  Size: 580 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 212 KiB

@ -4,8 +4,8 @@
xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml">
<Color x:Key="Primary">#512BD4</Color>
<Color x:Key="Secondary">#DFD8F7</Color>
<Color x:Key="Primary">#ff9d5e</Color>
<Color x:Key="Secondary">#402e32</Color>
<Color x:Key="Tertiary">#2B0B98</Color>
<Color x:Key="White">White</Color>
<Color x:Key="Black">Black</Color>

@ -52,6 +52,10 @@
<PackageReference Include="Microsoft.Extensions.Logging.Debug" Version="7.0.0" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Model\Model.csproj" />
</ItemGroup>
<ItemGroup>
<Compile Update="Especes.xaml.cs">
<DependentUpon>Especes.xaml</DependentUpon>
@ -59,6 +63,9 @@
</ItemGroup>
<ItemGroup>
<MauiXaml Update="Espece.xaml">
<Generator>MSBuild:Compile</Generator>
</MauiXaml>
<MauiXaml Update="Especes.xaml">
<Generator>MSBuild:Compile</Generator>
</MauiXaml>

@ -7,7 +7,10 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Console", "Console\Console.
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Model", "Model\Model.csproj", "{83309215-075B-406F-A72E-45E40AD47E43}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Views", "Views\Views.csproj", "{6FB34AC9-C9A0-4223-96A0-C8D3D7C3242F}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Views", "Views\Views.csproj", "{6FB34AC9-C9A0-4223-96A0-C8D3D7C3242F}"
ProjectSection(ProjectDependencies) = postProject
{83309215-075B-406F-A72E-45E40AD47E43} = {83309215-075B-406F-A72E-45E40AD47E43}
EndProjectSection
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution

Loading…
Cancel
Save