From 7c1f14845bc948e9ea25908e96099203d9433a69 Mon Sep 17 00:00:00 2001 From: a1xd <68629610+a1xd@users.noreply.github.com> Date: Tue, 6 Apr 2021 01:21:42 -0400 Subject: update wrapper + writer to handle lut grapher is building but applying options still broken for the most part --- grapher/Models/Serialized/GUISettings.cs | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) (limited to 'grapher/Models/Serialized/GUISettings.cs') diff --git a/grapher/Models/Serialized/GUISettings.cs b/grapher/Models/Serialized/GUISettings.cs index bb35055..93d56de 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 { @@ -65,6 +66,32 @@ namespace grapher.Models.Serialized AutoWriteToDriverOnStartup.GetHashCode(); } + public void Save() + { + File.WriteAllText(Constants.GuiConfigFileName, JsonConvert.SerializeObject(this)); + } + + public static GUISettings MaybeLoad() + { + GUISettings settings = null; + + try + { + settings = JsonConvert.DeserializeObject( + File.ReadAllText(Constants.GuiConfigFileName)); + } + catch (Exception ex) + { + if (!(ex is JsonException || ex is FileNotFoundException)) + { + throw; + } + } + + return settings; + } + #endregion Methods + } } -- cgit v1.2.3