public void SaveCurrentDeck() { List <Card> Cards = new List <Card>(); foreach (EditCardPanel cardInDeck in this.termFlowLayoutPanel.Controls) { Cards.Add(cardInDeck.ConvertToCard()); } DeckReference.Cards = Cards; DeckReference.Title = deckTitleTextbox.Text; DeckManager.OverwriteDeck(DeckReference); DeckManager.ExportDecksToJson(); }
//fires when the delete button is clicked - LS /* * Author: LS, LM * Notes: Levi wrote most of this method, Lucas updated it to use the new overloaded version of the NavigationManager.SetActiveScreen method to prevent any attempts to autosave a deck that no longer exists when navigating away * Asks the user to confirm deleting the current deck and navigates back to DeckList screen without trying to autosave after deleting */ private void deleteDeckButton_Click(object sender, EventArgs e) { //create a yes/no dialog box - LS var confirmResult = MessageBox.Show("Really delete the deck?", "Deck deletion", MessageBoxButtons.YesNo); //if the user answers yes - LS if (confirmResult == DialogResult.Yes) { DeckManager.DeleteDeck(DeckReference); DeckManager.ExportDecksToJson(); //Calls new overload of SetActiveScreen, avoids attempting to autosave deck that no longer exists NavigationManager.SetActiveScreen(NavigationScreen.DeckList, false); } }
/* * Author: BH * Detects when the PrimaryForm is closing, signaling that the application is closing * Writes the master DeckList to storage one more time before closing so that the next time the application starts it has access to the most recent, up-to-date data */ private void PrimaryForm_FormClosing(object sender, FormClosingEventArgs e) { DeckManager.ExportDecksToJson(); }