Пример #1
0
        private void SaveSettings()
        {
            string jsonString;

            lock (globalLock)
            {
                var dict = new Dictionary <string, string>();
                dict["AudioSettings"] = realtimeConfig != null?realtimeConfig.Serialize() : "";

                dict[nameof(SelectedInputL)]      = SelectedInputL.ToString();
                dict[nameof(SelectedInputR)]      = SelectedInputR.ToString();
                dict[nameof(SelectedOutputL)]     = SelectedOutputL.ToString();
                dict[nameof(SelectedOutputR)]     = SelectedOutputR.ToString();
                dict[nameof(loadSampleDirectory)] = loadSampleDirectory;
                dict[nameof(saveSampleDirectory)] = saveSampleDirectory;
                dict[nameof(savePresetDirectory)] = savePresetDirectory;
                dict[nameof(VolumeSlider)]        = VolumeSlider.ToString("0.000", CultureInfo.InvariantCulture);
                jsonString = JsonConvert.SerializeObject(dict, Formatting.Indented);

                if (jsonString != currentJsonSettings)
                {
                    if (currentJsonSettings != null)                 // don't save on the first round, only compute the value you indend to save. This is so we don't touch the config every time the app opens
                    {
                        File.WriteAllText(settingsFile, jsonString);
                    }

                    currentJsonSettings = jsonString;
                }
            }
        }