public async Task <IReadOnlyCollection <DictionaryItem> > ReadData() { List <DictionaryItem> items = new List <DictionaryItem>(); try { string file = await _fileAccessor.ReadFile(_fileUri); if (!string.IsNullOrEmpty(file)) { string[] parts = file.Split('*'); foreach (string part in parts) { Dictionary.ListItemIndex itemIndex = Dictionary.ListItemIndex.FromString(part); DictionaryItem item = _dictionaryService.GetItemByIndex(itemIndex); DictionaryItem realItem = _dictionaryService.GetItemByWord(item.Title, item.LanguageCode); items.Add(realItem); } } } catch (Exception ex) { Debug.WriteLine(ex); } return(items); }
public DictionaryItem GetItemByIndex(Dictionary.ListItemIndex index) { lock (_locker) { return(new DictionaryItem(_dictionary.GetItemByIndex(index))); } }
private void WordOnClick(Metadata metadata) { DictionaryItem item = null; switch (metadata.Type) { case MetadataTypes.Text: item = _dictionaryService.GetItemByWord(metadata.Word, metadata.LanguageCode); break; case MetadataTypes.Link: Dictionary.ListItemIndex itemIndex = new Dictionary.ListItemIndex(string.Empty, (int)metadata.ListIndex, (int)metadata.EntryIndex, (int)metadata.EntryIndex); item = _dictionaryService.GetItemByIndex(itemIndex); break; case MetadataTypes.Sound: _articleRenderingService.PlayArticleSound(metadata.SoundIndex, _soundPlayer); break; case MetadataTypes.PopupArticle: Dictionary.ListItemIndex popupItemIndex = new Dictionary.ListItemIndex(string.Empty, (int)metadata.ListIndex, (int)metadata.EntryIndex, (int)metadata.EntryIndex); DictionaryItem popupArticle = _dictionaryService.GetItemByIndex(popupItemIndex); RenderPopup(popupArticle); break; } if (item != null) { item.Label = metadata.Label; if (item.Index.Equals(_renderingItem.Item.Index)) { Common.Delegate.Call(Scrolled, item.Label); } else { _renderingItem = new RenderingItem(item, false); Render(false); } } }
public void PlaySound(Dictionary.ListItemIndex itemIndex, Dictionary.ISoundPlayer soundPlayer) { _articleService.PlaySound(itemIndex, soundPlayer); }