summaryrefslogtreecommitdiff
path: root/grapher/Models/Serialized/GUISettings.cs
diff options
context:
space:
mode:
authora1xd <[email protected]>2021-09-22 20:49:04 -0400
committerGitHub <[email protected]>2021-09-22 20:49:04 -0400
commit8a4b6f57758338d5537d4671184099a4728a8cdd (patch)
treedf36529a344d5d21ff11f5ba021ec80afb4b68a4 /grapher/Models/Serialized/GUISettings.cs
parentMerge pull request #87 from matthewstrasiotto/streamer_mode (diff)
parentimprove converter + docs (diff)
downloadrawaccel-8a4b6f57758338d5537d4671184099a4728a8cdd.tar.xz
rawaccel-8a4b6f57758338d5537d4671184099a4728a8cdd.zip
Merge pull request #105 from a1xd/1.5.x
v1.5
Diffstat (limited to 'grapher/Models/Serialized/GUISettings.cs')
-rw-r--r--grapher/Models/Serialized/GUISettings.cs27
1 files changed, 27 insertions, 0 deletions
diff --git a/grapher/Models/Serialized/GUISettings.cs b/grapher/Models/Serialized/GUISettings.cs
index a4eb627..e7b67ba 100644
--- a/grapher/Models/Serialized/GUISettings.cs
+++ b/grapher/Models/Serialized/GUISettings.cs
@@ -1,5 +1,6 @@
using Newtonsoft.Json;
using System;
+using System.IO;
namespace grapher.Models.Serialized
{
@@ -70,6 +71,32 @@ namespace grapher.Models.Serialized
StreamingMode.GetHashCode();
}
+ public void Save()
+ {
+ File.WriteAllText(Constants.GuiConfigFileName, JsonConvert.SerializeObject(this));
+ }
+
+ public static GUISettings MaybeLoad()
+ {
+ GUISettings settings = null;
+
+ try
+ {
+ settings = JsonConvert.DeserializeObject<GUISettings>(
+ File.ReadAllText(Constants.GuiConfigFileName));
+ }
+ catch (Exception ex)
+ {
+ if (!(ex is JsonException || ex is FileNotFoundException))
+ {
+ throw;
+ }
+ }
+
+ return settings;
+ }
+
#endregion Methods
+
}
}