private void Button_Click(object sender, RoutedEventArgs e) { if (!string.IsNullOrWhiteSpace(tbSaveName.Text)) { WebApi.AddNewLevel(tbSaveName.Text, GridConverter.Serialize(grid)); //string path = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), string.Format(@"PuzzleGame\{0}.json", tbSaveName.Text)); //string root = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), @"PuzzleGame\"); //if (!Directory.Exists(root)) //{ // Directory.CreateDirectory(root); //} //// Delete the file if it exists. //if (File.Exists(path)) //{ // //File.Delete(path); // MessageBox.Show("Naam is al bezet kies een ander."); //} //else //{ // //Create the file. // File.WriteAllText(path, grid.Serialize()); //} } }
private void SaveLevel() { string levelName = Message.InputMessage("Give youre level a name", "Save", "Cancel"); if (!string.IsNullOrWhiteSpace(levelName)) { WebApi.AddNewLevel(levelName, GridConverter.Serialize(levelEditor.grid)); } }