From ceee48974d100d273438fa30e6cd9c4eea0f0c60 Mon Sep 17 00:00:00 2001 From: Jade_VAN_BRABANDT Date: Tue, 30 May 2023 15:27:59 +0200 Subject: [PATCH] =?UTF-8?q?fix=20:=20j'avais=20peut=20=C3=AAtre=20cass?= =?UTF-8?q?=C3=A9=20le=20programme?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Sources/Persistance/Persistance.cs | 2 +- Sources/Stim.Model/Manager.cs | 10 +++++----- Sources/Stim/AddGamePage.xaml.cs | 4 +++- Sources/Stim/App.xaml.cs | 2 +- Sources/Stim/DetailledPage.xaml.cs | 1 - 5 files changed, 10 insertions(+), 9 deletions(-) diff --git a/Sources/Persistance/Persistance.cs b/Sources/Persistance/Persistance.cs index c5a2544..908a824 100644 --- a/Sources/Persistance/Persistance.cs +++ b/Sources/Persistance/Persistance.cs @@ -29,7 +29,7 @@ namespace StimPersistance throw new NotImplementedException(); } - public ObservableCollection? LoadGame() + public ObservableCollection LoadGame() { if (File.Exists("games.xml")) { diff --git a/Sources/Stim.Model/Manager.cs b/Sources/Stim.Model/Manager.cs index 8b9e91f..8a4d277 100644 --- a/Sources/Stim.Model/Manager.cs +++ b/Sources/Stim.Model/Manager.cs @@ -4,12 +4,12 @@ namespace Model { public class Manager { - public IPersistance persistance; + public IPersistance Mgrpersistance; public ObservableCollection GameList { get;} public Manager(IPersistance persistance) { - persistance = persistance; + Mgrpersistance = persistance; GameList = persistance.LoadGame(); if (GameList == null) { GameList = new ObservableCollection();} } @@ -17,13 +17,13 @@ namespace Model public void AddGametoGamesList(Game game) { GameList.Add(game); - persistance.SaveGame(GameList); + Mgrpersistance.SaveGame(GameList); } public void RemoveGameFromGamesList(Game game) { GameList.Remove(game); - persistance.SaveGame(GameList); + Mgrpersistance.SaveGame(GameList); } /*public void LoadGames() @@ -32,7 +32,7 @@ namespace Model }*/ public void SaveGames() { - persistance.SaveGame(GameList); + Mgrpersistance.SaveGame(GameList); } } } diff --git a/Sources/Stim/AddGamePage.xaml.cs b/Sources/Stim/AddGamePage.xaml.cs index 1b5e165..2c675ae 100644 --- a/Sources/Stim/AddGamePage.xaml.cs +++ b/Sources/Stim/AddGamePage.xaml.cs @@ -23,11 +23,13 @@ public partial class AddGamePage : ContentPage //System.IO.File.Copy(_ImgPath, /**/, true); ((App)App.Current).Manager.AddGametoGamesList(new Game(NameEntry.Text, DescriptionEntry.Text, year, new List { TagEntry1.Text, TagEntry2.Text, TagEntry3.Text }, imgName, LinkEntry.Text)); Navigation.RemovePage(this); - } + ((App)App.Current).Manager.SaveGames(); + } private async void Button_Clicked(object sender, EventArgs e) { var ImgTask = await FilePicker.Default.PickAsync(null); + if (ImgTask == null) return; _ImgPath = ImgTask.FullPath; } } \ No newline at end of file diff --git a/Sources/Stim/App.xaml.cs b/Sources/Stim/App.xaml.cs index c60130b..4c80b04 100644 --- a/Sources/Stim/App.xaml.cs +++ b/Sources/Stim/App.xaml.cs @@ -20,7 +20,7 @@ public partial class App : Application window.Stopped += (s, e) => { - Manager.persistance = new Persistance(FileSystem.Current.AppDataDirectory); + Manager.Mgrpersistance = new Persistance(FileSystem.Current.AppDataDirectory); var test = Manager; Manager.SaveGames(); }; diff --git a/Sources/Stim/DetailledPage.xaml.cs b/Sources/Stim/DetailledPage.xaml.cs index c9c7c9c..dcb9dab 100644 --- a/Sources/Stim/DetailledPage.xaml.cs +++ b/Sources/Stim/DetailledPage.xaml.cs @@ -12,7 +12,6 @@ public partial class DetailledPage : ContentPage avgLabel.Text = game.Average.ToString(); AddStars(starsContainer, game.Average); - var test = game.Lien; } private void AddStars(object sender, EventArgs e)