public PracticeDialog(VocabularyBook book, List <VocabularyWordPractice> practiceList) { InitializeComponent(); Icon = Icon.FromHandle(Icons.LightningBolt.GetHicon()); evaluator = new Evaluator { OptionalExpressions = Settings.Default.EvaluateOptionalExpressions, TolerateArticle = Settings.Default.EvaluateTolerateArticle, TolerateNoSynonym = Settings.Default.EvaluateTolerateNoSynonym, ToleratePunctuationMark = Settings.Default.EvaluateToleratePunctuationMark, TolerateSpecialChar = Settings.Default.EvaluateTolerateSpecialChar, TolerateWhiteSpace = Settings.Default.EvaluateTolerateWhiteSpace }; player = new SoundPlayer(); this.book = book; this.practiceList = practiceList; index = 0; currentPractice = practiceList[0]; currentWord = currentPractice.VocabularyWord; specialCharDialog = new SpecialCharKeyboard(); specialCharDialog.Initialize(this, BtnSpecialChar); if (Settings.Default.UserEvaluates) { MinimumSize = new Size(MinimumSize.Width, LogicalToDeviceUnits(380)); // All other controls are adjusted by anchor } LbMotherTongue.Text = book.MotherTongue; LbForeignLang.Text = book.ForeignLang; if (book.PracticeMode == PracticeMode.AskForForeignLang) { GroupPractice.Text = string.Format(Words.TranslateFromTo, book.MotherTongue, book.ForeignLang); } else { GroupPractice.Text = string.Format(Words.TranslateFromTo, book.ForeignLang, book.MotherTongue); } }
private void EvaluateWord() { TbForeignLang.ReadOnly = true; TbMotherTongue.ReadOnly = true; TbForeignLangSynonym.ReadOnly = true; GroupUserEvaluation.Enabled = true; currentPractice.PracticeResult = EvaluateInput(); currentWord.PracticeDate = DateTime.Now; Stream sound = null; //Ergebnis bekannt geben if (currentPractice.PracticeResult == PracticeResult.Correct) { //Ergebnisse speichern if (currentWord.PracticeStateNumber == 0) { currentWord.PracticeStateNumber = 2; } else { currentWord.PracticeStateNumber++; } if (!Settings.Default.UserEvaluates) { TbCorrectAnswer.Text = Words.Correct + "!"; TbCorrectAnswer.BackColor = Color.FromArgb(144, 238, 144); sound = Sounds.sound_correct; } } else if (currentPractice.PracticeResult == PracticeResult.PartlyCorrect) { currentPractice.WrongInput = GetWrongInput(); // Do not change practice state number in this case if (!Settings.Default.UserEvaluates) { TbCorrectAnswer.Text = $"{Words.PartlyCorrect}! ({GetEvaluationAnswer()})"; TbCorrectAnswer.BackColor = Color.FromArgb(255, 215, 0); sound = Sounds.sound_correct; } } else // if (currentPractice.PracticeResult == PracticeResult.Wrong) { currentPractice.WrongInput = GetWrongInput(); currentWord.PracticeStateNumber = 1; if (!Settings.Default.UserEvaluates) { TbCorrectAnswer.Text = $"{Words.Wrong}! ({GetEvaluationAnswer()}"; TbCorrectAnswer.BackColor = Color.FromArgb(255, 192, 203); sound = Sounds.sound_wrong; } } // Sound playback player.Stop(); if (Settings.Default.PracticeSoundFeedback && sound != null) { player.Stream = sound; player.Play(); } //Nächste Vokabel vorbereiten index++; if (index < practiceList.Count) { currentPractice = practiceList[index]; currentWord = currentPractice.VocabularyWord; } //Zahlen aktualisieren RefreshStatistics(); check = false; solution = false; if (index == practiceList.Count) { BtnContinue.Text = Words.Finish; } }