Reglage problème route New_DetailAnimal

pull/18/head
Leana BESSON 2 years ago
parent 4c411d9b0c
commit d854da1bdd

@ -13,6 +13,7 @@ class Program
static private Theque Theque { get; set; } = Stub.LoadTheque();
static void Main(string[] args)
{
MenusPrincipal();
}

@ -5,12 +5,14 @@ using System.Runtime.Serialization.Json;
using System.Xml;
using static System.Console;
using Model;
using Microsoft.VisualBasic;
using System.Data;
namespace Persistance
{
public class DataContractSerializer
public class DataSerializer
{
public Theque DataContractSerializer()
public void Serializer()
{
Theque theque = new Theque();
@ -23,12 +25,23 @@ namespace Persistance
{
serializer.WriteObject(s, theque);
}
}
public Theque Deserializer()
{
string path = FileSystem.
Directory.SetCurrentDirectory();
string xmlFile = "theque.xml";
Theque theque2;
var serializer = new DataContractSerializer(typeof(Theque));
Theque theque = new Theque();
using (Stream s = File.OpenRead(xmlFile))
{
theque2 = serializer.ReadObject(s) as Theque;
theque = serializer.ReadObject(s) as Theque;
}
return theque;
}
}
}

@ -20,7 +20,9 @@ public partial class Animaux : ContentPage
public async void Button_OnClick(object sender, EventArgs e)
{
await Shell.Current.GoToAsync($"New_DetailAnimal");
(App.Current as App).AnimalSelectionner = (App.Current as App).Theque.AjouterAnimal();
(App.Current as App).PageDeSaisie?.InitBinding();
await Shell.Current.GoToAsync("//New_DetailAnimal");
}
}

@ -6,8 +6,19 @@ namespace Views
{
public partial class App : Application, INotifyPropertyChanged
{
string path = FileSystem.Current.AppDataDirectory;
public Theque Theque { get; set; } = Stub.LoadTheque();
public Animal AnimalSelectionner { get; set; }
public Animal AnimalSelectionner
{
get => animalSelectionner;
set
{
animalSelectionner = value;
OnPropertyChanged(nameof(AnimalSelectionner));
}
}
public New_DetailAnimal PageDeSaisie { get; set; }
private Animal animalSelectionner;
public Espece EspeceSelectionner { get; set; }
public Race RaceSelectionner { get; set; }

@ -20,4 +20,8 @@
Title="Vos animaux"
ContentTemplate="{DataTemplate local:Animaux}"
Route="Animaux"/>
<ShellContent
ContentTemplate="{DataTemplate local:New_DetailAnimal}"
Route="New_DetailAnimal"/>
</Shell>

@ -5,7 +5,7 @@
public AppShell()
{
InitializeComponent();
Routing.RegisterRoute("New_DetailAnimal", typeof(New_DetailAnimal));
//Routing.RegisterRoute("New_DetailAnimal", typeof(New_DetailAnimal));
}
}
}

@ -3,7 +3,7 @@
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
x:Class="Views.New_DetailAnimal"
Title="{Binding Nom}" x:Name="page_creation">
<ScrollView>
<ScrollView x:Name="scroll_view">
<VerticalStackLayout>
<HorizontalStackLayout
VerticalOptions="Start"

@ -1,16 +1,23 @@
using Model;
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).AnimalSelectionner = (App.Current as App).Theque.AjouterAnimal();
BindingContext = (App.Current as App).AnimalSelectionner;
(App.Current as App).PageDeSaisie = this;
InitBinding();
}
public void InitBinding()
{
BindingContext = AnimalSelectione;
Picker_especes.BindingContext = (App.Current as App).Theque;
OnBackButtonPressed();
}
public async void Button_OnClick(object sender, EventArgs e)
@ -20,9 +27,12 @@ public partial class New_DetailAnimal : ContentPage
}
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)
{

Loading…
Cancel
Save