public BookListViewItem(Book book) : base() { ArgCheck.NotNull(book); Book = book; Text = GetLengthIndicator().PadRight(15) + Book.Title; }
public BlankBookContent() { Book = new Book("blank"); LayoutStrategy = new BlankLayoutStrategy(); PageCount = 100; if (Book.CurrentPosition == null) { Book.CurrentPosition = PositionInBook.FromPhysicalPage(1, PageCount); } }
public BookContent(Book book, DW<PageImageCache> imageCache = null) { ArgCheck.NotNull(book, "book"); _book = book; // null is ok ImageCache = imageCache; // Load layouts Layouts = new Dictionary<int, PageLayout>(); if (Settings.Default.Cache_SaveLayouts) { Layouts = XmlHelper.DeserializeOrDefault(LayoutsFile, Layouts); } _layoutStrategy = RenderFactory.Default.GetLayoutStrategy(); // Slightly hacky but best way to do it // -- set the book position info if it's null if (Book.CurrentPosition == null) { Book.CurrentPosition = PositionInBook.FromPhysicalPage(1, BookProvider.o.PageCount); } }
public BookViewModel(Book book) { ArgCheck.NotNull(book); Book = book; // TODO: handle position changed }
public override DW<IBookContent> NewBookContent(Book book, DW<PageImageCache> cache) { throw new NotImplementedException(); }
public override DW<IBookContent> NewBookContent(Book book, DW<PageImageCache> cache) { return DW.Wrap<IBookContent>(new BookContent(book, cache)); }
public abstract DW<IBookContent> NewBookContent(Book book, DW<PageImageCache> cache = null);
public void RemoveBook(Book book) { ArgCheck.NotNull(book, "book"); _books.Remove(book); book.CurrentPositionChanged -= OnBookPositionChanged; if (BooksChanged != null) { BooksChanged(this, EventArgs.Empty); } }
BookLibrary GetLibrary(int numBooks) { // Load from non-existing temp file to prevent saving to real library String file = Path.GetTempFileName(); File.Delete(file); var lib = BookLibrary.Load(file); for (int i = 0; i < numBooks; i++) { var book = new Book("book-" + i); lib.AddBook(book); } return lib; }
public override DW<IBookContent> NewBookContent(Book book, DW<PageImageCache> cache) { return BookContent; }
public void Create(LayoutTestCase tcase) { if (_haltTests) { Assert.Ignore("Halt tests"); } if (_bookContent == null || _bookContent.o.Book.Filename != tcase.Filename) { if (_bookContent != null) { _bookContent.DisposeItem(); _bookContent = null; } Book book = new Book(tcase.Filename); _bookContent = DW.Wrap<IBookContent>(new BookContent(book, null)); } IPageLayoutStrategy alg = new PdfWordsLayoutStrategy(); PageLayout layout = alg.DetectLayoutFromBook(_bookContent.o, tcase.PageNum); layout.SetPageSizeToScreen(600); // Get staus based on the layout TestCaseStatus status = tcase.GetStatus(layout); // Skip pages that pass the test if (status == TestCaseStatus.Pass_Good || status == TestCaseStatus.Pass_Acceptable) { return; } DW<Bitmap> page = DW.Wrap(_bookContent.o.BookProvider.o.RenderPageImage(tcase.PageNum, layout.PageSize)); DW<Bitmap> newPage = layout.Debug_DrawLayout(page); TestCaseStatus newStatus = _form.Show(status, tcase, newPage); page.DisposeItem(); newPage.DisposeItem(); if (newStatus == TestCaseStatus.HaltTest) { _haltTests = true; Assert.Ignore("Halt tests"); } // Update test case object tcase.Comment = _form.Comment; if (newStatus == TestCaseStatus.Pass_Acceptable || newStatus == TestCaseStatus.Pass_Good) { tcase.ExpectedLayout = layout; tcase.ExpectedLayoutAccurate = (newStatus == TestCaseStatus.Pass_Good); } if (newStatus == TestCaseStatus.Ignore_Clear) { tcase.ExpectedLayout = null; } switch (newStatus) { case TestCaseStatus.Fail: Assert.Fail("Failed: " + tcase.Comment); break; case TestCaseStatus.Ignore: case TestCaseStatus.Ignore_Clear: Assert.Ignore("Ignore: " + tcase.Comment); break; case TestCaseStatus.Unknown: Assert.Inconclusive(); break; } }
IEnumerable<LayoutTestCase> GetTestCases() { const int StartCount = 7; const int MidCount = 4; const int EndCount = 4; var cases = new List<LayoutTestCase>(); foreach (var file in TestConst.GetAllPdfFiles()) { int pageCount; Book book = new Book(file); DW<IBookContent> bookC = RenderFactory.Default.NewBookContent(book, null); pageCount = bookC.o.PageCount; bookC.DisposeItem(); // indexes var pages = LinqExtensions.IntRange(1, StartCount) .Concat(LinqExtensions.IntRange((pageCount - MidCount) / 2, MidCount)) .Concat(LinqExtensions.IntRange(pageCount - EndCount + 1, EndCount)) .Where(x => 1 <= x && x <= pageCount) .Distinct() .OrderBy(x => x); foreach (int pageNum in pages) { var tcase = LayoutTestCase.Get(file, pageNum); yield return tcase; } } }
public OpenBookEventArgs(Book book) { if (book == null) { throw new ArgumentNullException("book"); } Book = book; }