吾爱破解 - LCG - LSG |安卓破解|病毒分析|www.52pojie.cn

 找回密码
 注册[Register]

QQ登录

只需一步,快速开始

查看: 2731|回复: 43
收起左侧

[C&C++ 原创] 单词考试软件

  [复制链接]
jim19 发表于 2023-9-6 12:38
想起来小时候用小霸王英语词霸, 对我学习英语帮助挺大. 所以做了一个类似的. 就是一个简单的选择题. 每天不断反复的让孩子练习. 看看对大家有没有帮助. 单词表用的一个托福的单词表, 自己也可以按照格式添加小学, 初中, 高中以及四六级的, 不过我没找到什么现成的. 带了微软的语音, 所以可以配个影响, 让孩子跟着电脑读.
aa.png
单词考试.rar (1.21 MB, 下载次数: 403)
[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 = "不好意思, 答错了";
            }

        }
    }
}

免费评分

参与人数 9吾爱币 +14 热心值 +9 收起 理由
gamingnow + 1 + 1 用心讨论,共获提升!
UDB555 + 1 + 1 热心回复!
wushaominkk + 7 + 1 欢迎分析讨论交流,吾爱破解论坛有你更精彩!
星空迷徒 + 1 我很赞同!
akibaizumi + 1 + 1 谢谢@Thanks!
dhwl9899 + 1 + 1 谢谢@Thanks!
ivanyeung215 + 1 + 1 谢谢@Thanks!
sohuso + 1 + 1 感谢发布原创作品,吾爱破解论坛因你更精彩!
聪本 + 1 + 1 看上去是一个很不错的软件

查看全部评分

本帖被以下淘专辑推荐:

发帖前要善用论坛搜索功能,那里可能会有你要找的答案或者已经有人发布过相同内容了,请勿重复发帖。

 楼主| jim19 发表于 2023-9-6 12:54
markhoo911 发表于 2023-9-6 12:53
请问一下,你是用的WinForm还是WPF

用的winform
markhoo911 发表于 2023-11-29 17:41
jim19 发表于 2023-11-2 15:48
譬如你找个比较好用的那种我看看

https://worktile.com  
这个里面有个目标管理,然后就是一个看板。那个目标挺好用,看书的时候,进度会显示百分比,填入总页数或者总章节,看到哪里我填一下就更新了。太好用了。效率神器。但是这个小功能就收费,太操蛋了
聪本 发表于 2023-9-6 12:49
xiaoniaoyou325 发表于 2023-9-6 12:50
为什么收藏不了
markhoo911 发表于 2023-9-6 12:53
请问一下,你是用的WinForm还是WPF
czp13 发表于 2023-9-6 12:58
我来试试
ivanyeung215 发表于 2023-9-6 13:00
我來玩玩,正好最近在學英文
dhwl9899 发表于 2023-9-6 13:10
谢谢分享,但愿实用有效。
cux666 发表于 2023-9-6 13:30
真有高人,收藏,赞!
zhengsg5 发表于 2023-9-6 13:46
试试效果怎样!
您需要登录后才可以回帖 登录 | 注册[Register]

本版积分规则 警告:本版块禁止灌水或回复与主题无关内容,违者重罚!

快速回复 收藏帖子 返回列表 搜索

RSS订阅|小黑屋|处罚记录|联系我们|吾爱破解 - LCG - LSG ( 京ICP备16042023号 | 京公网安备 11010502030087号 )

GMT+8, 2024-5-2 23:27

Powered by Discuz!

Copyright © 2001-2020, Tencent Cloud.

快速回复 返回顶部 返回列表