private void appBarOkButton_Click(object sender, EventArgs e) { // Confirm there is some text in the text box. if (tbNewOriginWord.Text.Length > 0 && tbNewTranslateWord.Text.Length > 0) { // Create a new word. Word newWord = new Word { OriginWord = tbNewOriginWord.Text, TranslateWord = tbNewTranslateWord.Text, }; // Add the item to the ViewModel. ViewModel.AddWord(newWord); // Return to the main page. if (NavigationService.CanGoBack) { NavigationService.GoBack(); } } else { string errorMessages = "jjjj"; MessageBox.Show(errorMessages, "Warning: Invalid Values", MessageBoxButton.OK); } }
/// <summary> /// Updates the task provided by <see cref="GetTask"/> method. If update is impossibe, you should call Reset method. /// </summary> /// <returns></returns> public bool UpdateTask() { // check if iterator is initialized if(current != null) { current.EffortsNumber += 1; } // Origin is english if (allWordsForTrainSession.MoveNext()) { current = allWordsForTrainSession.Current; this.task.Initialized = true; var correctTranslation = current.TranslateWord; var translations = new string[numberOfTranslationSuggestions]; allTranslationsForTrainSession.Where(translation => translation != correctTranslation) .Take(numberOfTranslationSuggestions - 1).ToArray().CopyTo(translations, 0); translations[numberOfTranslationSuggestions - 1] = correctTranslation; translations = translations.OrderBy(_ => Guid.NewGuid()).ToArray(); this.task.UpdateFields(current.OriginWord, translations); return true; } else { // Works fine, I promise this.dictionary.SubmitChanges(); this.task.Initialized = false; return false; } }
public void AddWord(Word newWords) { // Add a word to the data context. dictionaryDB.Words.InsertOnSubmit(newWords); // Save changes to the database. dictionaryDB.SubmitChanges(); }
private double learningIndex(Word w) { // TODO: Add randomness return w.EffortsNumber + 2 * w.SuccessfulEffortsNumber + (new Random()).Next(-2, 2); }
public Word(Word previousWord) { System.Diagnostics.Debug.WriteLine("Word copy constructor called"); }
// Remove a word from the database and collections. public void DeleteWord(Word wordForDelete) { // Remove the word from the "all" observable collection. AllWords.Remove(wordForDelete); NeedableWord.Remove(wordForDelete); // Remove the word from the data context. // Remove the word from the appropriate category. switch (wordForDelete.isKnown()) { case true: KnownWords.Remove(wordForDelete); break; case false: UnKnownWords.Remove(wordForDelete); break; default: break; } dictionaryDB.Words.DeleteOnSubmit(wordForDelete); // Save changes to the database. dictionaryDB.SubmitChanges(); }