-
Notifications
You must be signed in to change notification settings - Fork 0
/
StudyingScreen.cs
156 lines (130 loc) · 5.49 KB
/
StudyingScreen.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
using SanjayComSciIA.Models;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace SanjayComSciIA
{
public partial class StudyingScreen : Form
{
List<FlashCardsModel> FlashCards;
//creating a variable to move along the flashcards
int flashcardCounter = 0;
//creating a boolean to check if the card is on the front or the back
bool isFront = true;
public StudyingScreen()
{
InitializeComponent();
}
public StudyingScreen(List<FlashCardsModel> fc)
{
FlashCards = fc;
InitializeComponent();
}
private void StudyingScreen_Load(object sender, EventArgs e)
{
this.CenterToScreen();
FlashCards = FlashCardsModel.GetFlashCards();
}
private void btnHard_Click(object sender, EventArgs e)
{
var flashcards = (from d in FlashCards select d.Front).ToList();
var difficulty = (from diff in FlashCards select diff.Difficulty).ToList();
//checking if there are more cards
if (flashcardCounter > flashcards.Count()-1)
{
MessageBox.Show(this, "All Cards have been Studied!", Titles.AppTitle, MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
//closes the screen to return back to the main screen
this.Close();
//Creating a new thread that runs the second application
Thread t = new Thread(new ThreadStart(ThreadWelcome));
t.Start();
flashcardCounter--;
}
txtCardAnswer.Text = flashcards[flashcardCounter].ToString();
txtDifficulty.Text = difficulty[flashcardCounter].ToString();
//incrementing this flashcard value
flashcardCounter++;
}
private void btnMedium_Click(object sender, EventArgs e)
{
var flashcards = (from d in FlashCards select d.Front).ToList();
var difficulty = (from diff in FlashCards select diff.Difficulty).ToList();
//checking if there are more cards
if (flashcardCounter > flashcards.Count() - 1)
{
MessageBox.Show(this, "All Cards have been Studied!", Titles.AppTitle, MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
//closes the screen to return back to the main screen
this.Close();
//Creating a new thread that runs the second application
Thread t = new Thread(new ThreadStart(ThreadWelcome));
t.Start();
flashcardCounter--;
}
txtCardAnswer.Text = flashcards[flashcardCounter].ToString();
txtDifficulty.Text = difficulty[flashcardCounter].ToString();
//incrementing this flashcard value
flashcardCounter++;
}
private void btnEasy_Click(object sender, EventArgs e)
{
var flashcards = (from d in FlashCards select d.Front).ToList();
var difficulty = (from diff in FlashCards select diff.Difficulty).ToList();
//checking if there are more cards
if (flashcardCounter > flashcards.Count() - 1)
{
MessageBox.Show(this, "All Cards have been Studied!", Titles.AppTitle, MessageBoxButtons.OK, MessageBoxIcon.None);
//closes the screen to return back to the main screen
this.Close();
//Creating a new thread that runs the second application
Thread t = new Thread(new ThreadStart(ThreadWelcome));
t.Start();
flashcardCounter--;
}
txtCardAnswer.Text = flashcards[flashcardCounter].ToString();
txtDifficulty.Text = difficulty[flashcardCounter].ToString();
//incrementing this flashcard value
flashcardCounter++;
}
private void btnFlip_Click(object sender, EventArgs e)
{
var flashcardsFront = (from d in FlashCards select d.Front).ToList();
var flashcardsBack = (from d in FlashCards select d.Back).ToList();
if (isFront)
{
txtCardAnswer.Text = flashcardsBack[flashcardCounter].ToString();
isFront = false;
}
else
{
txtCardAnswer.Text = flashcardsFront[flashcardCounter].ToString();
isFront = true;
}
}
private void btnExit_Click(object sender, EventArgs e)
{
//closing the current form
this.Close();
//Creating a new thread that runs the second application
Thread t = new Thread(new ThreadStart(ThreadWelcome));
t.Start();
}
private void ThreadWelcome()
{
Application.Run(new Welcome());
}
private void btnStart_Click(object sender, EventArgs e)
{
var flashcards = (from d in FlashCards select d.Front).ToList();
txtCardAnswer.Text = flashcards.First().ToString();
var difficulty = (from diff in FlashCards select diff.Difficulty).ToList();
txtDifficulty.Text = difficulty.First().ToString();
}
}
}