예제 #1
0
        public VMLearnWords(IMainWindowsCodeBehind codeBehind)
        {
            _codeBehind = codeBehind;
            _data       = new Data();

            LearnWord.LearnFirstWords(_data.GetDictionary, ref _sourseImage, ref _ukrWord, ref _englWord, ref _tranckWord);
        }
예제 #2
0
        public ActionResult AddToLearned(int fileId, string[] words)
        {
            _documentWords = new WordInfoXmlSource(ServerPath.MapDocumentPath(fileId.ToString()));
            _learnedWords  = new LearnedWordXmlSource(ServerPath.MapUserVocabularyPath(UserName));
            foreach (string word in words)
            {
                var wordInfo = _documentWords.Get(w => w.WordString == word);
                wordInfo.Status = Models.WordStatus.Learned;

                LearnWord outValue;
                bool      learned = _learnedWords.IsLearned(word, out outValue);

                if (learned)
                {
                    outValue.Documents.Add(fileId);
                }
                else
                {
                    outValue = new LearnWord {
                        WordString = word, Documents = new List <int> {
                            fileId
                        }
                    };
                    _learnedWords.Add(outValue);
                }
            }

            _documentWords.Save();
            _learnedWords.Save();
            return(RedirectToAction("Load", "Home", new { fileId = fileId }));
        }
예제 #3
0
        /// <summary>Inserts word to the user's vocabulary of learning words.</summary>
        /// <param name="word">Original word.</param>
        /// <param name="translation">Translation of the word.</param>
        /// <param name="userId">External user's identifier.</param>
        /// <returns>The count of changed elements in data storage.</returns>
        public int InsertLearnWord(string word, string translation, int userId)
        {
            var owner     = _accountService.GetByExternalId(userId);
            var learnWord = new LearnWord {
                Word = word, Translation = translation, Owner = owner, Type = VocabType.LearnWord
            };

            var existingLearnWord = _watchWordUnitOfWork.LearnWordsRepository.GetByСondition(
                l => l.Owner.Id == owner.Id && l.Word == word, l => l.Owner);

            var existingKnownWord = _watchWordUnitOfWork.KnownWordsRepository.GetByСondition(
                k => k.Owner.Id == owner.Id && k.Word == word, k => k.Owner);

            if (existingKnownWord != null)
            {
                // Delete translation from known words vocabulary if exist.
                _watchWordUnitOfWork.KnownWordsRepository.Delete(existingKnownWord.Id);
            }

            if (existingLearnWord != null)
            {
                // Update translation if word exist.
                existingLearnWord.Translation = translation;
                _watchWordUnitOfWork.LearnWordsRepository.Update(existingLearnWord);
            }
            else
            {
                // Insert if this a new word.
                _watchWordUnitOfWork.LearnWordsRepository.Insert(learnWord);
            }

            return(_watchWordUnitOfWork.Commit());
        }
        public static void pageDirects(string page)
        {
            if (!Form1.Instance.PnlContainer.Controls.ContainsKey(page))
            {
                Form1.Instance.PnlContainer.Controls.Clear();
                if ("AddWord" == page)
                {
                    AddWord aw = new AddWord();
                    aw.Dock = DockStyle.Fill;
                    Form1.Instance.PnlContainer.Controls.Add(aw);
                }
                if ("MainBase" == page)
                {
                    MainBase mb = new MainBase();
                    mb.Dock = DockStyle.Fill;
                    Form1.Instance.PnlContainer.Controls.Add(mb);
                }
                if ("LearnWord" == page)
                {
                    LearnWord ln = new LearnWord();
                    ln.Dock = DockStyle.Fill;
                    Form1.Instance.PnlContainer.Controls.Add(ln);
                }
                if ("Search" == page)
                {
                    Search sa = new Search();
                    sa.Dock = DockStyle.Fill;
                    Form1.Instance.PnlContainer.Controls.Add(sa);
                }
                if ("TabSignUp" == page)
                {
                    TabSignUp su = new TabSignUp();
                    su.Dock = DockStyle.Fill;
                    Form1.Instance.PnlContainer.Controls.Add(su);
                }
                if ("TabSign" == page)
                {
                    TabSign si = new TabSign();
                    si.Dock = DockStyle.Fill;
                    Form1.Instance.PnlContainer.Controls.Add(si);
                }
                if ("QuizPage" == page)
                {
                    QuizPage qp = new QuizPage();
                    qp.Dock = DockStyle.Fill;
                    Form1.Instance.PnlContainer.Controls.Add(qp);
                }
                if ("Statistics" == page)
                {
                    Statistics st = new Statistics();
                    st.Dock = DockStyle.Fill;
                    Form1.Instance.PnlContainer.Controls.Add(st);
                }
            }

            Form1.Instance.PnlContainer.Controls[page].BringToFront();
        }
예제 #5
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);
        }