diff options
Diffstat (limited to 'grapher/Models/Serialized/GUISettings.cs')
| -rw-r--r-- | grapher/Models/Serialized/GUISettings.cs | 27 |
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 + } } |