Пример #1
0
        private void btnSettings_Click(object sender, EventArgs e)
        {
            btnExit.Visible      = false;
            btnSettings.Visible  = false;
            btnStartGame.Visible = false;

            btnBack.Visible       = true;
            btnMusicState.Visible = true;
            tbVolume.Visible      = true;
            lblVolume.Visible     = true;

            AudioAndMedia.BackgroundAudioFileSave loader = new AudioAndMedia.BackgroundAudioFileSave();
            backgroundAudio = loader.Load(backgroundAudio);
        }
 public BackgroundAudio Load(BackgroundAudio backgroundAudio)
 {
     if (File.Exists(BackgroundAudio.JsonPathSave))
     {
         string          json_  = File.ReadAllText(BackgroundAudio.JsonPathSave);
         BackgroundAudio result = new BackgroundAudio();
         result = JsonConvert.DeserializeObject <BackgroundAudio>(json_);
         return(result);
     }
     else
     {
         RegistrationForm.MessageShow("Users.json isn't exist.", "Info", MessageBoxButtons.OK);
         return(null);
     }
 }
        public void Save(BackgroundAudio backgroundAudio)
        {
            string jsonStr = System.Text.Json.JsonSerializer.Serialize <BackgroundAudio>(backgroundAudio);

            File.WriteAllText(BackgroundAudio.JsonPathSave, jsonStr);
        }