parent
d854da1bdd
commit
ae2fa75b01
@ -1,67 +1,69 @@
|
||||
using Model;
|
||||
using Model;
|
||||
using Persistance;
|
||||
using System.Dynamic;
|
||||
|
||||
namespace Views;
|
||||
|
||||
public partial class New_DetailAnimal : ContentPage
|
||||
{
|
||||
private Animal AnimalSelectione => (App.Current as App).AnimalSelectionner;
|
||||
|
||||
public New_DetailAnimal()
|
||||
{
|
||||
InitializeComponent();
|
||||
(App.Current as App).PageDeSaisie = this;
|
||||
InitBinding();
|
||||
}
|
||||
|
||||
namespace Views;
|
||||
|
||||
public partial class New_DetailAnimal : ContentPage
|
||||
{
|
||||
private Animal AnimalSelectione => (App.Current as App).AnimalSelectionner;
|
||||
|
||||
public New_DetailAnimal()
|
||||
{
|
||||
InitializeComponent();
|
||||
(App.Current as App).PageDeSaisie = this;
|
||||
InitBinding();
|
||||
}
|
||||
|
||||
public void InitBinding()
|
||||
{
|
||||
BindingContext = AnimalSelectione;
|
||||
BindingContext = AnimalSelectione;
|
||||
Picker_especes.BindingContext = (App.Current as App).Theque;
|
||||
}
|
||||
|
||||
public async void Button_OnClick(object sender, EventArgs e)
|
||||
{
|
||||
(App.Current as App).Theque.SupprimerAnimal((App.Current as App).AnimalSelectionner);
|
||||
await Shell.Current.GoToAsync("//Animaux");
|
||||
}
|
||||
|
||||
public async void Validate_OnClick(object sender, EventArgs e)
|
||||
{
|
||||
}
|
||||
|
||||
public async void Button_OnClick(object sender, EventArgs e)
|
||||
{
|
||||
(App.Current as App).Theque.SupprimerAnimal((App.Current as App).AnimalSelectionner);
|
||||
await Shell.Current.GoToAsync("//Animaux");
|
||||
}
|
||||
|
||||
public async void Validate_OnClick(object sender, EventArgs e)
|
||||
{
|
||||
if ((App.Current as App).AnimalSelectionner.NomIsValid == true)
|
||||
{
|
||||
await Shell.Current.GoToAsync("//Animaux");
|
||||
}
|
||||
}
|
||||
|
||||
private void EspeceClic(object sender, EventArgs e)
|
||||
{
|
||||
(App.Current as App).AnimalSelectionner.Espece = (sender as Picker).SelectedItem as Espece;
|
||||
(App.Current as App).AnimalSelectionner.Race = null;
|
||||
}
|
||||
|
||||
private void RaceClic(object sender, EventArgs e)
|
||||
{
|
||||
(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)
|
||||
{
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
DataSerializer.Serializer((App.Current as App).SerializationPath);
|
||||
}
|
||||
}
|
||||
|
||||
private void EspeceClic(object sender, EventArgs e)
|
||||
{
|
||||
(App.Current as App).AnimalSelectionner.Espece = (sender as Picker).SelectedItem as Espece;
|
||||
(App.Current as App).AnimalSelectionner.Race = null;
|
||||
}
|
||||
|
||||
private void RaceClic(object sender, EventArgs e)
|
||||
{
|
||||
(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)
|
||||
{
|
||||
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…
Reference in new issue