public async void OpenItem(object DataContext) { if (DataContext is GRRow <FTSResult> RsRow) { Chapter Ch = Shared.BooksDb.Chapters.Find(RsRow.Source.ChapterId); if (Ch == null) { StringResources stx = StringResources.Load("Message"); await Popups.ShowDialog(UIAliases.CreateDialog(string.Format(stx.Str("FTSNeedsRebuild")))); return; } Ch.Book = Shared.BooksDb.QueryBook(x => x.Id == Ch.BookId).FirstOrDefault(); // Chapter is hard-linked to Volume. So we can load it confidently await Shared.BooksDb.LoadCollectionAsync(Ch.Book, x => x.Volumes, x => x.Index); foreach (Volume V in Ch.Book.Volumes) { await Shared.BooksDb.LoadCollectionAsync(V, x => x.Chapters, x => x.Index); } BookItem BkItem = ItemProcessor.GetBookItem(Ch.Book); PageProcessor.NavigateToReader(BkItem, Ch); } }
private bool TryGetBookItem(object DataContext, out BookItem BkItem) { BkItem = null; if (DataContext is GRRow <BookDisplay> BkRow) { BkItem = ItemProcessor.GetBookItem(BkRow.Source.Entry); } else if (DataContext is BookItem) { BkItem = ( BookItem )DataContext; } return(BkItem != null); }
private async void Edit_Click(object sender, RoutedEventArgs e) { object DataContext = (( FrameworkElement )sender).DataContext; if (DataContext is GRRow <BookDisplay> BkRow) { BookItem BkItem = ItemProcessor.GetBookItem(BkRow.Source.Entry); SpiderBook SBk = await SpiderBook.CreateSAsync(BkItem.ZoneId, BkItem.ZItemId, null); if (SBk.CanProcess) { ControlFrame.Instance.NavigateTo(PageId.PROC_PANEL, () => new ProcPanelWrapper(SBk.MetaLocation)); } } }
public object Convert(object value, Type targetType, object parameter, string language) { if (value is BookDisplay BkDisplay) { BookItem BItem = ItemProcessor.GetBookItem(BkDisplay.Entry); if (!BItem.CoverExist) { BookLoader Loader = new BookLoader(); Loader.LoadCover(BItem, true); } return(BItem); } return(null); }
public void ProcessOrOpenItem(IGRRow DataContext) { if (DataContext is GRRow <IBookProcess> Row) { LocalBook BkProc = ( LocalBook )Row.Source; if (BkProc.Processed && BkProc.ProcessSuccess) { Book Bk = Shared.BooksDb.QueryBook(BookType.L, BkProc.ZoneId, BkProc.ZItemId); if (Bk != null) { PageProcessor.NavigateToTOC(Page, ItemProcessor.GetBookItem(Bk)); } } else { ProcessItem(DataContext); } } }
private async void PinToStart_Click(object sender, RoutedEventArgs e) { if ((( FrameworkElement )sender).DataContext is GRRow <BookDisplay> BkRow) { BookItem BkItem = ItemProcessor.GetBookItem(BkRow.Source.Entry); string TileId = await PageProcessor.PinToStart(BkItem); if (!string.IsNullOrEmpty(TileId)) { PinManager PM = new PinManager(); PM.RegPin(BkItem, TileId, true); if (BkItem is BookInstruction BInst) { SpiderBook SBook = await SpiderBook.CreateSAsync(BkItem.ZoneId, BkItem.ZItemId, null); await PageProcessor.RegLiveSpider(SBook, BInst, TileId); } } } }