Ajout de Take Photo dans Detail Animal + Révision entite

pull/18/head
Leana BESSON 2 years ago
parent 995c97d59e
commit 498b81e5fb

@ -279,7 +279,7 @@ class Program
AfficherEntite(animal.Petsitter);
Console.WriteLine("\tCHENIL : ");
AfficherEntite(animal.Chenil);
Console.WriteLine("\VETERINAIRE : ");
Console.WriteLine("\tVETERINAIRE : ");
AfficherEntite(animal.Veterinaire);
Console.WriteLine("\tMAGASIN ALIMENTAIRE : ");
AfficherEntite(animal.MagasinAlimentaire);

@ -3,14 +3,19 @@ using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Runtime.CompilerServices;
using System.Runtime.Serialization;
using System.Text;
using System.Threading.Tasks;
using System.Xml.Linq;
namespace Model
{
[DataContract(Name = "animal")]
public class Animal : INotifyPropertyChanged
{
public event PropertyChangedEventHandler? PropertyChanged;
[DataMember(Name = "nom")]
public string Nom
{
get => nom;
@ -24,6 +29,8 @@ namespace Model
}
private string nom;
[DataMember(Name = "naissance")]
public string DateNaissance
{
get => dateNaissance;
@ -37,6 +44,7 @@ namespace Model
}
private string dateNaissance;
[DataMember(Name = "sexe")]
public string Sexe
{
get => sexe;
@ -49,6 +57,7 @@ namespace Model
}
private string sexe;
[DataMember(Name = "adoption")]
public string DateAdoption
{
get => dateAdoption;
@ -62,6 +71,7 @@ namespace Model
}
private string dateAdoption;
[DataMember(Name = "taille")]
public float? Taille
{
get => taille;
@ -75,6 +85,7 @@ namespace Model
}
private float? taille;
[DataMember(Name = "poids")]
public float? Poids
{
get => poids;
@ -88,6 +99,7 @@ namespace Model
}
private float? poids;
[DataMember(Name = "alimentation")]
public string Alimentation
{
get => alimentation;
@ -101,6 +113,7 @@ namespace Model
}
private string alimentation;
[DataMember(Name = "espèce")]
public Espece? Espece
{
get => espece;
@ -114,6 +127,7 @@ namespace Model
}
private Espece? espece;
[DataMember(Name = "race")]
public Race? Race
{
get => race;
@ -127,6 +141,7 @@ namespace Model
}
private Race? race;
[DataMember(Name = "veterinaire")]
public Veterinaire? Veterinaire
{
get => veterinaire;
@ -140,6 +155,7 @@ namespace Model
}
private Veterinaire? veterinaire = new Veterinaire();
[DataMember(Name = "chenil")]
public Chenil? Chenil
{
get => chenil;
@ -153,6 +169,7 @@ namespace Model
}
private Chenil? chenil = new Chenil();
[DataMember(Name = "magasinAlimentaire")]
public MagasinAlimentaire? MagasinAlimentaire
{
get => magasinAlimentaire;
@ -166,6 +183,7 @@ namespace Model
}
private MagasinAlimentaire? magasinAlimentaire = new MagasinAlimentaire();
[DataMember(Name = "provenance")]
public Provenance? Provenance
{
get => provenance;
@ -179,6 +197,7 @@ namespace Model
}
private Provenance? provenance = new Provenance();
[DataMember(Name = "petsitter")]
public Petsitter? Petsitter
{
get => petsitter;
@ -192,6 +211,20 @@ namespace Model
}
private Petsitter? petsitter = new Petsitter();
[DataMember(Name = "image")]
public string Image
{
get => image;
set
{
if (image == value)
return;
image = value;
OnPropertyChanged(nameof(Image));
}
}
private string image;
public Animal(string nom = "", string dateNaissance = "Inconnue", string sexe = "Inconnu", string dateAdpotion = "Inconnue", float? taille = null, float? poids = null, string alimentation = "Inconnue", Race? race = null)
{
Nom = nom;

@ -8,11 +8,5 @@ namespace Model
{
public class Chenil : Entite
{
public Entite Entite { get; set; }
public Chenil()
{
Entite = new Entite();
}
}
}

@ -87,7 +87,7 @@ namespace Model
NumTel = numTel;
}
void OnPropertyChanged(string propertyName)
public void OnPropertyChanged(string propertyName)
{
if (PropertyChanged != null)
{

@ -8,11 +8,5 @@ namespace Model
{
public class MagasinAlimentaire : Entite
{
public Entite Entite { get; set; }
public MagasinAlimentaire()
{
Entite = new Entite();
}
}
}

@ -9,11 +9,5 @@ namespace Model
{
public class Petsitter : Entite
{
public Entite Entite { get; set; }
public Petsitter()
{
Entite = new Entite();
}
}
}

@ -8,11 +8,5 @@ namespace Model
{
public class Provenance : Entite
{
public Entite Entite { get; set; }
public Provenance()
{
Entite = new Entite();
}
}
}

@ -1,8 +1,10 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.Serialization;
using System.Text;
using System.Threading.Tasks;
using System.Xml.Linq;
namespace Model
{
@ -20,6 +22,8 @@ namespace Model
public string Cout { get; }
public string Conseil { get; }
public string Image { get; }
public Race(string nom = "Inconnu", string nomScientifique = "Inconnu", string esperanceVie = "Inconnue", string poidsMoyen = "Inconnu", string tailleMoyenne = "Inconnu", string comportement = "Auncune information", string sante = "Aucune information", string education = "Auncune information", string entretien = "Aucune information", string cout = "Auncune information", string conseil = "Aucun conseil")
{
Nom = nom;

@ -9,7 +9,6 @@ namespace Model
{
public class Veterinaire : Entite
{
public Entite Entite { get; set; }
public string Clinique
{
get => clinique;
@ -18,14 +17,9 @@ namespace Model
if(clinique == value)
return;
clinique = value;
Entite.OnPropertyChanged(nameof(Clinique));
OnPropertyChanged(nameof(Clinique));
}
}
private string clinique;
public Veterinaire()
{
Entite = new Entite();
}
}
}

@ -15,6 +15,12 @@
MaximumWidthRequest="300"
Margin="20"
HorizontalOptions="Center"/>
<Button Text="Ajouter photo"
Background="{StaticResource Primary}"
VerticalOptions="Center"
HorizontalOptions="Center"
Margin="20"
Clicked="TakePhoto"/>
<Entry Text="{Binding Nom}"
HorizontalOptions="Center"/>
<Border Stroke="{StaticResource Secondary}"
@ -211,7 +217,7 @@
StrokeThickness="2"
Padding="10"
Background="{StaticResource Primary}">
<Grid RowDefinitions="Auto, Auto, Auto, Auto, Auto"
<Grid RowDefinitions="Auto, Auto, Auto, Auto, Auto, Auto"
ColumnDefinitions="*, *">
<Label FontAttributes="Bold"
Text="Nom"/>
@ -220,31 +226,38 @@
Text="{Binding Veterinaire.Entite.Nom}"/>
<Label Grid.Row="1"
FontAttributes="Bold"
Text="Adresse"/>
Text="Clinique"/>
<Entry Grid.Column="1"
Grid.Row="1"
HorizontalOptions="End"
Text="{Binding Veterinaire.Entite.Adresse}"/>
Text="{Binding Veterinaire.Clinique}"/>
<Label Grid.Row="2"
FontAttributes="Bold"
Text="Code postal"/>
Text="Adresse"/>
<Entry Grid.Column="1"
Grid.Row="2"
HorizontalOptions="End"
Text="{Binding Veterinaire.Entite.CodePostal}"/>
Text="{Binding Veterinaire.Entite.Adresse}"/>
<Label Grid.Row="3"
FontAttributes="Bold"
Text="Ville"/>
Text="Code postal"/>
<Entry Grid.Column="1"
Grid.Row="3"
HorizontalOptions="End"
Text="{Binding Veterinaire.Entite.Ville}"/>
Text="{Binding Veterinaire.Entite.CodePostal}"/>
<Label Grid.Row="4"
FontAttributes="Bold"
Text="Numéro de téléphone"/>
Text="Ville"/>
<Entry Grid.Column="1"
Grid.Row="4"
HorizontalOptions="End"
Text="{Binding Veterinaire.Entite.Ville}"/>
<Label Grid.Row="5"
FontAttributes="Bold"
Text="Numéro de téléphone"/>
<Entry Grid.Column="1"
Grid.Row="5"
HorizontalOptions="End"
Text="{Binding Veterinaire.Entite.NumTel}"/>
</Grid>
</Border>

@ -27,4 +27,25 @@ public partial class DetailAnimal : ContentPage
{
(App.Current as App).AnimalSelectionner.Race = (sender as Picker).SelectedItem as Race;
}
public async void TakePhoto(object sender, EventArgs e)
{
if (MediaPicker.Default.IsCaptureSupported)
{
FileResult photo = await MediaPicker.Default.PickPhotoAsync();
if (photo != null)
{
// save the file into local storage
string localFilePath = Path.Combine(FileSystem.AppDataDirectory, photo.FileName);
using Stream sourceStream = await photo.OpenReadAsync();
using FileStream localFileStream = File.OpenWrite(localFilePath);
await sourceStream.CopyToAsync(localFileStream);
(App.Current as App).AnimalSelectionner.Image = Path.Combine(FileSystem.AppDataDirectory, photo.FileName);
}
}
}
}
Loading…
Cancel
Save