From 5ea4e1ab41289fdac8fa46a2f7f2eab236cf0040 Mon Sep 17 00:00:00 2001 From: Matheo HERSAN Date: Fri, 12 May 2023 17:12:20 +0200 Subject: [PATCH] Modified DataContract --- MangaMap/App.xaml.cs | 6 +- MangaMap/AppShell.xaml | 8 +- MangaMap/MangaMap.csproj | 3 + MangaMap/Stub/DataContract.cs | 17 ++- MangaMap/Views/homePage.xaml.cs | 3 +- MangaMap/Views/homePageDisconnect.xaml | 123 ++++++++++++++++++++++ MangaMap/Views/homePageDisconnect.xaml.cs | 9 ++ MangaMap/Views/settingsPage.xaml | 2 +- MangaMap/Views/settingsPage.xaml.cs | 5 + 9 files changed, 166 insertions(+), 10 deletions(-) create mode 100644 MangaMap/Views/homePageDisconnect.xaml create mode 100644 MangaMap/Views/homePageDisconnect.xaml.cs diff --git a/MangaMap/App.xaml.cs b/MangaMap/App.xaml.cs index f852825..4743ffd 100644 --- a/MangaMap/App.xaml.cs +++ b/MangaMap/App.xaml.cs @@ -6,8 +6,8 @@ namespace MangaMap; public partial class App : Application { - //public Manager MyManager { get; private set; } = new Manager(new Stub.Stub()); //pour utiliser le stub comme moyen de persistance. - public Manager MyManager { get; private set; } = new Manager(new Stub.DataContract()); + public Manager MyManager { get; private set; } = new Manager(new Stub.Stub()); //pour utiliser le stub comme moyen de persistance. + //public Manager MyManager { get; private set; } = new Manager(new Stub.DataContract()); public Admin MyAdmin { get; private set; } = new Admin("test", "test@test.ts", "Pseudo_test"); @@ -18,7 +18,7 @@ public partial class App : Application MyManager.Admins.Add(MyAdmin); MainPage = new AppShell(); - //MyManager.Persistance = new DataContract(); + MyManager.Persistance = new DataContract(); MyManager.sauvegarder(); } diff --git a/MangaMap/AppShell.xaml b/MangaMap/AppShell.xaml index a967bf5..20d839e 100644 --- a/MangaMap/AppShell.xaml +++ b/MangaMap/AppShell.xaml @@ -7,9 +7,15 @@ xmlns:Views="clr-namespace:MangaMap.Views" Shell.FlyoutBehavior="Disabled" Shell.NavBarIsVisible="False" - Shell.TabBarIsVisible="False"> + Shell.TabBarIsVisible="True"> + + + MSBuild:Compile + + MSBuild:Compile + MSBuild:Compile diff --git a/MangaMap/Stub/DataContract.cs b/MangaMap/Stub/DataContract.cs index 9f49598..85ca7f6 100644 --- a/MangaMap/Stub/DataContract.cs +++ b/MangaMap/Stub/DataContract.cs @@ -22,10 +22,19 @@ namespace MangaMap.Stub var serializer = new DataContractSerializer(typeof(DataToPersist)); DataToPersist data; - using (Stream s = File.OpenRead(Path.Combine(FilePath, FileName))) - { - data = serializer.ReadObject(s) as DataToPersist; - } + if (File.Exists(Path.Combine(FilePath, FileName))) // Vérifiez si le fichier existe + { + + using (Stream s = File.OpenRead(Path.Combine(FilePath, FileName))) + { + data = serializer.ReadObject(s) as DataToPersist; + } + } + + else + { + data = new DataToPersist(); // Si le fichier n'existe pas, créez une nouvelle liste + } return (data.Oeuvres, data.Utilisateurs); } diff --git a/MangaMap/Views/homePage.xaml.cs b/MangaMap/Views/homePage.xaml.cs index c8a9da0..e454b1e 100644 --- a/MangaMap/Views/homePage.xaml.cs +++ b/MangaMap/Views/homePage.xaml.cs @@ -12,4 +12,5 @@ public partial class homePage : ContentPage a1.BindingContext = my_manager; a2.BindingContext = my_manager; } -} \ No newline at end of file +} + diff --git a/MangaMap/Views/homePageDisconnect.xaml b/MangaMap/Views/homePageDisconnect.xaml new file mode 100644 index 0000000..f528f92 --- /dev/null +++ b/MangaMap/Views/homePageDisconnect.xaml @@ -0,0 +1,123 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/MangaMap/Views/homePageDisconnect.xaml.cs b/MangaMap/Views/homePageDisconnect.xaml.cs new file mode 100644 index 0000000..28cf76e --- /dev/null +++ b/MangaMap/Views/homePageDisconnect.xaml.cs @@ -0,0 +1,9 @@ +namespace MangaMap.Views; + +public partial class homePageDisconnect : ContentPage +{ + public homePageDisconnect() + { + InitializeComponent(); + } +} \ No newline at end of file diff --git a/MangaMap/Views/settingsPage.xaml b/MangaMap/Views/settingsPage.xaml index dd77c2f..f0060ba 100644 --- a/MangaMap/Views/settingsPage.xaml +++ b/MangaMap/Views/settingsPage.xaml @@ -10,7 +10,7 @@ -