好友
阅读权限10
听众
最后登录1970-1-1
|
想起来小时候用小霸王英语词霸, 对我学习英语帮助挺大. 所以做了一个类似的. 就是一个简单的选择题. 每天不断反复的让孩子练习. 看看对大家有没有帮助. 单词表用的一个托福的单词表, 自己也可以按照格式添加小学, 初中, 高中以及四六级的, 不过我没找到什么现成的. 带了微软的语音, 所以可以配个影响, 让孩子跟着电脑读.
单词考试.rar
(1.21 MB, 下载次数: 420)
[C#] 纯文本查看 复制代码 using System.Data;
using System.Text;
using System.Transactions;
using System.Speech.Recognition;
using System.Speech.Synthesis;
namespace 单词考试
{
public partial class Form1 : Form
{
private DataTable dt;
private int FRightSubmit = 0;
private List<RadioButton> frbtns;
private bool FNoSubmit = true;
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
frbtns = new List<RadioButton>();
frbtns.Add(rbtn1);
frbtns.Add(rbtn2);
frbtns.Add(rbtn3);
frbtns.Add(rbtn4);
FRightSubmit = 0;
dt = new DataTable();
System.IO.FileStream fs = new System.IO.FileStream(Environment.CurrentDirectory + "\\tuofu.csv", System.IO.FileMode.Open);
System.IO.StreamReader sr = new System.IO.StreamReader(fs, Encoding.GetEncoding("UTF-8"));
string temptext = "";
bool firstRow = true;
while ((temptext = sr.ReadLine()) != null)
{
string[] arr = temptext.Split(new char[] { '|' }, StringSplitOptions.RemoveEmptyEntries);
DataRow dr = dt.NewRow();
if (firstRow)
{
firstRow = false;
for (int i = 0; i < arr.Length; i++)
{
dt.Columns.Add(i.ToString());
}
}
for (int i = 0; i < arr.Length; i++)
{
dr[i] = arr[i];
}
dt.Rows.Add(dr);
}
sr.Close();
fs.Close();
btnnext.PerformClick();
}
private static void Shuffle(List<RadioButton> list)
{
int n = list.Count;
while (n > 1)
{
int randomIndex = new Random().Next(n);
if (n > 0 && n < list.Count && randomIndex >= 0 && randomIndex < list.Count && n != randomIndex)
{
var temp = list[n - 1];
list[n - 1] = list[randomIndex];
list[randomIndex] = temp;
}
n--;
}
}
private void btnnext_Click(object sender, EventArgs e)
{
bool nocheckedbtn = true;
foreach (RadioButton r in frbtns)
{
if (r.Checked)
{
nocheckedbtn = false;
break;
}
}
if (rbtn1.Text != "radioButton1" && FNoSubmit)
{
return;
}
if (rbtn1.Text != "radioButton1" && nocheckedbtn)
{
return;
}
FNoSubmit = true;
Shuffle(frbtns);
Random ranMaker = new Random();
HashSet<int> selectID = new HashSet<int>();
int firstid = -1;
while (selectID.Count < 4)
{
int i = ranMaker.Next(0, dt.Rows.Count);
if (firstid == -1)
{
firstid = i;
}
selectID.Add(i);
}
DataRow dr1 = dt.Rows[firstid];
lblword.Text = dr1[0].ToString();
lblsound.Text = dr1[1].ToString();
int ri = 0;
foreach (int id in selectID)
{
dr1 = dt.Rows[id];
frbtns[ri].Text = (string)dr1["2"];
ri++;
}
foreach (RadioButton r in frbtns)
{
r.Checked = false;
}
}
public string ReadEmbeddedCsv(string filename)
{
string path = Path.GetFullPath(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, filename));
if (File.Exists(path))
return File.ReadAllText(path, Encoding.UTF8);
else
return null;
}
private void button1_Click(object sender, EventArgs e)
{
FNoSubmit = false;
var reader = new System.Speech.Synthesis.SpeechSynthesizer();
reader.SpeakAsync(lblword.Text);
if (FRightSubmit == 100)
{
MessageBox.Show("你已经完成了今天的任务, 恭喜你");
}
if (frbtns[0].Checked)
{
lblok.BackColor = Color.Green;
lblok.ForeColor = Color.White;
lblok.Text = "恭喜你, 答对了";
FRightSubmit++;
label2.Text = "答对题目数: " + FRightSubmit.ToString() + "/100";
}
else
{
lblok.ForeColor = Color.White;
lblok.BackColor = Color.Red;
lblok.Text = "不好意思, 答错了";
}
}
}
} |
免费评分
-
查看全部评分
|
发帖前要善用【论坛搜索】功能,那里可能会有你要找的答案或者已经有人发布过相同内容了,请勿重复发帖。 |
|
|
|
|