From 336ccda5bb70c932aa240d22784b0810d11922f6 Mon Sep 17 00:00:00 2001 From: Jade_VAN_BRABANDT Date: Wed, 24 May 2023 15:43:13 +0200 Subject: [PATCH] =?UTF-8?q?Feat=20:=20sauvegarde=20=C3=A0=20la=20fermeture?= =?UTF-8?q?,=20cr=C3=A9ation=20de=20fichier=20si=20non=20existant?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Sources/Stim/App.xaml.cs | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/Sources/Stim/App.xaml.cs b/Sources/Stim/App.xaml.cs index 4a3a143..277653f 100644 --- a/Sources/Stim/App.xaml.cs +++ b/Sources/Stim/App.xaml.cs @@ -1,5 +1,6 @@ using Model; using StimPersistance; +using StimStub; namespace Stim; @@ -13,7 +14,20 @@ public partial class App : Application { InitializeComponent(); string mainDir = FileSystem.Current.AppDataDirectory; - Mgr = new Manager(new Persistance(mainDir)); + if (File.Exists(Path.Combine(mainDir,"games.xml"))) Mgr = new Manager(new Persistance(mainDir)); + else Mgr = new Manager(new Stub()); MainPage = new AppShell(); } + protected override Window CreateWindow(IActivationState activationState) + { + Window window = base.CreateWindow(activationState); + + window.Stopped += (s, e) => + { + Mgr._persistance = new Persistance(FileSystem.Current.AppDataDirectory); + Mgr.SaveGames(); + }; + + return window; + } }