public async void GetCurrentSentence(int index) { ActiveSentence localSent = sentenceService.GetActiveSentenceByIndex(index); if (localSent != null) { CurrentSentence = localSent; } else { await new Windows.UI.Popups.MessageDialog("The number of sentence is out of range.").ShowAsync(); } }
public ActiveSentence GetActiveSentenceByIndex(int index) { int i = 0; if (index < App.Corpus.SourceSentences.Count && index >= 0) { i = index; } else if (index == App.Corpus.SourceSentences.Count) { i = 0; } else if (index < 0) { i = App.Corpus.SourceSentences.Count - 1; } else { return(null); } ActiveSentence aSentence = new ActiveSentence(); aSentence.ActiveIndex = i; aSentence.ActiveSrcSentence = App.Corpus.SourceSentences.ElementAt(i); aSentence.ActiveSysSentence = App.Corpus.SystemSentences.ElementAt(i); aSentence.ActiveModSysSentence = App.Corpus.ModifiedSystemSentences.ElementAt(i); if (App.Corpus.ReferenceSentences.Count() > 0) { aSentence.ActiveRefSentence = App.Corpus.ReferenceSentences.ElementAt(i); } else { aSentence.ActiveRefSentence = new Sentence() { Index = i, Text = "" } }; return(aSentence); }
public void SearchSentByCategory(string cat) { if (cat != "") { ListSentByCat.Clear(); foreach (var sysSen in App.Corpus.SystemSentences) { var foundAnno = sysSen.Annotations.Where(x => x.AnnoDim.Name == cat).ToList(); if (foundAnno.Any()) { ActiveSentence localSent = sentenceService.GetActiveSentenceByIndex(sysSen.Index); ListSentByCat.Add(localSent); } } if (ListSentByCat.Any()) { SearchedIndex = 0; SearchedSent = ListSentByCat.ElementAt(SearchedIndex); } else { SearchedIndex = 0; SearchedSent = new ActiveSentence() { ActiveIndex = 0, ActiveModSysSentence = new Sentence() { Index = 0, Text = "" }, ActiveRefSentence = new Sentence() { Index = 0, Text = "" }, ActiveSrcSentence = new Sentence() { Index = 0, Text = "" }, ActiveSysSentence = new SysSentence() { Index = 0, Text = "", Annotations = null } }; } } else { ListSentByCat.Clear(); SearchedIndex = 0; SearchedSent = new ActiveSentence() { ActiveIndex = 0, ActiveModSysSentence = new Sentence() { Index = 0, Text = "" }, ActiveRefSentence = new Sentence() { Index = 0, Text = "" }, ActiveSrcSentence = new Sentence() { Index = 0, Text = "" }, ActiveSysSentence = new SysSentence() { Index = 0, Text = "", Annotations = null } }; } }