コード例 #1
0
        public override WordOfDictionary TranslateWord(string word,Language SourceLang,Language TargetLang)
        {
            
            WordOfDictionary WordOfDictionary = new WordOfDictionary();

            LinguaLeoAPI.TranslateAPIResponse resp = api.TranslateWord_withoutlogin(word);

            WordOfDictionary.word_of_dictionary = word;
            WordOfDictionary.outer_id = resp.word_id;
            WordOfDictionary.transcription = resp.transcription;
            WordOfDictionary.sound_url = resp.sound_url;
            WordOfDictionary.pictures_url = resp.pic_url;

            foreach(var elm in resp.translate)
            {
                TranslationOfWord tr = new TranslationOfWord();
                tr.external_id = elm.id;
                tr.Translation = elm.value;
                tr.Votes = elm.votes;
                //tr.picture_url = elm.pic_url;
                tr.SetPictureUrl(elm.pic_url);

                WordOfDictionary.translations.Add(tr);
            }

            if (WordOfDictionary.translations.Count > 0)
            {
                WordOfDictionary.translation_as_string = WordOfDictionary.translations.OrderByDescending(x => x.Votes).First().Translation;
                WordOfDictionary.translations[0].Selected = true;
                WordOfDictionary.translations[0].Index_of_selection = 1;
            }

            return WordOfDictionary;
        }
コード例 #2
0
        public void FindWord()
        {

            string db_name = "Dictionary_FindWord.db"; 

            EFDbContext db;
            db = RecreateDB(db_name);

            Dictionary dic = new Dictionary();
            db.AddNewItemToDBContext(dic);

            WordOfDictionary wrd0 = new WordOfDictionary();
            wrd0.word_of_dictionary = "Test";
            dic.Words.Add(wrd0);

            WordOfDictionary wrd1 = new WordOfDictionary();
            wrd1.word_of_dictionary = "I am";

            wrd1.AddForm("I'm");
            Assert.IsTrue(wrd1.Forms == "[i'm]");

            wrd1.RemoveForm("I'm");
            Assert.IsTrue(wrd1.Forms == "");

            wrd1.AddForm("I'm");
            dic.Words.Add(wrd1);

            WordOfDictionary wrd2 = new WordOfDictionary();
            wrd2.word_of_dictionary = "Hello";
            dic.Words.Add(wrd2);

            db.SaveChanges();
            db.Close();


            db = ConnectToDb(db_name);
            dic = db.FirstOrDefault<Dictionary>();

            WordOfDictionary fwrd = dic.FindWord("I'm");
            Assert.IsTrue(fwrd.word_of_dictionary == "I am");

            fwrd = dic.FindWord("I am");
            Assert.IsTrue(fwrd.word_of_dictionary == "I am");

            db.Close();

        }
コード例 #3
0
        public ReferencesToWord_ViewModel(
            ILogger Logger_, 
            INavigationService NavigationService_,
            EFDbContext EFDbContext_,
            IDialogService DialogService_,
            ILocalization Tx_
            )
        {
            if (!IsInDesignMode)
            {
                Logger = Logger_;
                NavigationService = NavigationService_;
                EFDbContext =EFDbContext_;
                DialogService = DialogService_;
                Tx = Tx_;

                CommandDispatcher = new MvxCommand<string>(CmdDispatcher);

                References = new ObservableCollection<ReferenceToWordOfDictionary>();
            }

            ClearButton = new ButtonModel();
                      

            if (IsInDesignMode)
            {
                Word = new WordOfDictionary { word_of_dictionary = "I'm" };

                LearningItem li1 = new LearningItem { Name = "Mazzy collection" };
                LearningItem li2 = new LearningItem { Name = "Futurama season 1" };

                Subtitles st1 = new Subtitles { Name = "English - Russian" };
                Subtitles st2 = new Subtitles { Name = "English - Ukraine" };

                References = new ObservableCollection<ReferenceToWordOfDictionary>()
                {
                    new ReferenceToWordOfDictionary {LearningItem = li1, Subtitles = st1,SubtitleItem =  new SubtitleItem { Text = "I'm Mazzy"},WordOfSubtitleItem = new WordOfSubtitleItem { word = "I'm"} },
                    new ReferenceToWordOfDictionary {LearningItem = li1, Subtitles = st1, SubtitleItem = new SubtitleItem { Text = "I am princess Sylvia" } ,WordOfSubtitleItem = new WordOfSubtitleItem { word = "I am"}},
                    new ReferenceToWordOfDictionary {LearningItem = li2, Subtitles = st2, SubtitleItem = new SubtitleItem { Text = "I'm Nibbler" } ,WordOfSubtitleItem = new WordOfSubtitleItem { word = "I'm"}}
                };

            }

        }
