38 lines
1.0 KiB
C#
38 lines
1.0 KiB
C#
using System;
|
|
using System.IO;
|
|
using Newtonsoft.Json;
|
|
|
|
namespace StarfaceOutlookSync.Models
|
|
{
|
|
public class UserSettings
|
|
{
|
|
public bool StartMinimized { get; set; } = false;
|
|
|
|
private static readonly string SettingsFile = Path.Combine(
|
|
Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData),
|
|
"StarfaceOutlookSync", "settings.json");
|
|
|
|
public static UserSettings Load()
|
|
{
|
|
try
|
|
{
|
|
if (File.Exists(SettingsFile))
|
|
return JsonConvert.DeserializeObject<UserSettings>(File.ReadAllText(SettingsFile))
|
|
?? new UserSettings();
|
|
}
|
|
catch { }
|
|
return new UserSettings();
|
|
}
|
|
|
|
public void Save()
|
|
{
|
|
try
|
|
{
|
|
Directory.CreateDirectory(Path.GetDirectoryName(SettingsFile));
|
|
File.WriteAllText(SettingsFile, JsonConvert.SerializeObject(this, Formatting.Indented));
|
|
}
|
|
catch { }
|
|
}
|
|
}
|
|
}
|