public void SetNextStep(WordOfDictionary wrd)
 {
    
     // New word
     if (wrd.CurrentStepOfLearning == 0)
     {
         wrd.CurrentStepOfLearning = 1;
         wrd.DateOfRepetition = DateTime.Today;
     } else
     {
         StrategyItem item = GetStepByNumber(wrd.CurrentStepOfLearning + 1);
         if (item == null) return;
         wrd.CurrentStepOfLearning = item.number;
         wrd.DateOfRepetition = DateTime.Today.AddDays(item.interval_from_last_step);
     }
 }
Ejemplo n.º 2
0
        public WordOfDictionary AddOrUpdateWord(int outer_id,string str_word,string transcription,string picture_url ="",string sound_url="") {

            WordOfDictionary word = Words.Where(x => x.outer_id == outer_id).FirstOrDefault();
            bool isNewWord = word == null;

            if (isNewWord)
            {
                word = new WordOfDictionary { outer_id = outer_id };
                Words.Add(word);
            }
    
            if(word.CurrentStepOfLearning == 0) ViewModelLocator.Instance.AppSetting.LearningWordStrategy.SetNextStep(word);
           
            word.word = str_word;
            word.transcription = transcription;
            word.last_updated_at = DateTime.Today;
            word.pictures_url = picture_url;
            word.sound_url = sound_url;
            
            return word;
        }
Ejemplo n.º 3
0
 public void AddOrUpdateWord(WordOfDictionary currentWord)
 {
     string strWord = currentWord.word.ToLower();
     WordOfDictionary searchedWord = Words.Where(x => x.word.ToLower() == strWord).FirstOrDefault();
     if (searchedWord == null)
     {
         Words.Add(currentWord);
     }
     else
     {
         throw new NotImplementedException();
     }    
 }
Ejemplo n.º 4
0
 public bool ContainsLearnedWord(WordOfDictionary wrd)
 {
     return ContainsLearnedWord(wrd.word);
 }
Ejemplo n.º 5
0
 public void DeleteWord(WordOfDictionary wrd)
 {
     Words.Remove(wrd);
     EFDbContext.SaveChgs();
 }
Ejemplo n.º 6
0
 public WordOfDictionary GetWord(string word_,bool SetDefaultTranslationForNewWords = false)
 {
     WordOfDictionary wrd = Words.FirstOrDefault(x => x.word == word_);
     if(wrd == null)
     {
         LinguaLeoAPI.TranslateAPIResponse res = LinguaLeoAPI.TranslateWord_withoutlogin(word_);
         wrd = new WordOfDictionary(word_,res);
         if (SetDefaultTranslationForNewWords && wrd.translations.Count > 0)
         {
             wrd.translation_as_string = wrd.translations.OrderByDescending(x => x.votes).First().translation;
             wrd.translations[0].selected = true;
             wrd.translations[0].index_of_selection = 1;
         }
         Application.Current.Dispatcher.Invoke(()=> { Words.Add(wrd); EFDbContext.SaveChgs();});
         //Words.Add(wrd);
         //EFDbContext.SaveChgs();
     }
     return wrd;
 }
