void basicLanguage_KeyDown(object sender, KeyEventArgs e) { //event for single group if (e.Key == Key.Enter) { if (this.type == 1) { if (words.Count != 0) { Word current = words.ElementAt<Word>(indexOfCurrentWord); lastWord = current; if ((basicLanguage.Text.Equals(current.Foregin, StringComparison.OrdinalIgnoreCase) && selectedType == 0) || (basicLanguage.Text.Equals(current.Basic, StringComparison.OrdinalIgnoreCase) && selectedType == 1)) { words.Remove(current); if (words.Count > 0) { progressBar1.Value++; goodAnsv.Content = (int)goodAnsv.Content + 1; Random r = new Random(); indexOfCurrentWord = r.Next(0, words.Count); foreginWord.Text = selectedType == 0 ? words.ElementAt<Word>(indexOfCurrentWord).Basic : words.ElementAt<Word>(indexOfCurrentWord).Foregin; lastForeign.Text = lastWord.Basic; lastBasic.Text = lastWord.Foregin; lastForeign.Visibility = Visibility.Visible; lastBasic.Visibility = Visibility.Visible; label6.Visibility = Visibility.Visible; label7.Visibility = Visibility.Visible; } else { //SqlAccess sql = new SqlAccess(); //sql.UpdateStats(new Result(selectedGroups, (int)goodAnsv.Content, (int)badAnsv.Content, DateTime.Now.Subtract(ts))); this.Close(); ShowResult(); } } else { bad.Add(words.ElementAt<Word>(indexOfCurrentWord)); badAnsv.Content = (int)badAnsv.Content + 1; Random r = new Random(); indexOfCurrentWord = r.Next(0, words.Count); foreginWord.Text = selectedType == 0 ? words.ElementAt<Word>(indexOfCurrentWord).Basic : words.ElementAt<Word>(indexOfCurrentWord).Foregin; lastForeign.Text = lastWord.Basic; lastBasic.Text = lastWord.Foregin; lastForeign.Visibility = Visibility.Visible; lastBasic.Visibility = Visibility.Visible; label6.Visibility = Visibility.Visible; label7.Visibility = Visibility.Visible; } basicLanguage.Text = ""; } else { MessageBox.Show("Wybrana grupa nie ma slowek."); } } else if (this.type == 2) { if (words.Count != 0) { Word current = words.ElementAt<Word>(indexOfCurrentWord); lastWord = current; if ((basicLanguage.Text.Equals(current.Foregin, StringComparison.OrdinalIgnoreCase) && selectedType == 0) || (basicLanguage.Text.Equals(current.Basic, StringComparison.OrdinalIgnoreCase) && selectedType == 1)) { words.Remove(current); if (words.Count > 0) { progressBar1.Value++; goodAnsv.Content = (int)goodAnsv.Content + 1; Random r = new Random(); indexOfCurrentWord = r.Next(0, words.Count); foreginWord.Text = selectedType == 0 ? words.ElementAt<Word>(indexOfCurrentWord).Basic : words.ElementAt<Word>(indexOfCurrentWord).Foregin; words.Remove(current); lastForeign.Text = lastWord.Basic; lastBasic.Text = lastWord.Foregin; lastForeign.Visibility = Visibility.Visible; lastBasic.Visibility = Visibility.Visible; label6.Visibility = Visibility.Visible; label7.Visibility = Visibility.Visible; } else { SqlAccess sql = new SqlAccess(); sql.UpdateStats(new Result(selectedGroups, (int)goodAnsv.Content, (int)badAnsv.Content, DateTime.Now.Subtract(ts))); this.Close(); ShowResult(); } } else { bad.Add(words.ElementAt<Word>(indexOfCurrentWord)); words.Remove(current); if (words.Count > 0) { progressBar1.Value++; badAnsv.Content = (int)badAnsv.Content + 1; Random r = new Random(); indexOfCurrentWord = r.Next(0, words.Count); foreginWord.Text = selectedType == 0 ? words.ElementAt<Word>(indexOfCurrentWord).Basic : words.ElementAt<Word>(indexOfCurrentWord).Foregin; lastForeign.Text = lastWord.Basic; lastBasic.Text = lastWord.Foregin; lastForeign.Visibility = Visibility.Visible; lastBasic.Visibility = Visibility.Visible; label6.Visibility = Visibility.Visible; label7.Visibility = Visibility.Visible; } else { SqlAccess sql = new SqlAccess(); sql.UpdateStats(new Result(selectedGroups, (int)goodAnsv.Content, (int)badAnsv.Content, DateTime.Now.Subtract(ts))); this.Close(); ShowResult(); } } basicLanguage.Text = ""; } else { MessageBox.Show("Wybrana grupa nie ma slowek."); } } else if (this.type == 3) { MessageBox.Show("3"); if (words.Count != 0) { Word current = words.ElementAt<Word>(indexOfCurrentWord); lastWord = current; if ((basicLanguage.Text.Equals(current.Foregin, StringComparison.OrdinalIgnoreCase) && selectedType == 0) || (basicLanguage.Text.Equals(current.Basic, StringComparison.OrdinalIgnoreCase) && selectedType == 1)) { words.Remove(current); if (words.Count > 0) { progressBar1.Value++; goodAnsv.Content = (int)goodAnsv.Content + 1; Random r = new Random(); indexOfCurrentWord = r.Next(0, words.Count); foreginWord.Text = selectedType == 0 ? words.ElementAt<Word>(indexOfCurrentWord).Basic : words.ElementAt<Word>(indexOfCurrentWord).Foregin; lastForeign.Text = lastWord.Basic; lastBasic.Text = lastWord.Foregin; lastForeign.Visibility = Visibility.Visible; lastBasic.Visibility = Visibility.Visible; label6.Visibility = Visibility.Visible; label7.Visibility = Visibility.Visible; } else { //SqlAccess sql = new SqlAccess(); //sql.UpdateStats(new Result(selectedGroups, (int)goodAnsv.Content, (int)badAnsv.Content, DateTime.Now.Subtract(ts))); this.Close(); ShowResult(); } } else { bad.Add(words.ElementAt<Word>(indexOfCurrentWord)); badAnsv.Content = (int)badAnsv.Content + 1; Random r = new Random(); indexOfCurrentWord = r.Next(0, words.Count); foreginWord.Text = selectedType == 0 ? words.ElementAt<Word>(indexOfCurrentWord).Basic : words.ElementAt<Word>(indexOfCurrentWord).Foregin; lastForeign.Text = lastWord.Basic; lastBasic.Text = lastWord.Foregin; lastForeign.Visibility = Visibility.Visible; lastBasic.Visibility = Visibility.Visible; label6.Visibility = Visibility.Visible; label7.Visibility = Visibility.Visible; } basicLanguage.Text = ""; } else MessageBox.Show("Wybrana grupa nie ma dodanych slow."); } } }
void basicLanguageMultiple_KeyDown(object sender, KeyEventArgs e) { //event for multiplie selected groups if (e.Key == Key.Enter) { //something smart to recognize which word is connected to which group and save pos/neg ansv. if (this.type == 1) { if (words.Count != 0) { Word current = words.ElementAt<Word>(indexOfCurrentWord); if ((basicLanguage.Text.Equals(current.Foregin, StringComparison.OrdinalIgnoreCase) && selectedType == 0) || (basicLanguage.Text.Equals(current.Basic, StringComparison.OrdinalIgnoreCase) && selectedType == 1)) { words.Remove(current); lastWord = current; if (words.Count > 0) { progressBar1.Value++; goodAnsv.Content = (int)goodAnsv.Content + 1; Random r = new Random(); indexOfCurrentWord = r.Next(0, words.Count); foreginWord.Text = selectedType == 0 ? words.ElementAt<Word>(indexOfCurrentWord).Basic : words.ElementAt<Word>(indexOfCurrentWord).Foregin; lastForeign.Text = lastWord.Basic; lastBasic.Text = lastWord.Foregin; lastForeign.Visibility = Visibility.Visible; lastBasic.Visibility = Visibility.Visible; label6.Visibility = Visibility.Visible; label7.Visibility = Visibility.Visible; } else { //SqlAccess sql = new SqlAccess(); //sql.UpdateStats(new Result(selectedGroups, (int)goodAnsv.Content, (int)badAnsv.Content, DateTime.Now.Subtract(ts))); this.Close(); ShowResult(); } } else { bad.Add(words.ElementAt<Word>(indexOfCurrentWord)); badAnsv.Content = (int)badAnsv.Content + 1; Random r = new Random(); indexOfCurrentWord = r.Next(0, words.Count); foreginWord.Text = selectedType == 0 ? words.ElementAt<Word>(indexOfCurrentWord).Basic : words.ElementAt<Word>(indexOfCurrentWord).Foregin; lastForeign.Text = lastWord.Basic; lastBasic.Text = lastWord.Foregin; lastForeign.Visibility = Visibility.Visible; lastBasic.Visibility = Visibility.Visible; label6.Visibility = Visibility.Visible; label7.Visibility = Visibility.Visible; } basicLanguage.Text = ""; } else { MessageBox.Show("Wybrana grupa nie ma slowek."); } } else if (this.type == 2) { if (words.Count != 0) { Word current = words.ElementAt<Word>(indexOfCurrentWord); if ((basicLanguage.Text.Equals(current.Foregin, StringComparison.OrdinalIgnoreCase) && selectedType == 0) || (basicLanguage.Text.Equals(current.Basic, StringComparison.OrdinalIgnoreCase) && selectedType == 1)) { words.Remove(current); lastWord = current; if (words.Count > 0) { progressBar1.Value++; goodAnsv.Content = (int)goodAnsv.Content + 1; Result currResult = groupsWithResult[ selectedGroups.ElementAt<Group>(selectedGroups.IndexOf( Group.getFromID(current.Id_group)))]; currResult.positiveAnsw++; Random r = new Random(); indexOfCurrentWord = r.Next(0, words.Count); foreginWord.Text = selectedType == 0 ? words.ElementAt<Word>(indexOfCurrentWord).Basic : words.ElementAt<Word>(indexOfCurrentWord).Foregin; lastForeign.Text = lastWord.Basic; lastBasic.Text = lastWord.Foregin; lastForeign.Visibility = Visibility.Visible; lastBasic.Visibility = Visibility.Visible; label6.Visibility = Visibility.Visible; label7.Visibility = Visibility.Visible; words.Remove(current); } else { SqlAccess sql = new SqlAccess(); sql.UpdateStats(groupsWithResult, DateTime.Now.Subtract(ts)); this.Close(); ShowResult(); } } else { bad.Add(words.ElementAt<Word>(indexOfCurrentWord)); words.Remove(current); if (words.Count > 0) { Result currResult = groupsWithResult[selectedGroups.ElementAt<Group>(selectedGroups.IndexOf(Group.getFromID(current.Id_group)))]; currResult.negativeAnsw++; progressBar1.Value++; badAnsv.Content = (int)badAnsv.Content + 1; Random r = new Random(); indexOfCurrentWord = r.Next(0, words.Count); foreginWord.Text = selectedType == 0 ? words.ElementAt<Word>(indexOfCurrentWord).Basic : words.ElementAt<Word>(indexOfCurrentWord).Foregin; lastForeign.Text = lastWord.Basic; lastBasic.Text = lastWord.Foregin; lastForeign.Visibility = Visibility.Visible; lastBasic.Visibility = Visibility.Visible; label6.Visibility = Visibility.Visible; label7.Visibility = Visibility.Visible; } else { SqlAccess sql = new SqlAccess(); sql.UpdateStats(groupsWithResult, DateTime.Now.Subtract(ts)); this.Close(); ShowResult(); } } basicLanguage.Text = ""; } else { MessageBox.Show("Wybrana grupa nie ma slowek."); } } else if (this.type == 3) { if (words.Count != 0) { Word current = words.ElementAt<Word>(indexOfCurrentWord); if ((basicLanguage.Text.Equals(current.Foregin, StringComparison.OrdinalIgnoreCase) && selectedType == 0) || (basicLanguage.Text.Equals(current.Basic, StringComparison.OrdinalIgnoreCase) && selectedType == 1)) { words.Remove(current); lastWord = current; if (words.Count > 0) { progressBar1.Value++; goodAnsv.Content = (int)goodAnsv.Content + 1; Random r = new Random(); indexOfCurrentWord = r.Next(0, words.Count); foreginWord.Text = selectedType == 0 ? words.ElementAt<Word>(indexOfCurrentWord).Basic : words.ElementAt<Word>(indexOfCurrentWord).Foregin; lastForeign.Text = lastWord.Basic; lastBasic.Text = lastWord.Foregin; lastForeign.Visibility = Visibility.Visible; lastBasic.Visibility = Visibility.Visible; label6.Visibility = Visibility.Visible; label7.Visibility = Visibility.Visible; } else { //SqlAccess sql = new SqlAccess(); //sql.UpdateStats(new Result(selectedGroups, (int)goodAnsv.Content, (int)badAnsv.Content, DateTime.Now.Subtract(ts))); this.Close(); ShowResult(); } } else { bad.Add(words.ElementAt<Word>(indexOfCurrentWord)); badAnsv.Content = (int)badAnsv.Content + 1; Random r = new Random(); indexOfCurrentWord = r.Next(0, words.Count); foreginWord.Text = selectedType == 0 ? words.ElementAt<Word>(indexOfCurrentWord).Basic : words.ElementAt<Word>(indexOfCurrentWord).Foregin; lastForeign.Text = lastWord.Basic; lastBasic.Text = lastWord.Foregin; lastForeign.Visibility = Visibility.Visible; lastBasic.Visibility = Visibility.Visible; label6.Visibility = Visibility.Visible; label7.Visibility = Visibility.Visible; } basicLanguage.Text = ""; } else MessageBox.Show("Wybrana grupa nie ma dodanych slow."); } } }