コード例 #4
0
        EFDbConnect CreateDemoBase(string db_name)
        {
            string path = PathToDb(db_name);
            if (File.Exists(path))
            {
                File.Delete(path);
            }

            ILogger ILoggerMock = Mock.Of<ILogger>();
            ISQLitePlatform platf = new SQLitePlatformWin32();
            EFDbConnect EFDbConnect = new EFDbConnect(platf, path);

            EFDbContext ctx = new EFDbContext(EFDbConnect);

            LearningItem li1 = new LearningItem();
            li1.Name = "First";
            ctx.AddNewItemToDBContext(li1);
            LearningItem li2 = new LearningItem();
            li2.Name = "Second";
            ctx.AddNewItemToDBContext(li2);


            // Audio tracks
            AudioTrack at1 = new AudioTrack();
            li1.AudioTracks.Add(at1);

            AudioTrack at2 = new AudioTrack();
            li1.AudioTracks.Add(at2);

            AudioTrack at3 = new AudioTrack();
            li2.AudioTracks.Add(at3);

            // Frequency dictionary
            FrequencyDictionary fd1 = new FrequencyDictionary();
            FrequencyDictionary fd2 = new FrequencyDictionary();

            FrequencyDictionary.Item fdi1 = new FrequencyDictionary.Item();
            fd1.Items.Add(fdi1);
            FrequencyDictionary.Item fdi2 = new FrequencyDictionary.Item();
            fd1.Items.Add(fdi2);

            FrequencyDictionary.Item fdi3 = new FrequencyDictionary.Item();
            fd2.Items.Add(fdi3);
            FrequencyDictionary.Item fdi4 = new FrequencyDictionary.Item();
            fd2.Items.Add(fdi4);

            // Languages
            Language lang1 = new Language();
            lang1.FrequencyDictionary = fd1;

            Language lang2 = new Language();
            lang2.FrequencyDictionary = fd2;

            Subtitles sub1 = new Subtitles();
            li1.SubtitleCollection.Add(sub1);
            sub1.SecondaryLanguage = lang1;

            Subtitles sub2 = new Subtitles();
            li1.SubtitleCollection.Add(sub2);


            SubtitleItem si1 = new SubtitleItem();
            sub1.Items.Add(si1);
            SubtitleItem si2 = new SubtitleItem();
            sub1.Items.Add(si2);

            SubtitleItem si3 = new SubtitleItem();
            sub2.Items.Add(si3);
            SubtitleItem si4 = new SubtitleItem();
            sub2.Items.Add(si4);

            Subtitles sub3 = new Subtitles();
            li2.SubtitleCollection.Add(sub3);
            sub3.SecondaryLanguage = lang2;

            SubtitleItem si5 = new SubtitleItem();
            sub3.Items.Add(si5);


            WordOfSubtitleItem sw1 = new WordOfSubtitleItem();
            si1.WordsCollection.Add(sw1); 

            WordOfSubtitleItem sw2 = new WordOfSubtitleItem();
            si1.WordsCollection.Add(sw2); 

            WordOfSubtitleItem sw3 = new WordOfSubtitleItem();
            si5.WordsCollection.Add(sw3);



            // Dictionary
            Dictionary dic1 = new Dictionary();
            ctx.AddNewItemToDBContext(dic1);

            WordOfDictionary wd1 = new WordOfDictionary();
            dic1.Words.Add(wd1);

            TranslationOfWord tw1 = new TranslationOfWord();
            wd1.translations.Add(tw1);
            
            TranslationOfWord tw2 = new TranslationOfWord();
            wd1.translations.Add(tw2);

            WordOfDictionary wd2 = new WordOfDictionary();
            dic1.Words.Add(wd2);
            sw1.word_of_dictionary = wd1;
            sw2.word_of_dictionary = wd2;

            Dictionary dic2 = new Dictionary();
            ctx.AddNewItemToDBContext(dic2);
            WordOfDictionary wd3 = new WordOfDictionary();
            dic1.Words.Add(wd3);
            WordOfDictionary wd4 = new WordOfDictionary();
            dic1.Words.Add(wd4);
            sw3.word_of_dictionary = wd3;

            
            
            
            ctx.SaveChanges();

            return EFDbConnect;
        }
