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();
            }
        }
Exemple #2
0
 /*
  * Author: LM
  * Overload of Ben's LoadDeckPanels method that accept a string and passes that string to the overloaded CreateDeckPanels method of the DeckManager class
  * This is one of the foundations of the functionality allowing users to search for Decks by name
  * As the user's search string is built up, the DeckPanels are re-rendered with each update slowly excluding every deck that does not contain the current string in its title
  */
 public void LoadDeckPanels(string str)
 {
     DeckListFlowLayoutPanel.Controls.Clear();
     foreach (DeckPanel dp in DeckManager.CreateDeckPanels(str))
     {
         DeckListFlowLayoutPanel.Controls.Add(dp);
     }
 }
        //Creates new empty deck and sets view to edit it
        private void CreateDeckButton_Click(object sender, EventArgs e)
        {
            Deck NewDeck = DeckManager.CreateNewDeck(DeckTitle.Text, DeckDescription.Text);

            NavigationManager.SetActiveScreen(NavigationScreen.EditDeck, NewDeck.Id);
            DeckTitle.clearText();
            DeckDescription.clearText();
        }
Exemple #4
0
        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();
        }
Exemple #5
0
 /*
  * Gets a dictionary containing the id and name of every deck currently in storage and uses them to set the elements of the CheckedListBox
  * CheckedListBox will use the deck name for the display while the actual value of the list item is the deck id
  */
 public void SetDeckList()
 {
     Decks = DeckManager.getDeckNames();
     checkedListBox1.Items.Clear();
     foreach (KeyValuePair <int, string> kvp in Decks.OrderBy(pair => pair.Value))
     {
         checkedListBox1.Items.Add(new ListItem {
             DisplayValue = kvp.Value, RealValue = kvp.Key
         });
     }
     checkedListBox1.DisplayMember = "DisplayValue";
     checkedListBox1.ValueMember   = "RealValue";
 }
Exemple #6
0
        //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);
            }
        }
Exemple #7
0
        /*
         * When the export button is clicked, get a list of ints representing the ids of the decks selected from the list
         * Pass that list to DeckManager.ShareDecks method then clear then uncheck all the items in the list
         */
        private void exportBtn_Click(object sender, EventArgs e)
        {
            List <int> ids = new List <int>();

            if (checkedListBox1.CheckedItems.Count > 0)
            {
                foreach (ListItem li in checkedListBox1.CheckedItems)
                {
                    ids.Add(li.RealValue);
                }

                DeckManager.ShareDecks(ids);
                checkedListBox1.ClearSelected();
            }
        }
Exemple #8
0
        /*
         * 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;
                }
            }
        }
Exemple #9
0
        public PrimaryForm()
        {
            InitializeComponent();

            //Import deck file
            DeckManager.ImportDecksFromJson();

            //Initialize references to form controls
            NavigationManager.GetParent(this);
            NavigationManager.InitializeControl(PrimaryNavMenu);

            NavigationManager.InitializeControl(PrimaryDeckListPanel);
            NavigationManager.InitializeControl(PrimaryEditPanel);
            NavigationManager.InitializeControl(PrimaryStudyPanel);
            NavigationManager.InitializeControl(PrimaryHelpPanel);
            NavigationManager.InitializeControl(PrimaryAddNewDeckPanel);
            NavigationManager.InitializeControl(PrimarySharePanel);

            //Set deck list screen as active when the form loads
            NavigationManager.SetActiveScreen(NavigationScreen.DeckList);
        }
Exemple #10
0
 /*
  * 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();
 }
Exemple #11
0
 /*
  * Call the DeckManager.ImportDecks method when the import button is clicked
  */
 private void importBtn_Click(object sender, EventArgs e)
 {
     DeckManager.ImportDecks();
 }