コード例 #1
0
 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);
 }
コード例 #2
0
        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);
        }
コード例 #3
0
        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();
        }
コード例 #4
0
ファイル: TextToSpeech.cs プロジェクト: peter-popov/manywords
        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);
            }
        }
コード例 #5
0
        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);
        }
コード例 #6
0
 public PlaySound(Word w, TextToSpeech tts)
 {
     this.tts = tts;
     this.word = w;
 }
コード例 #7
0
 public SpellingExercise(Word word)
 {
     Word = word.Spelling;
     Translation = word.getTranslation(App.LanguagesListModel.MotherLanguage.Code);
 }
コード例 #8
0
 public SkipWord(Word w)
 {
     this.word = w;
 }
コード例 #9
0
 public LearnWord(Word w)
 {
     this.word = w;
     this.Result = ExerciseResult.Ignore;
 }
コード例 #10
0
 protected Translation selectCorectTranslation(Word w)
 {
     var list = WordsSelector.takeRandom(w.Translations.Where(x => x.Language == App.LanguagesListModel.MotherLanguage.Code));
     return list.FirstOrDefault();
 }
コード例 #11
0
ファイル: Vocabulary.cs プロジェクト: peter-popov/manywords
 private void detach_vocabulary(Word entity)
 {
     NotifyPropertyChanging("Words");
     entity.Vocabulary = null;
 }
コード例 #12
0
ファイル: Vocabulary.cs プロジェクト: peter-popov/manywords
 private void attach_vocabulary(Word entity)
 {
     NotifyPropertyChanging("Words");
     entity.Vocabulary = this;
 }