コード例 #5
0
        protected void SetCurrentWord(WordOfDictionary item)
        {

            if (!IsInDesignMode)
            {
                if (CurrentWord != null)  CurrentWord.PropertyChanged -= CurrentWord_PropertyChanged;
            }
            
            CurrentWord = item;

            

            if (!IsInDesignMode)
            {
                CmdDispatcher("SpeechItem");
                CurrentWord.PropertyChanged += CurrentWord_PropertyChanged;
                // Language services
                LanguageServiceCollection = LanguageServices.GetServices(CurrentWord.TargetLanguage,CurrentWord.NativeLanguage);
            }

            // default setting
            btnOk.Visibility = VisualState.Collapsed;
            ImagesList_Visibility = VisualState.Collapsed;
            ErrorIconVisibility = VisualState.Collapsed;
            EditModeVisibility = VisualState.Collapsed;

            

            bool Testing = false;
            switch (mode)
            {
                case WordsTranslation_parameters.ViewMode.FoundNewWord:
                    Header_LabelModel.Text  = Tx.T("WordsTranslation.Caption.NewWordsFound");
                    Header2_LabelModel.Text = Tx.T("WordsTranslation.Caption.NewWordsFound.Second");

                    //Testing = LearningItem.TestingUnderstandingNewWords;
                    Testing = true;

                    btnTrainingNext.Visibility = VisualState.Collapsed;
                    ImagePanelVisibility = Testing ? VisualState.Collapsed : VisualState.Visible;
                    WordsButtonPanelVisibility = Testing ? VisualState.Visible : VisualState.Collapsed;
                    TranslatingVisibility = Testing ? VisualState.Hidden : VisualState.Visible;
                    if (TranslatingVisibility == VisualState.Visible)
                    {
                        CommentaryVisibilty = string.IsNullOrEmpty(CurrentWord.commentary) ? VisualState.Collapsed : VisualState.Visible;
                    } else
                    {
                        CommentaryVisibilty = VisualState.Hidden;
                    }
                    BottomButtonsPanelVisibility = Testing ? VisualState.Collapsed : VisualState.Visible;

                    break;

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

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

                case WordsTranslation_parameters.ViewMode.DictionaryItem:
                    Header_LabelModel.Text = Tx.T("WordsTranslation.Caption.Translation");
                    Testing = false;
                    btnTrainingNext.Visibility = VisualState.Visible;
                    btnPreviousButton.Visibility = VisualState.Hidden;
                    btnNextButton.Visibility = VisualState.Hidden;
                    WordsCollection_ListModel.Visibility = VisualState.Visible;
                    WordsButtonPanelVisibility = VisualState.Collapsed;
                    BottomButtonsPanelVisibility = VisualState.Collapsed;
                    btnTrainingNext.Visibility = VisualState.Collapsed;
                    btnAllWordsList.Visibility = VisualState.Collapsed;
                    break;
                    
                case WordsTranslation_parameters.ViewMode.Edit:
                    btnPreviousButton.Visibility = VisualState.Collapsed;
                    btnNextButton.Visibility = VisualState.Collapsed;
                    WordsCollection_ListModel.Visibility = VisualState.Collapsed;
                    btnOk.Visibility = VisualState.Visible;
                    BottomButtonsPanelVisibility = VisualState.Collapsed;
                    WordsButtonPanelVisibility = VisualState.Collapsed;
                    btnTrainingNext.Visibility = VisualState.Collapsed;
                    TranslatingVisibility = VisualState.Visible;
                    CommentaryVisibilty = VisualState.Visible;
                    RightPanel_Properties.IsChecked = true;
                    ImagesList_Visibility = VisualState.Visible;
                    EditModeVisibility = VisualState.Visible;
                    ContextVisibility = VisualState.Collapsed;
                    
                    break;

                default:
                    throw new NotImplementedException();
            }
            if (IsInDesignMode) return;
            /*
            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_of_phrase = CurrentWord.translation_as_string };
                phrase.Words.Add(trueword);

                if(CurrentWord.translation_as_string.Length > 0)
                {
                    Dictionary dict_ = CurrentWord.Dictionary;
                    if (dict_ == null)
                    {
                        SystemMessage.Show("Dictionary is null " + CurrentWord);
                        return;
                    }
                    Language lang_ = dict_.SecondaryLanguage;
                    if(lang_ == null)
                    {
                        SystemMessage.Show("Language is null " + dict_);
                        return;
                    }
                    FrequencyDictionary fdic_ = lang_.FrequencyDictionary;
                    if(fdic_ == null)
                    {
                        SystemMessage.Show("Frequency dictionary is null" + dict_);
                        return;
                    }

                    ObservableCollection<FrequencyDictionary.Item> coll = fdic_.GetRndWords(4);
                    foreach(var elm in coll)
                    {
                        phrase.Words.Add(new PhraseOfCollectMode.Word() { word_of_phrase = elm.Lemma});
                    }
                } else SystemMessage.Show("Can't found translation for "+CurrentWord);

                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_of_phrase, WordOfButton = word,IsItTrue = word == trueword});
                }
            }
        }
コード例 #6
0
 async void Dictionary_DataGrid_ContextMenu_Dispatcher(WordOfDictionary wrd, string command)
 {
     switch (command)
     {
         case "OpenItem":
             NavigationService.OpenDialog(Views.WordsTranslation,new WordsTranslation_parameters
             {
                 Mode = WordsTranslation_parameters.ViewMode.Edit,
                 Dictionary = Subtitles.Dictionary,
                 WordsCollection = new ObservableCollection<WordOfDictionary> { wrd }
             });
             break;
         case "DeleteItem":
             var refers = wrd.FindReferences(EFDbContext);
             bool isDelete = false;
             if (refers.Count > 0)
             {
                 await NavigationService.OpenDialogModal(Views.ReferencesToWord,
                     new ReferencesToWord_parameters
                     {
                         Word = wrd,
                         Title = Tx.T("SubtitleEditor.Messages.FoundReferencesCannotDelete")
                     });
                 refers = wrd.FindReferences(EFDbContext);
             }
             if (refers.Count == 0)
             {
                 bool res = await DialogService.Ask(string.Format(Tx.T("SubtitleEditor.Messages.ReallyDeleteAWord"),wrd));
                 if (res)
                 {
                     wrd.Dictionary.DeleteWord(wrd,EFDbContext);    
                 }
             }
             break;
         case "RefItem":
             NavigationService.OpenDialog(Views.ReferencesToWord, new ReferencesToWord_parameters { Word = wrd });
             break;
     }
 }
コード例 #7
0
        /*
        public List<WordOfSubtitleItem> FindReferences(WordOfDictionary wrd)
        {
            return DBContext.Query<WordOfSubtitleItem>(new QueryBuilder(DBContext) { Where = $"{nameof(WordOfSubtitleItem.word_of_dictionary_id)} = '{wrd.id.Hex}'"});
        } 
        */

        public void MergeWords(WordOfDictionary DestWord,WordOfDictionary DeletedWord)
        {
            if (DBContext == null) throw new Exception("DbContext not initialized");

            DestWord.AddForm(DeletedWord.word_of_dictionary);
            
            //DBContext.Delete(DeletedWord);
            if (Words.Contains(DeletedWord))
            {
                Words.Remove(DeletedWord);
            } else
            {
                DBContext.Delete(DeletedWord);
            }

            //string sql = "SELECT * FROM " + WordOfSubtitleItem.TableName + " WHERE word_of_dictionary_id = " + DeletedWord.id.Hex;
            List<WordOfSubtitleItem> lst = DBContext.Query(new QueryBuilder<WordOfSubtitleItem>(DBContext) {Where= $"{nameof(WordOfSubtitleItem.word_of_dictionary_id)} = '{DeletedWord.id.Hex}'"});
            foreach(WordOfSubtitleItem elm in lst)
            {
                elm.word_of_dictionary = DestWord;
            }

        }
コード例 #8
0
        public WordsTranslation_ViewModel(
            INavigationService NavigationService_,
            IDialogService DialogService_,
            AppSetting AppSetting_,
            IAudioAPI AudioAPI_,
            IFolderService FolderService_,
            IMvxMessenger MvxMessenger_,
            ILocalization Loc_
            )
        {
            
            // Design mode settings
            bool isButtonPressed = true;
            bool isPressedTrueButton = false;
            if (IsInDesignMode)
            {
                //mode = WordsTranslation_parameters.ViewMode.FoundNewWord;
                mode = WordsTranslation_parameters.ViewMode.Edit; // Subtitle editor
                //mode = WordsTranslation_parameters.ViewMode.Training; // Training mode
                //mode = WordsTranslation_parameters.ViewMode.WordTranslation; // Dictionary
                //mode = WordsTranslation_parameters.ViewMode.Training;
                //mode = WordsTranslation_parameters.ViewMode.DictionaryItem; 
            }
            
            if (!IsInDesignMode)
            {
                NavigationService = NavigationService_;
                DialogService = DialogService_;
                AppSetting = AppSetting_;
                AudioAPI = AudioAPI_;
                FolderService  = FolderService_;
                MvxMessenger = MvxMessenger_;
                Tx = Loc_;

                Statuses = new ObservableCollection<WordStatuses>(Enumeration.GetAll<WordStatuses>());

                CommandDispatcher = new MvxCommand<string>(CmdDispatcher);
                PressWordButton_Command = new MvxCommand<ButtonModel>(PressWordButton_Cmd);
                Command_SelectLanguageService = new MvxCommand<LanguageService>(PressLanguageServiceButton_Cmd);

                PropertyChanged += WordsTranslation_ViewModel_PropertyChanged;
            }
            
            WordsForSelection_Buttons = new ObservableCollection<ButtonModel>();
            LanguageServiceCollection = new ObservableCollection<LanguageService>();
            
            btnNextButton = new ButtonModel();
            btnPreviousButton = new ButtonModel();
            btnAddToDictionary = new ButtonModel();
            btnSkip = new ButtonModel();
            WordsCollection_ListModel = new List_Model();
            btnTrainingNext = new ButtonModel();
            btnOk = new ButtonModel();
            Header_LabelModel = new Label_Model();
            Header2_LabelModel = new Label_Model();
            btnAllWordsList = new ButtonModel();
            MergeButton = new ButtonModel { IsEnabled = false };

            RightPanel_TranslationButton = new ButtonModel();
            RightPanel_Properties = new ButtonModel();
            RightPanel_AllWordsButton = new ButtonModel();

            SpeechParts = new ObservableCollection<Domain.SpeechParts>(Domain.SpeechParts.GetAll<SpeechParts>());

            if (IsInDesignMode)
            {

                //Statuses = WordOfDictionary.WordStatuses.Statuses;

                Header_LabelModel.Text = "This is a Header";
                Header2_LabelModel.Text = "second header";
                Tx = new LocalizationForDesignMode();

                CurrentWord = new WordOfDictionary();
                CurrentWord.word_of_dictionary = "White";
                CurrentWord.translation_as_string = "Белый";
                CurrentWord.transcription = "[wʌɪt]";
                CurrentWord.commentary = "Белый цвет, не черный, не зеленый, а [b]именно белый[/b]. \nСовершенно белый.\nНу может с [i]желтоватым отливом[/i]";
                CurrentWord.pictures_url = "http://d144fqpiyasmrr.cloudfront.net/uploads/picture/295623.png";
                CurrentWord.context = "of the color of milk or fresh snow, due to the reflection of most wavelengths of visible light; the opposite of black.";
                CurrentWord.SpeechPart = Domain.SpeechParts.Pronoun;
                
                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_of_dictionary = "everybody"});
                WordsCollection.Add(new WordOfDictionary {word_of_dictionary = "likes"});
                WordsCollection.Add(new WordOfDictionary {word_of_dictionary = "cakes"});
                
                LanguageServiceCollection.Add(new LanguageService { Name = "Google translate"});
                LanguageServiceCollection.Add(new LanguageService { Name = "Yandex translate"});
                LanguageServiceCollection.Add(new LanguageService { Name = "LinguaLeo"});
                LanguageServiceCollection.Add(new LanguageService { Name = "Macmillan dictionary"});
                
                SetCurrentWord(CurrentWord);

                MergeWithStr = "I am";
                FoundedWord = new WordOfDictionary { word_of_dictionary = MergeWithStr };

                SpeechParts = new ObservableCollection<SpeechParts>
                {
                    Domain.SpeechParts.Adverb,
                    Domain.SpeechParts.Article,
                    Domain.SpeechParts.Conjuction,
                    Domain.SpeechParts.Pronoun
                };


            }

            if (IsInDesignMode)
            {
                if (mode == WordsTranslation_parameters.ViewMode.Training || mode == WordsTranslation_parameters.ViewMode.FoundNewWord)
                {
                    if (isButtonPressed)
                    {
                        PressWordButton_Cmd(new ButtonModel { IsItTrue = isPressedTrueButton});
                    }
                }

            }

            
        }
