From 3500430109836218624bcc5f7abb5e3b47d97d09 Mon Sep 17 00:00:00 2001 From: HeshamTB Date: Sun, 23 Sep 2018 16:08:46 +0300 Subject: [PATCH] use of save maneger --- OWTrack/MainForm.cs | 2 +- OWTrack/saveManeger.cs | 16 ++++++++++++++-- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/OWTrack/MainForm.cs b/OWTrack/MainForm.cs index da59458..beab07b 100644 --- a/OWTrack/MainForm.cs +++ b/OWTrack/MainForm.cs @@ -157,7 +157,7 @@ namespace OWTrack } else srLabel.Text = tr.startSR.ToString() + " - " + tr.srDiff(); srTextBox.Text = null; - File.WriteAllText(Directory.GetCurrentDirectory() + "/saves/data.json", JsonConvert.SerializeObject(tr)); + saveManeger.SaveJSON(tr); } #region Events diff --git a/OWTrack/saveManeger.cs b/OWTrack/saveManeger.cs index e2df361..0ac4cb9 100644 --- a/OWTrack/saveManeger.cs +++ b/OWTrack/saveManeger.cs @@ -32,6 +32,10 @@ namespace OWTrack { private static string savesPath = Directory.GetCurrentDirectory() + "/saves/data.json"; + /// + /// Deserialize saved tracker instance. + /// + /// public static Tracker GetSavedTracker() { try @@ -44,7 +48,6 @@ namespace OWTrack } } - //TODO: use para public static Tracker GetSavedTracker(string customPath) { try @@ -57,11 +60,16 @@ namespace OWTrack } } + /// + ///Saves the Tracker Object. + /// + /// + /// public static bool SaveJSON(Tracker tracker) { try { - File.WriteAllText(Directory.GetCurrentDirectory() + "/data.json", JsonConvert.SerializeObject(tracker)); + File.WriteAllText(savesPath, JsonConvert.SerializeObject(tracker)); return true; } catch (Exception) @@ -70,6 +78,10 @@ namespace OWTrack } } + /// + /// Check if a 'data.json' exists in the default location '../saves/data.json'. + /// + /// Boolean Value public static bool saveExist() { try