diff --git a/GameAtlas/GameAtlas/App.xaml.cs b/GameAtlas/GameAtlas/App.xaml.cs index 06bd1b6..e3f999f 100644 --- a/GameAtlas/GameAtlas/App.xaml.cs +++ b/GameAtlas/GameAtlas/App.xaml.cs @@ -6,17 +6,33 @@ namespace GameAtlas; public partial class App : Application { - public Manager MyManager { get; private set; } = new Manager(new Stub.Stub());//new Manager(new DataContractPersistance.DataContractPers()); + + public string FileName { get; set; } = "data.xml"; + + public string FilePath { get; set; } = Path.Combine(AppDomain.CurrentDomain.BaseDirectory); + + public Manager MyManager { get; private set; } = new Manager(new Stub.Stub());//new Manager(new DataContractPersistance.DataContractPers()); public App() { - MyManager.ChargerDonnees(); - InitializeComponent(); + InitializeComponent(); + + if (File.Exists(Path.Combine(FilePath, FileName))) + { + MyManager = new Manager(new DataContractPersistance.DataContractPers()); + } - MyManager.Persistance = new DataContractPersistance.DataContractPers(); + MyManager.ChargerDonnees(); MainPage = new AppShell(); + + if (!File.Exists(Path.Combine(FilePath, FileName))) + { + MyManager.Persistance = new DataContractPersistance.DataContractPers(); + } + + MyManager.SauvegardeDonnees(); } } diff --git a/GameAtlas/GameAtlas/Stub/Stub.cs b/GameAtlas/GameAtlas/Stub/Stub.cs index 1e4a1b1..f8425f3 100644 --- a/GameAtlas/GameAtlas/Stub/Stub.cs +++ b/GameAtlas/GameAtlas/Stub/Stub.cs @@ -14,10 +14,12 @@ namespace GameAtlas.Stub List ListUsers = new List(); List ListJeu = new List(); Utilisateur user1 = new Utilisateur("test@gmail.com", "test", "Test1234"); - Jeu TheLastOfUs = new Jeu("The last of Us Part 1", 5, 487, "Ps5", "Aventure", "https://cdn1.epicgames.com/offer/b7b42e2078524ab386a8b2a9856ef557/EGS_SifuDeluxeEditionUpgradeBundle_Sloclap_Bundles_S1_2560x1440-43bae7aa2089289442238bd1e2b55655"); - Jeu ForzaHorizon = new Jeu("Forza Horizon 5", 4, 420, "Ps4", "Course", "https://cdn.cloudflare.steamstatic.com/steam/apps/1562430/capsule_616x353.jpg?t=1682587412"); + Jeu TheLastOfUs = new Jeu("The last of Us Part 1", 5, 487, "Ps5", "Aventure", "cover_lastofus1.png"); + Jeu ForzaHorizon = new Jeu("Forza Horizon 5", 4, 420, "Ps4", "Course", "cover_forzahorizon5.png"); + Jeu Test = new Jeu("The Legend of Zelda: Tears of the Kingdom", 5, 250, "Ps4", "Aventure", "cover_zelda.png"); ListJeu.Add(TheLastOfUs); ListJeu.Add(ForzaHorizon); + ListJeu.Add(Test); ListUsers.Add(user1); return (ListJeu,ListUsers); } diff --git a/GameAtlas/GameAtlas/Views/PageAccueil.xaml b/GameAtlas/GameAtlas/Views/PageAccueil.xaml index ff0ed50..deba581 100644 --- a/GameAtlas/GameAtlas/Views/PageAccueil.xaml +++ b/GameAtlas/GameAtlas/Views/PageAccueil.xaml @@ -3,7 +3,6 @@ xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" xmlns:toolkit="http://schemas.microsoft.com/dotnet/2022/maui/toolkit" xmlns:views="clr-namespace:GameAtlas.Views.Composants" - xmlns:model="clr-namespace:GameAtlas.Models" x:Class="GameAtlas.Views.PageAcceuil" Title="ACCUEIL"> @@ -160,7 +159,7 @@ - + @@ -190,11 +189,6 @@ - - - - - diff --git a/GameAtlas/GameAtlas/Views/PageJeu.xaml b/GameAtlas/GameAtlas/Views/PageJeu.xaml index c873982..e15b100 100644 --- a/GameAtlas/GameAtlas/Views/PageJeu.xaml +++ b/GameAtlas/GameAtlas/Views/PageJeu.xaml @@ -4,7 +4,7 @@ x:Class="GameAtlas.Views.PageJeu" Title="PageJeu"> - + @@ -29,13 +29,13 @@ - + -