コード例 #9
0
 public void AddLearnedWord(WordOfDictionary word) {
     string word_str = word.word_of_dictionary.ToLower();
     if (!ContainsLearnedWord(word)) LearnedWords.Add(new LearnedWord() { learnedWord = word_str});
 }
コード例 #10
0
 public bool ContainsLearnedWord(WordOfDictionary wrd)
 {
     return ContainsLearnedWord(wrd.word_of_dictionary);
 }
コード例 #11
0
 public void AddOrUpdateWord(WordOfDictionary currentWord)
 {
     //string strWord = currentWord.word_of_dictionary.ToLower();
     //WordOfDictionary searchedWord = Words.Where(x => x.word_of_dictionary.ToLower() == strWord).FirstOrDefault();
     WordOfDictionary searchedWord = FindWord(currentWord.word_of_dictionary);
     if (searchedWord == null)
     {
         WordOfDictionary newword = new WordOfDictionary {
             commentary = currentWord.commentary,
             word_of_dictionary = currentWord.word_of_dictionary,
             PictureFile = currentWord.PictureFile,
             SpeechPart = currentWord.SpeechPart,
             context = currentWord.context,
             outer_id = currentWord.outer_id,
             pictures_url = currentWord.pictures_url,
             sound_url = currentWord.sound_url,
             SoundFile = currentWord.SoundFile,
             Status = currentWord.Status,
             transcription = currentWord.transcription,
             translations = new SynchronizedObservableCollection<TranslationOfWord>(),
             translation_as_string = currentWord.translation_as_string,
         };
         foreach(TranslationOfWord transl in currentWord.translations)
         {
             TranslationOfWord newtransl = new TranslationOfWord
             {
                 external_id = transl.external_id,
                 picture_url = transl.picture_url,
                 SpeechPart = currentWord.SpeechPart,
                 Translation = transl.Translation,
                 Votes = transl.Votes,
                 Selected = transl.Selected,
                 Index_of_selection = transl.Index_of_selection,
             };
             newword.translations.Add(newtransl);
         }
         LearningWordStrategy.InitializeWord(newword);
         Words.Add(newword);
     }
     else
     {
         throw new NotImplementedException();
     }    
 }
