//------------------------------------------------------------- private void button_Save_Click(object sender, EventArgs e) //------------------------------------------------------------- { DTO_SuggestionInternet suggestion = new DTO_SuggestionInternet() { description = textBox_Description.Text, imageCover = textBox_ImageCover.Text, maxPlayers = string.IsNullOrEmpty(textBox_MaxPlayers.Text) ? 0 : Convert.ToInt32(textBox_MaxPlayers.Text), imageBig = textBox_ImageBig.Text, title = textBox_Title.Text, url = textBox_GameUrl.Text, version = textBox_Versions.Text }; //Choose folder to save SaveFileDialog saveFileDialog = new SaveFileDialog(); saveFileDialog.Filter = "JSON file|*.json"; saveFileDialog.Title = "Save JSON config File"; saveFileDialog.InitialDirectory = Helper.GetDirection(); saveFileDialog.FileName = suggestion.title; saveFileDialog.ShowDialog(); if (saveFileDialog.FileName != "") { DTO_SuggestionInternet.SaveData(saveFileDialog.FileName, suggestion); } }
//------------------------------------------------------------- private void button_Load_Click(object sender, EventArgs e) //------------------------------------------------------------- { OpenFileDialog openFileDialog = new OpenFileDialog(); openFileDialog.Filter = "JSON file|*.json"; openFileDialog.Title = "Save JSON config File"; openFileDialog.InitialDirectory = Helper.GetDirection(); openFileDialog.ShowDialog(); if (openFileDialog.FileName != "") { DTO_SuggestionInternet suggestion = DTO_SuggestionInternet.LoadData(openFileDialog.FileName); textBox_Description.Text = suggestion.description; textBox_ImageCover.Text = suggestion.imageCover; textBox_ImageBig.Text = suggestion.imageBig; textBox_Title.Text = suggestion.title; textBox_GameUrl.Text = suggestion.url; textBox_Versions.Text = suggestion.version; textBox_MaxPlayers.Text = suggestion.maxPlayers.ToString(); } }