public WordListItemModel(Word w, TextToSpeech tts) { this.word = w; w.PropertyChanged += new PropertyChangedEventHandler(w_PropertyChanged); this.translation = w.getTranslation(App.LanguagesListModel.MotherLanguage.Code); playCmd = new PlaySound(word, tts); }
public NewWordExercise(Word word) { OnSkip = new SkipWord(word); OnLearn = new LearnWord(word); Word = word.Spelling; Translation = word.getTranslation(App.LanguagesListModel.MotherLanguage.Code); playSound = new PlaySound(word, App.TextToSpeech); }
public void Import(string filePath) { Vocabulary v = findOrCreate(); StreamReader sr = new StreamReader(filePath); string line; Console.WriteLine("Creating database objects..."); while ((line = sr.ReadLine()) != null) { var row = line.Split('$'); int pos = languageFrom.Item2; string spelling = row[pos].Trim(); if (spelling == "") { continue; } var translations = new List<Tuple<string, string>>(); foreach (var lng in languagesTo) { pos = lng.Item2; if ( pos >= row.Length ) { translations.Clear(); break; } translations.Add(Tuple.Create(lng.Item1, row[pos])); } if (translations.Count == 0) { Console.WriteLine("Warning: {0} - word ignored, no translations found", spelling); continue; } Word item = new Word { Spelling = spelling, Added = DateTime.Now, State = State.New}; database.Words.InsertOnSubmit(item); v.Words.Add(item); foreach (var t in translations) { if (t.Item2.Trim().Length == 0) continue; Translation tr = new Translation { Spelling = t.Item2, Language = t.Item1 }; item.Translations.Add(tr); database.Translations.InsertOnSubmit(tr); } } Console.WriteLine("Submiting changes..."); database.SubmitChanges(); }
public void Speak(Word word) { if (lastText != null && lastText == word.Spelling && audioCache != null) { playBuffer(new MemoryStream(audioCache)); return; } Stream s = App.WordStorage.GetSpeachAudioStream(word); if (s != null) { playBuffer(s); } else { translator.StartSpeach(clearWord(word.Spelling), CurrentLanguage, word); lastText = clearWord(word.Spelling); } }
public BackwardChoiceExercise(Word word) { var translation = selectCorectTranslation(word); Question = new ChoiceQuestion { Text = translation.Spelling }; var wordSelector = new WordsSelector(App.WordStorage, null); var words = wordSelector.SelectWordsForTranslation(translation, 3) .Select(x=>new ChoiceAnswer { Text = x.Spelling, IsCorrect = false }) .ToList(); correctAnswer = new ChoiceAnswer { Text = word.Spelling, IsCorrect = true }; words.Add(correctAnswer); foreach (var answer in WordsSelector.takeRandom(words)) { Answers.Add(answer); } playSound = new PlaySound(word, App.TextToSpeech); }
public PlaySound(Word w, TextToSpeech tts) { this.tts = tts; this.word = w; }
public SpellingExercise(Word word) { Word = word.Spelling; Translation = word.getTranslation(App.LanguagesListModel.MotherLanguage.Code); }
public SkipWord(Word w) { this.word = w; }
public LearnWord(Word w) { this.word = w; this.Result = ExerciseResult.Ignore; }
protected Translation selectCorectTranslation(Word w) { var list = WordsSelector.takeRandom(w.Translations.Where(x => x.Language == App.LanguagesListModel.MotherLanguage.Code)); return list.FirstOrDefault(); }
private void detach_vocabulary(Word entity) { NotifyPropertyChanging("Words"); entity.Vocabulary = null; }
private void attach_vocabulary(Word entity) { NotifyPropertyChanging("Words"); entity.Vocabulary = this; }