private static MainSettings LoadFromConfig() { MainSettings settings = new MainSettings(); try { using (FileStream stream = File.OpenRead(Path.Combine(settings.DefaultFolder, FILENAME))) using (StreamReader reader = new StreamReader(stream, Encoding.UTF8)) { JsonSerializer serializer = new JsonSerializer(); MainSettingsModel model = (MainSettingsModel)(serializer.Deserialize(reader, typeof(MainSettingsModel))); settings.UploadOnStop = model.UploadOnStop; switch (model.UploadServiceName) { case "imgur": case "giphy": case "gfycat": { settings.UploadServiceName = model.UploadServiceName; } break; default: break; } if (model.Recordings != null) { double delayMs = model.Recordings.Delay.TotalMilliseconds; if (33.0 <= delayMs && delayMs <= ushort.MaxValue) { settings.Recordings.Delay = (int)(delayMs); } if (model.Recordings.Folder != null) { settings.Recordings.Folder = model.Recordings.Folder; } } } } catch { } return(settings); }
public RecordingSettings(MainSettings settings) { _defaultFolder = Path.Combine(settings.DefaultFolder, "recordings"); ResetDelay(); ResetFolder(); }
static MainSettings() { _instance = LoadFromConfig(); }