예제 #1
0
        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);
        }
예제 #2
0
 public RecordingSettings(MainSettings settings)
 {
     _defaultFolder = Path.Combine(settings.DefaultFolder, "recordings");
     ResetDelay();
     ResetFolder();
 }
예제 #3
0
 static MainSettings()
 {
     _instance = LoadFromConfig();
 }