/// <summary> /// 获取一个问题的拼音速查代码 /// </summary> /// <param name="question">问题</param> /// <returns>问题的拼音速查代码</returns> private string getPinYin(string question) { StringBuilder result = new StringBuilder(); foreach (char ch in question.ToLower()) { char pinyin = Pinyin.GetPinyin(ch); if ((pinyin >= '0' && pinyin <= '9') || (pinyin >= 'a' && pinyin <= 'z')) { result.Append(pinyin); } } return(result.ToString()); }
/// <summary> /// 窗口载入完毕 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void MainForm_Shown(object sender, EventArgs e) { // 允许跨线程操作组件 Control.CheckForIllegalCrossThreadCalls = false; // 加载 info.txt loadInfo(); // 初始化拼音库 Pinyin.init(); // 加载题目表 this.questions = new Questions(); // 刷新显示内容 updateUI(); // 设置启动时间 this.startTime = DateTime.Now; // 启动自动更新 new Thread(AutoUpdate.start).Start(); }