public SubWordEditor_ViewModel(ILogger Logger_, INavigationService NavigationService_, IDialogService DialogService_) { Logger = Logger_; NavigationService = NavigationService_; DialogService = DialogService_; CommandDispatcher = new MvxCommand<string>(CmdDispatcher); if (IsInDesignMode) { Word = new WordOfSubtitleItem(); Word.word = "Test"; } }
override public void OnNavigationOpenPage(ParametersOfForms param_) { SubWordEditor_parameters param = (SubWordEditor_parameters)param_; Word = param.Word; }
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; }
/* private void CurrentDictionary_Cmd(WordOfDictionary wrd,string cmd) { switch (cmd) { case "OpenItem": NavigationService.OpenDialog(Views.WordsTranslation,new WordsTranslation_parameters { Mode = WordsTranslation_parameters.ViewMode.Edit, Dictionary = Subtitles.Dictionary, WordsCollection = new ObservableCollection<WordOfDictionary> { wrd } }); break; } } */ private async void SubGrid_PhrasesForDictionary_Cmd(WordOfSubtitleItem word, string cmd,bool recursion = false) { switch (cmd) { case "EditWord": NavigationService.OpenDialog(Views.SubWordEditor,new SubWordEditor_parameters() { Word = word }); break; case "EditTranslation": if (word.word_of_dictionary == null) { DialogService.Message(Tx.T("SubtitleEditor.Messages.PleaseMakeTranslationBeforeEdit")); return; } ObservableCollection<WordOfDictionary> wrdcoll = new ObservableCollection<WordOfDictionary>{word.word_of_dictionary}; NavigationService.OpenDialog(Views.WordsTranslation,new WordsTranslation_parameters {Mode = WordsTranslation_parameters.ViewMode.Edit,WordsCollection = wrdcoll }); break; case "DeleteWord": EFDbContext.Context.Delete(word); break; case "AddTranslating": word.Translating(Subtitles.Dictionary); break; case "MarkTranslation": if (word.word_of_dictionary == null) return; word.word_of_dictionary.Status = WordStatuses.ManualEditing; EFDbContext.SaveChgs(); break; case "AddToWordRulesList": Subtitles.PrimaryLanguage.ProcessingWordsRules.Add(new ProcessingWordsRules {word = word.word}); break; } if (!recursion && ( //cmd == "MarkWordAsIgnore" || cmd=="DeleteWord" || cmd=="AddTranslating")) { bool res = await DialogService.Ask(Tx.Text("SubtitleEditor.Messages.ApplyToAllWords")); if (res){ foreach(SubtitleItem SubItem in Subtitles.Items) { foreach(WordOfSubtitleItem wrd_in_collection in SubItem.WordsCollection) { if(wrd_in_collection.word.ToLower() == word.word.ToLower()) { SubGrid_PhrasesForDictionary_Cmd(wrd_in_collection, cmd,true); } } } } } /* if (!recursion && EFDbContext.HasChanges) { EFDbContext.SaveChgs(); } */ }