Ejemplo n.º 7
0
 public void AddLearnedWord(WordOfDictionary word) {
     string word_str = word.word.ToLower();
     if (!ContainsLearnedWord(word)) LearnedWords.Add(new LearnedWord() { word = word_str});
 }
 private void CurrentDictionary_Cmd(WordOfDictionary wrd,string cmd)
 {
     string hello = "world";
 }
 private void SpeechItem_Cmd(WordOfDictionary word)
 {
     WMPLib.WindowsMediaPlayer wmp = new WMPLib.WindowsMediaPlayer();
     wmp.URL = word.sound_url;
     //wmp.settings.volume = LearningItem.SpeechVolume;
     wmp.controls.play();
 }
        public WordsTranslation_ViewModel(INavigationService NavigationService_,IDialogService DialogService_,AppSetting AppSetting_)
        {
            if (IsInDesignMode)
            {
                mode = Mode.Edit;
            }

            if (!IsInDesignMode)
            {
                NavigationService = NavigationService_;
                DialogService = DialogService_;
                AppSetting = AppSetting_;

                Statuses = WordOfDictionary.WordStatuses.Statuses;
            }

            ExecuteCommand = new RelayCommand<string>(CommandDispatcher);
            PressWordButton_Command = new RelayCommand<ButtonModel>(PressWordButton_Cmd);

            WordsForSelection_Buttons = new ObservableCollection<ButtonModel>(); 

            btnNextButton = new ButtonModel();
            btnPreviousButton = new ButtonModel();
            btnAddToDictionary = new ButtonModel();
            btnSkip = new ButtonModel();
            WordsCollection_ListModel = new List_Model();
            btnTrainingNext = new ButtonModel();
            btnOk = new ButtonModel();

            if (IsInDesignMode)
            {
                CurrentWord = new WordOfDictionary();
                CurrentWord.word = "White";
                CurrentWord.translation_as_string = "Белый";
                CurrentWord.transcription = "[wʌɪt]";
                //CurrentWord.commentary = "{Белый цвет, не черный, не зеленый, а именно белый. \nСовершенно белый.\nНу может с желтоватым отливом}";
                CurrentWord.pictures_url = "http://d144fqpiyasmrr.cloudfront.net/uploads/picture/295623.png";

                CurrentWord.translations.Add(new TranslationOfWord() {translation="белый",votes=150 });
                CurrentWord.translations.Add(new TranslationOfWord() {translation="беловатый",votes=50 });
                CurrentWord.translations.Add(new TranslationOfWord() {translation="беленький, беловатый, бледноватный, беловатенькая, серобуромалиновенькая, ярко белая в крапинку",votes=15 });

                WordsForSelection_Buttons.Add(new ButtonModel() { Text="Зелёный"});
                WordsForSelection_Buttons.Add(new ButtonModel() { Text="Белый"});
                WordsForSelection_Buttons.Add(new ButtonModel() { Text="Черный"});
                WordsForSelection_Buttons.Add(new ButtonModel() { Text="Пурпурный"});
                WordsForSelection_Buttons.Add(new ButtonModel() { Text="Фиолетовый"});

                WordsCollection = new ObservableCollection<WordOfDictionary>();
                WordsCollection.Add(new WordOfDictionary() {word = "everybody"});
                WordsCollection.Add(new WordOfDictionary() {word = "likes"});
                WordsCollection.Add(new WordOfDictionary() {word = "cakes"});

                Header_LabelModel.Text = "This is a Header";

                SetCurrentWord(CurrentWord);
            }

        }
        public void SetCurrentWord(WordOfDictionary item)
        {

            if (CurrentWord != null)  CurrentWord.PropertyChanged -= CurrentWord_PropertyChanged;

            CurrentWord = item;
            if (!IsInDesignMode)
            {
                CommandDispatcher("SpeechItem");
            }
            CurrentWord.PropertyChanged += CurrentWord_PropertyChanged;


            // default setting
            btnOk.Visibility = Visibility.Collapsed;
            TranslationsPanel_Visibility = Visibility.Collapsed;
            ImagesList_Visibility = Visibility.Collapsed;

            EditModeVisibility = Visibility.Collapsed;

            bool Testing = false;
            switch (mode)
            {
                case Mode.FoundNewWord:
                    Header_LabelModel.Text = Tx.T("WordsTranslation.Caption.NewWordsFound");
                    Testing = LearningItem.TestingUnderstandingNewWords;
                    btnTrainingNext.Visibility = Visibility.Collapsed;
                    ImagePanelVisibility = Testing ? Visibility.Collapsed : Visibility.Visible;
                    WordsButtonPanelVisibility = Testing ? Visibility.Visible : Visibility.Collapsed;
                    TranslatingVisibility = Testing ? Visibility.Hidden : Visibility.Visible;
                    BottomButtonsPanelVisibility = Testing ? Visibility.Collapsed : Visibility.Visible;
                    break;

                case Mode.Training:
                    Header_LabelModel.Text = Tx.T("WordsTranslation.Caption.Training");
                    Testing = true;
                    btnTrainingNext.Visibility = Visibility.Hidden;
                    ImagePanelVisibility = Visibility.Hidden;
                    WordsButtonPanelVisibility = Visibility.Visible;
                    TranslatingVisibility = Visibility.Hidden;
                    BottomButtonsPanelVisibility = Visibility.Collapsed;
                    WordsCollection_ListModel.Visibility = Visibility.Visible;
                    btnPreviousButton.Visibility = Visibility.Collapsed;
                    btnNextButton.Visibility = Visibility.Collapsed;
                    break;

                case Mode.WordTranslation:
                    Header_LabelModel.Text = Tx.T("WordsTranslation.Caption.Translation");
                    Testing = false;
                    btnTrainingNext.Visibility = Visibility.Visible;
                    btnPreviousButton.Visibility = Visibility.Hidden;
                    btnNextButton.Visibility = Visibility.Hidden;
                    WordsCollection_ListModel.Visibility = Visibility.Visible;
                    break;

                case Mode.Edit:
                    btnPreviousButton.Visibility = Visibility.Collapsed;
                    btnNextButton.Visibility = Visibility.Collapsed;
                    WordsCollection_ListModel.Visibility = Visibility.Collapsed;
                    btnOk.Visibility = Visibility.Visible;
                    BottomButtonsPanelVisibility = Visibility.Collapsed;
                    WordsButtonPanelVisibility = Visibility.Collapsed;
                    btnTrainingNext.Visibility = Visibility.Collapsed;
                    TranslatingVisibility = Visibility.Collapsed;
                    TranslationsPanel_Visibility = Visibility.Visible;
                    ImagesList_Visibility = Visibility.Visible;
                    EditModeVisibility = Visibility.Visible;
                    break;

                default:
                    throw new NotImplementedException();
            }

            /*
            btnSkip.Visibility = Visibility.Visible;
            if(Testing)
            {
                btnPreviousButton.Visibility = Visibility.Hidden;
                btnNextButton.Visibility = Visibility.Hidden;
                WordsCollection_ListModel.Visibility = Visibility.Visible;
            } else
            {
                WordsCollection_ListModel.Visibility = Visibility.Collapsed;
                btnNextButton.Visibility = idx < WordsCollection.Count - 1 ? Visibility.Visible : Visibility.Hidden;
                btnPreviousButton.Visibility = idx > 0 ? Visibility.Visible : Visibility.Hidden;
            }
            */

            if (IsInDesignMode) return;

            if (Testing)
            {
                PhraseOfCollectMode phrase = new PhraseOfCollectMode();
                PhraseOfCollectMode.Word trueword = new PhraseOfCollectMode.Word() { word = CurrentWord.translation_as_string };
                phrase.Words.Add(trueword);

                if(CurrentWord.translation_as_string.Length > 0)
                {
                    ObservableCollection<FrequencyDictionary.Item> coll = CurrentWord.Dictionary.SecondaryLanguage.FrequencyDictionary.GetRndWords(4);
                    foreach(var elm in coll)
                    {
                        phrase.Words.Add(new PhraseOfCollectMode.Word() { word = elm.Lemma});
                    }
                } else throw new NotImplementedException("err");

                WordsForSelection_Buttons.Clear();
                phrase.StartRandomSelection();
                for (int i = 0; i < phrase.Words.Count; i++)
                {
                    PhraseOfCollectMode.Word word = phrase.GetNextRandom();
                    WordsForSelection_Buttons.Add(new ButtonModel() { Text=word.word, WordOfButton = word,IsItTrue = word == trueword});
                }
            }
        }
Ejemplo n.º 12
0
 public List<SubtitleItem.Word> GetRelatedSubtitlesWords(WordOfDictionary word)
 {
     return EFDbContext.DataBase.SubtitleItem_Words.SqlQuery("select * from Subtitles_Items_Words where word_of_dictionary_id='"+word.id+"'").ToList(); 
 }