コード例 #12
0
        public WordOfDictionary AddOrUpdateWord(int outer_id,string str_word,string transcription,string picture_url ="",string sound_url="",string context="") {

            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) {
                AppSetting AppSettings = Mvx.Resolve<AppSetting>();
                AppSettings.LearningWordStrategy.SetNextStep(word);
            }
           
            word.word_of_dictionary = str_word;
            word.transcription = transcription;
            word.last_updated_at = DateTime.Today.ConvertToUTC();
            word.pictures_url = picture_url;
            word.sound_url = sound_url;
            word.context = context;
            
            return word;
        }
コード例 #13
0
 public void DeleteWord(WordOfDictionary wrd,EFDbContext context)
 {
     if (wrd.FindReferences(context).Count > 0) throw new Exception($"The word {wrd} has references from subtitles");
     Words.Remove(wrd);
 }
コード例 #14
0
        /*
        public WordOfDictionary AddOrUpdateWord(LinguaLeoAPI.Word wrd)
        {
            wrd.picture_url = "http:" + wrd.picture_url;
            WordOfDictionary word = Dictionary.AddOrUpdateWord(wrd.word_id, wrd.word_value, wrd.transcription, wrd.picture_url, wrd.sound_url,wrd.context);

            foreach (LinguaLeoAPI.UserTranslates transl in wrd.user_translates)
            { 
                word.AddTranslationWithExternalId((int)transl.translate_id, transl.translate_value, transl.speech_part);
                if (transl.speech_part != null && word.speech_part == null) word.speech_part = transl.speech_part;
            }
            if (word.translations.Any())
            {
                word.translation_as_string = word.translations.OrderByDescending(x => x.Votes).First().Translation;
            }
            


            
            //if(word.speech_part == null)
            //{
            //    var resp = LinguaLeoAPI.TranslateWord_withoutlogin(wrd.word_value);
            //    if(resp.word_forms.Count() > 0)
            //    {
            //        word.speech_part = resp.word_forms[0].speechpart;
            //    }
            //}
            

            return word;
        }
        */

        private void SpeechItem_Cmd(WordOfDictionary word)
        {
            AudioAPI.Play(new Uri(word.SoundPath, UriKind.RelativeOrAbsolute));
        }
コード例 #15
0
 private void CommandDispatcher_DictionaryList(WordOfDictionary Word,string cmd)
 {
     switch (cmd)
     {
         case "Open":
             ObservableCollection<WordOfDictionary>WordsCollection = new ObservableCollection<WordOfDictionary>();
             WordsCollection.Add(Word);
             NavigationService.NavigateForward(Views.WordsTranslation,new WordsTranslation_parameters {Mode = WordsTranslation_parameters.ViewMode.DictionaryItem, Dictionary = Dictionary,WordsCollection = WordsCollection});
             break;
         default:
             throw new NotImplementedException();
     }
 }