public void SetDeckToStudy(int DeckId) { DeckToStudy = DeckManager.GetDeckFromId(DeckId); //disallow decks with 0 cards to be studied - LS if (DeckToStudy.Cards.Count <= 0) { MessageBox.Show("It looks like there are no cards in this deck to study. Try adding some now."); NavigationManager.SetActiveScreen(NavigationScreen.EditDeck, DeckId); } else { Cards.Clear(); //C# passes by reference, so a for loop must be used - LS foreach (Card card in DeckToStudy.Cards) { Cards.Add(card); } //reset necessary variables for a study session - LS CurrentDeckTitle.Text = DeckToStudy.Title; CurrentCard = Cards[0]; Guesses = 0; InitialCardCount = Cards.Count; termAnswerTextbox.Show(); termAnswerTextbox.clearText(); ShowCardQuestion(); ShowSubmitButton(); } }
/* * Author: LS, LM * Notes: Levi wrote the majority of this, Lucas added the lines regarding adding to the cards list and controlling the visibility of the table layout * Get the details and cards from the selected deck and create all the needed EditCardPanels * If there are any cards to show, then make the containing TableLayout visible */ public void SetDeckToEdit(int DeckId) { DeckReference = DeckManager.GetDeckFromId(DeckId); termFlowLayoutPanel.Controls.Clear(); if (DeckReference != null) { deckTitleTextbox.Text = DeckReference.Title; foreach (Card c in DeckReference.Cards) { EditCardPanel newPanel = new EditCardPanel(c, this); termFlowLayoutPanel.Controls.Add(newPanel); cards.Add(newPanel); } if (DeckReference.Cards.Count > 0) { tableLayoutPanel1.Visible = true; } } }