private void studySubjectToolStripMenuItem_Click(object sender, EventArgs e) { //create menu/form to ask which method they'd like to study by System.Windows.Forms.DialogResult dialogResult = MessageBox.Show("Would you like to study this subject's child subjects along with it?", "Studying Options", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question); if (dialogResult == System.Windows.Forms.DialogResult.Cancel) { return; //no studying today } bool includeChildren = dialogResult == System.Windows.Forms.DialogResult.Yes ? true : false; //in the future add other study methods //hide main form, create study dialog, and let study session occur this.Hide(); List <Card> cards = populateCards((Subject)lastSelectedNode.Tag, includeChildren); if (cards.Count < 3) { Helper.ShowError("There must be at least 3 cards to study."); return; } StudySession session = StudyView.CreateSession(cards); //get and display results ResultView.ShowResults(session); //add study session to past study sessions ((RootSubject)treeMain.Nodes[0].Tag).PastStudySessions.Add(session); //show main form and edit flag or prompt for saving this.Show(); doEdited(); }
public static void ShowResults(StudySession session) { ResultView results = new ResultView(); int correct = session.SessionCards.Sum(x => x.CardStatus == (int)CardStatus.Correct ? 1 : 0); int incorrect = session.SessionCards.Sum(x => x.CardStatus == (int)CardStatus.Incorrect ? 1 : 0); results.textCorrect.Text = correct.ToString(); results.textIncorrect.Text = incorrect.ToString(); results.textPercentage.Text = ((int)((double)correct / (correct + incorrect) * 100)).ToString(); results.ShowDialog(); }