Skip to content

Commit

Permalink
a bug occuring when there is no dictionary is now fixed
Browse files Browse the repository at this point in the history
  • Loading branch information
tmokmss committed Jun 19, 2016
1 parent 789e38e commit cb12014
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 2 deletions.
20 changes: 19 additions & 1 deletion Morusu/MainForm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ public MainForm()

private void MainForm_Load(object sender, EventArgs e)
{
// 音声再生周りの初期化
var be = new DxBeemEmitter(this);
mp = new MorsePlayer(be);
mp.Beeped += OnBeeped;
Expand All @@ -39,15 +40,16 @@ private void MainForm_Load(object sender, EventArgs e)

SetFrequencyAndWPM();
SetAmplitude();
LoadDictList();

waveShapeList.SelectedIndex = 0;

LoadDictList();
InitializePlayMode();
}

void LoadDictList()
{
InitializeDictionaryIfUnavailable();
dictList.Items.Clear();
string[] files = Directory.GetFiles(@"dict\", "*.dic");
foreach (var file in files)
Expand All @@ -57,6 +59,22 @@ void LoadDictList()
dictList.SelectedIndex = 0;
}

void InitializeDictionaryIfUnavailable()
{
if (!Directory.Exists(@"dict\"))
{
Directory.CreateDirectory(@"dict\");
}
if (Directory.GetFiles(@"dict\", "*.dic").Length == 0)
{
using (var sw = new StreamWriter(@"dict\example.dic", false, Encoding.GetEncoding("Shift_Jis")))
{
var text = "表示部用名称,打鍵用名称, \r\n例,REI\r\nカンマが1つだけ存在する行のみ処理される\r\n元となる日本語辞書はここなどで拾えるhttp://bironist.so.land.to/uploader/upload.html";
sw.Write(text);
}
}
}

void InitializePlayMode()
{
qmaster = null;
Expand Down
2 changes: 1 addition & 1 deletion Morusu/Quiz/QuestionMaster.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@ namespace Morusu.Quiz
class QuestionMaster
{
List<Question> qlist;
QuestionReader reader = new QuestionReader();

public void SetQuestion(string qpath)
{
var reader = new QuestionReader();
qlist = reader.ReadFile(qpath);
}

Expand Down

0 comments on commit cb12014

Please sign in to comment.