-
Notifications
You must be signed in to change notification settings - Fork 0
/
Choice.cs
154 lines (139 loc) · 6.54 KB
/
Choice.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
using System;
using System.Drawing;
using System.Linq;
using System.Windows.Forms;
namespace HiraKata_Kaizen {
public partial class Choice : Form {
public string openNext;
Dashboard dashboard = Application.OpenForms.OfType<Dashboard>().FirstOrDefault();
public Choice() {
InitializeComponent();
// Packs
string[] packs = { "Текущий", "Собственный" };
cmbPack.Items.AddRange(packs);
cmbPack.Texts = cmbPack.Items[0].ToString();
// Time
for (byte i = 45; i >= 5; i -= 5) {
cmbTime.Items.Add(i.ToString());
}
cmbTime.SelectedIndex = 0;
// Number
for (byte i = 46; i >= 2; i -= 2) {
cmbNumber.Items.Add(i.ToString());
}
cmbNumber.SelectedIndex = 0;
// Questions
string[] questions = { "Хирагана", "Катакана", "Ромадзи" };
cmbQuestions.Items.AddRange(questions);
cmbQuestions.SelectedIndex = 0;
// Answers
cmbAnswers.Items.Clear(); // очистить все итемы
string[] answers = { "Ромадзи", "Катакана" };
cmbAnswers.Items.AddRange(answers);
cmbAnswers.SelectedIndex = 0;
}
void SaveSettings() {
if (openNext == "quiz") {
Properties.Settings.Default.QuizTime = byte.Parse(cmbTime.SelectedItem.ToString());
Properties.Settings.Default.QuizNumber = byte.Parse(cmbNumber.SelectedItem.ToString());
Properties.Settings.Default.QuizQuestion = cmbQuestions.SelectedItem.ToString();
Properties.Settings.Default.QuizAnswer = cmbAnswers.SelectedItem.ToString();
}
else if (openNext == "cards") {
Properties.Settings.Default.CardsTime = byte.Parse(cmbTime.SelectedItem.ToString());
Properties.Settings.Default.CardsNumber = byte.Parse(cmbNumber.SelectedItem.ToString());
Properties.Settings.Default.CardsQuestion = cmbQuestions.SelectedItem.ToString();
Properties.Settings.Default.CardsAnswer = cmbAnswers.SelectedItem.ToString();
}
Properties.Settings.Default.Save();
}
void LoadSettings() {
if (openNext == "quiz") {
cmbTime.SelectedItem = Properties.Settings.Default.QuizTime.ToString();
cmbNumber.SelectedItem = Properties.Settings.Default.QuizNumber.ToString();
cmbQuestions.SelectedItem = Properties.Settings.Default.QuizQuestion;
cmbAnswers.SelectedItem = Properties.Settings.Default.QuizAnswer;
}
else if (openNext == "cards") {
cmbTime.SelectedItem = Properties.Settings.Default.CardsTime.ToString();
cmbNumber.SelectedItem = Properties.Settings.Default.CardsNumber.ToString();
cmbQuestions.SelectedItem = Properties.Settings.Default.CardsQuestion;
cmbAnswers.SelectedItem = Properties.Settings.Default.CardsAnswer;
}
}
void Choice_Load(object sender, EventArgs e) {
ControlBox = false;
LoadSettings();
if (openNext == "quiz") {
lblTitle.Text = "Настройка для викторины";
}
else if (openNext == "cards") {
lblTitle.Text = "Настройка для карт";
}
lblTitle.Location = new Point((ClientSize.Width - lblTitle.Width) / 2, 18);
}
// Next
void btnStart_Click(object sender, EventArgs e) {
SaveSettings();
if (openNext == "quiz") {
if (dashboard.content.Controls.Count > 0) dashboard.content.Controls.RemoveAt(0);
Quiz quiz = new Quiz(cmbTime.Texts, cmbNumber.Texts, cmbQuestions.Texts, cmbAnswers.Texts);
quiz.TopLevel = false;
quiz.Dock = DockStyle.Fill;
dashboard.content.Controls.Add(quiz);
dashboard.content.Tag = quiz;
quiz.Show();
}
else if (openNext == "cards") {
if (dashboard.content.Controls.Count > 0) dashboard.content.Controls.RemoveAt(0);
Cards cards = new Cards(cmbTime.Texts, cmbNumber.Texts, cmbQuestions.Texts, cmbAnswers.Texts);
cards.TopLevel = false;
cards.Dock = DockStyle.Fill;
dashboard.content.Controls.Add(cards);
dashboard.content.Tag = cards;
cards.Show();
}
}
// Back
void btnPractice_Click(object sender, EventArgs e) {
SaveSettings();
var dashboard = Application.OpenForms.OfType<Dashboard>().FirstOrDefault();
if (dashboard.content.Controls.Count > 0) dashboard.content.Controls.RemoveAt(0);
Practice practice = new Practice();
practice.TopLevel = false;
practice.Dock = DockStyle.Fill;
dashboard.content.Controls.Add(practice);
dashboard.content.Tag = practice;
practice.Show();
}
void cmbQuestions_OnSelectedIndexChanged(object sender, EventArgs e) {
string selectedQuestion = cmbQuestions.SelectedItem.ToString();
switch (selectedQuestion) {
case "Хирагана":
// добавить новые
cmbAnswers.Items.Add("Ромадзи");
cmbAnswers.Items.Add("Катакана");
if (selectedQuestion == cmbAnswers.Texts) {
cmbAnswers.SelectedIndex = 0;
}
break;
case "Катакана":
cmbAnswers.Items.Clear();
cmbAnswers.Items.Add("Ромадзи");
cmbAnswers.Items.Add("Хирагана");
if (selectedQuestion == cmbAnswers.Texts) {
cmbAnswers.SelectedIndex = 0;
}
break;
case "Ромадзи":
cmbAnswers.Items.Clear();
cmbAnswers.Items.Add("Хирагана");
cmbAnswers.Items.Add("Катакана");
if (selectedQuestion == cmbAnswers.Texts) {
cmbAnswers.SelectedIndex = 0;
}
break;
}
}
}
}