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;
     }
 }
Exemplo n.º 2
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);
 }