You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
58 lines
1.5 KiB
58 lines
1.5 KiB
using Model.Classes;
|
|
using Model.Managers;
|
|
|
|
namespace Ohara;
|
|
|
|
public partial class ModalBestiaire : ContentPage
|
|
{
|
|
public Manager manager => (App.Current as App).manager;
|
|
public Bestiaire nouveauBest;
|
|
public string ancienNom;
|
|
public ModalBestiaire()
|
|
{
|
|
if (manager.SelectedItem != null)
|
|
{
|
|
nouveauBest = manager.SelectedItem as Bestiaire;
|
|
ancienNom = nouveauBest.Nom;
|
|
}
|
|
else
|
|
{
|
|
nouveauBest = new Bestiaire("Bestiaire", " ", " ", " ");
|
|
}
|
|
InitializeComponent();
|
|
BindingContext = nouveauBest;
|
|
}
|
|
|
|
private async void ButtonConfirmer_Clicked(object sender, EventArgs e)
|
|
{
|
|
if (manager.SelectedItem != null)
|
|
{
|
|
manager.ModifierBest(nouveauBest, ancienNom);
|
|
nouveauBest = manager.SelectedItem as Bestiaire;
|
|
}
|
|
else
|
|
{
|
|
manager.AjouterBest(nouveauBest);
|
|
}
|
|
|
|
await Navigation.PopModalAsync();
|
|
}
|
|
private async void ButtonAnnuler_Clicked(object sender, EventArgs e)
|
|
{
|
|
await Navigation.PopModalAsync();
|
|
}
|
|
private async void ButtonImage_Clicked(object sender, EventArgs e)
|
|
{
|
|
var result = await FilePicker.PickAsync(new PickOptions
|
|
{
|
|
PickerTitle = "Choisissez une image ...",
|
|
FileTypes = FilePickerFileType.Images,
|
|
});
|
|
if (result != null)
|
|
{
|
|
var stream = result.FullPath;
|
|
nouveauBest.Image = stream;
|
|
}
|
|
}
|
|
|
|
} |