Esempio n. 1
0
        public void AdjustScrollRange_GrowFootnoteStream()
        {
            DummyVwLayoutStream stream         = new DummyVwLayoutStream();
            DummyVwLayoutStream footnoteStream = new DummyVwLayoutStream();

            using (GoofyDivision divMgr = new GoofyDivision(stream))
                using (DummyPublication pubCtrl = new DummyPublication(null, divMgr, DateTime.Now))
                {
                    pubCtrl.PageHeight      = 72000 * 6;
                    divMgr.m_overrideHeight = divMgr.AvailablePageHeightInPrinterPixels;
                    pubCtrl.CreatePages();
                    Assert.AreEqual(2, pubCtrl.PageCount);
                    divMgr.CallAddElement(pubCtrl.Pages[0], divMgr.m_overrideHeight - 100,
                                          1, 1, divMgr.InsideMarginInPrinterPixels, 20, divMgr.AvailablePageHeightInPrinterPixels);
                    int origTopOfPageTwo = divMgr.m_overrideHeight - 100;
                    ((DummyPage)pubCtrl.Pages[0]).CallAddPageElement(divMgr, footnoteStream, false,
                                                                     new Rectangle(divMgr.InsideMarginInPrinterPixels, divMgr.m_overrideHeight - 100, divMgr.AvailablePageWidthInPrinterPixels, 100),
                                                                     0, false, 1, 1, 0, 100, false, true);
                    divMgr.CallAddElement(pubCtrl.Pages[1], 100, 1, 1, divMgr.OutsideMarginInPrinterPixels,
                                          origTopOfPageTwo, divMgr.AvailablePageHeightInPrinterPixels);
                    ((DummyPage)pubCtrl.Pages[1]).CallAddPageElement(divMgr, footnoteStream, false,
                                                                     new Rectangle(divMgr.InsideMarginInPrinterPixels, divMgr.m_overrideHeight - 100, divMgr.AvailablePageWidthInPrinterPixels, 100),
                                                                     101, false, 1, 1, 0, 100, false, true);
                    Point origScrollPos  = pubCtrl.ScrollPosition;
                    Size  origScrollSize = pubCtrl.AutoScrollMinSize;
                    pubCtrl.AdjustScrollRange(footnoteStream, 0, 0, 300, 95);
                    Assert.AreEqual(2, pubCtrl.PageCount);
                    Assert.AreEqual(origScrollPos, pubCtrl.ScrollPosition);
                    Assert.AreEqual(origScrollSize, pubCtrl.AutoScrollMinSize);
                    Assert.AreEqual(0, pubCtrl.Pages[0].PageElements[1].OffsetToTopPageBoundary);
                    Assert.AreEqual(401, pubCtrl.Pages[1].PageElements[1].OffsetToTopPageBoundary);
                    Assert.AreEqual(20, pubCtrl.Pages[0].OffsetFromTopOfDiv(divMgr));
                    Assert.AreEqual(origTopOfPageTwo, pubCtrl.Pages[1].OffsetFromTopOfDiv(divMgr));
                }
        }
Esempio n. 2
0
        public void AdjustScrollRange_GrowFirstDivOnPage_NoElements()
        {
            DummyVwLayoutStream stream = new DummyVwLayoutStream();

            using (GoofyDivision divMgr = new GoofyDivision(stream))
                using (DummyPublication pubCtrl = new DummyPublication(null, divMgr, DateTime.Now))
                {
                    pubCtrl.PageHeight      = 72000 * 6;
                    divMgr.m_overrideHeight = divMgr.AvailablePageHeightInPrinterPixels;
                    pubCtrl.CreatePages();
                    Assert.AreEqual(2, pubCtrl.PageCount);
                    Assert.AreEqual(0, pubCtrl.Pages[0].PageElements.Count);
                    Assert.AreEqual(0, pubCtrl.Pages[1].PageElements.Count);
                    Point origScrollPos  = pubCtrl.ScrollPosition;
                    Size  origScrollSize = pubCtrl.AutoScrollMinSize;
                    pubCtrl.AdjustScrollRange(stream, 0, 0, 300, 0);
                    Assert.AreEqual(2, pubCtrl.PageCount);
                    Assert.AreEqual(origScrollPos, pubCtrl.ScrollPosition);
                    Assert.AreEqual(origScrollSize, pubCtrl.AutoScrollMinSize);
                    Assert.AreEqual(0, pubCtrl.Pages[0].PageElements.Count);
                    Assert.AreEqual(0, pubCtrl.Pages[1].PageElements.Count);
                    Assert.IsTrue(pubCtrl.Pages[0].NeedsLayout);
                    Assert.IsTrue(pubCtrl.Pages[1].NeedsLayout);
                }
        }
Esempio n. 3
0
        public void AdjustScrollRange_GrowFirstDivOnPage()
        {
            DummyVwLayoutStream stream = new DummyVwLayoutStream();

            using (GoofyDivision divMgr = new GoofyDivision(stream))
                using (DummyPublication pubCtrl = new DummyPublication(null, divMgr, DateTime.Now))
                {
                    pubCtrl.PageHeight      = 72000 * 6;
                    divMgr.m_overrideHeight = divMgr.AvailablePageHeightInPrinterPixels;
                    pubCtrl.CreatePages();
                    Assert.AreEqual(2, pubCtrl.PageCount);
                    divMgr.CallAddElement(pubCtrl.Pages[0], divMgr.m_overrideHeight - 20,
                                          1, 1, divMgr.InsideMarginInPrinterPixels, 20, divMgr.AvailablePageHeightInPrinterPixels);
                    int origTopOfPageTwo = divMgr.m_overrideHeight - 20;
                    divMgr.CallAddElement(pubCtrl.Pages[1], 20, 1, 1, divMgr.OutsideMarginInPrinterPixels,
                                          origTopOfPageTwo, divMgr.AvailablePageHeightInPrinterPixels);
                    Point origScrollPos  = pubCtrl.ScrollPosition;
                    Size  origScrollSize = pubCtrl.AutoScrollMinSize;
                    pubCtrl.AdjustScrollRange(stream, 0, 0, 300, origTopOfPageTwo - 2000);
                    Assert.AreEqual(2, pubCtrl.PageCount);
                    Assert.AreEqual(origScrollPos, pubCtrl.ScrollPosition);
                    Assert.AreEqual(origScrollSize, pubCtrl.AutoScrollMinSize);
                    Assert.AreEqual(20, pubCtrl.Pages[0].PageElements[0].OffsetToTopPageBoundary);
                    Assert.AreEqual(origTopOfPageTwo + 300, pubCtrl.Pages[1].PageElements[0].OffsetToTopPageBoundary);
                    Assert.IsFalse(pubCtrl.Pages[0].NeedsLayout);
                    Assert.IsTrue(pubCtrl.Pages[1].NeedsLayout);
                }
        }
Esempio n. 4
0
        public void AdjustScrollRange_GrowSecondDivOnPageTwo()
        {
            DummyVwLayoutStream stream1 = new DummyVwLayoutStream();
            DummyVwLayoutStream stream2 = new DummyVwLayoutStream();

            using (GoofyDivision divMgr1 = new GoofyDivision(stream1))
                using (GoofyDivision divMgr2 = new GoofyDivision(stream2))
                    using (DummyPublication pubCtrl = new DummyPublication(null, divMgr1, DateTime.Now))
                    {
                        pubCtrl.PageHeight = 72000 * 6;
                        pubCtrl.AddDivision(divMgr2);
                        divMgr1.m_overrideHeight = divMgr1.AvailablePageHeightInPrinterPixels;
                        divMgr2.m_overrideHeight = divMgr2.AvailablePageHeightInPrinterPixels;
                        divMgr2.StartAt          = DivisionStartOption.Continuous;
                        pubCtrl.CreatePages();
                        Assert.AreEqual(3, pubCtrl.PageCount);
                        divMgr1.CallAddElement(pubCtrl.Pages[0], divMgr1.m_overrideHeight - 20, 1, 1,
                                               divMgr1.InsideMarginInPrinterPixels, 20, divMgr1.AvailablePageHeightInPrinterPixels);
                        int origTopOfPageTwoDiv1 = divMgr1.m_overrideHeight - 20;
                        divMgr1.CallAddElement(pubCtrl.Pages[1], 20, 1, 1, divMgr1.OutsideMarginInPrinterPixels,
                                               origTopOfPageTwoDiv1, divMgr1.AvailablePageHeightInPrinterPixels);
                        Page  origPg3 = pubCtrl.Pages[2];
                        int   origTopOfPageThreeDiv2 = origPg3.OffsetFromTopOfDiv(divMgr2);
                        Point origScrollPos          = pubCtrl.ScrollPosition;
                        Size  origScrollSize         = pubCtrl.AutoScrollMinSize;
                        pubCtrl.AdjustScrollRange(stream2, 0, 0, divMgr2.AvailablePageHeightInPrinterPixels, 0);
                        Assert.AreEqual(4, pubCtrl.PageCount);
                        Assert.IsFalse(pubCtrl.Pages[0].NeedsLayout);
                        Assert.IsFalse(pubCtrl.Pages[1].NeedsLayout,
                                       "This test simulates a call to AdjustScrollRange that happens in the middle of laying out this page, so it should not get flagged as needing layout.");
                        Assert.IsTrue(pubCtrl.Pages[2].NeedsLayout);
                        Assert.IsTrue(pubCtrl.Pages[3].NeedsLayout);
                        Assert.AreEqual(origScrollPos, pubCtrl.ScrollPosition);
                        Assert.AreEqual(origScrollSize.Height * 4 / 3, pubCtrl.AutoScrollMinSize.Height);
                        Assert.AreEqual(1, pubCtrl.Pages[0].PageElements.Count);
                        Assert.AreEqual(20, pubCtrl.Pages[0].PageElements[0].OffsetToTopPageBoundary);
                        Assert.AreEqual(1, pubCtrl.Pages[1].PageElements.Count);
                        Assert.AreEqual(origTopOfPageTwoDiv1, pubCtrl.Pages[1].OffsetFromTopOfDiv(divMgr1));
                        Assert.AreEqual(0, pubCtrl.Pages[1].OffsetFromTopOfDiv(divMgr2));
                        Assert.AreEqual(origPg3, pubCtrl.Pages[3],
                                        "A page should have been inserted between the original page 2 and page 3.");
                        Assert.AreEqual(0, pubCtrl.Pages[2].PageElements.Count);
                        Assert.AreEqual(divMgr2.AvailablePageHeightInPrinterPixels,
                                        pubCtrl.Pages[2].OffsetFromTopOfDiv(divMgr2),
                                        "Inserted page's offset from top of division 2 should be one ideal page from the top.");
                        Assert.AreEqual(0, pubCtrl.Pages[3].PageElements.Count);
                        Assert.AreEqual(origTopOfPageThreeDiv2 + divMgr2.AvailablePageHeightInPrinterPixels,
                                        pubCtrl.Pages[3].OffsetFromTopOfDiv(divMgr2));
                    }
        }
        public void AdjustScrollRange_ShrinkFirstDivOnPage()
        {
            DummyVwLayoutStream stream  = new DummyVwLayoutStream();
            GoofyDivision       divMgr  = new GoofyDivision(stream);
            DummyPublication    pubCtrl = new DummyPublication(null, divMgr, DateTime.Now);

            pubCtrl.PageHeight      = 72000 * 6;
            divMgr.m_overrideHeight = divMgr.AvailablePageHeightInPrinterPixels * 2;
            pubCtrl.CreatePages();
            Assert.AreEqual(3, pubCtrl.PageCount);
            Page pg1 = pubCtrl.Pages[0];
            Page pg2 = pubCtrl.Pages[1];
            Page pg3 = pubCtrl.Pages[2];

            divMgr.CallAddElement(pg1, divMgr.AvailablePageHeightInPrinterPixels - 20,
                                  1, 1, divMgr.InsideMarginInPrinterPixels, 20, divMgr.AvailablePageHeightInPrinterPixels);
            int origTopOfPageTwo = divMgr.AvailablePageHeightInPrinterPixels - 40;

            divMgr.CallAddElement(pg2, divMgr.AvailablePageHeightInPrinterPixels - 20,
                                  1, 1, divMgr.OutsideMarginInPrinterPixels, origTopOfPageTwo, divMgr.AvailablePageHeightInPrinterPixels);
            int origTopOfPageThree = divMgr.m_overrideHeight - 60;

            divMgr.CallAddElement(pg3, 40, 1, 1, divMgr.InsideMarginInPrinterPixels,
                                  origTopOfPageThree, divMgr.AvailablePageHeightInPrinterPixels);
            foreach (Page pg in pubCtrl.Pages)
            {
                Assert.AreEqual(pg.PageElements[0].OffsetToTopPageBoundary, pg.OffsetFromTopOfDiv(divMgr));
            }
            Point origScrollPos  = pubCtrl.ScrollPosition;
            Size  origScrollSize = pubCtrl.AutoScrollMinSize;

            // The following should cause the original page 2 to be deleted and adjust the top of
            // the original page 3 (now page 2) to be the same as the original top of page 2.
            pubCtrl.AdjustScrollRange(stream, 0, 0, -divMgr.AvailablePageHeightInPrinterPixels,
                                      origTopOfPageTwo - 2000);
            Assert.AreEqual(2, pubCtrl.PageCount);
            Assert.AreEqual(origScrollPos, pubCtrl.ScrollPosition);
            Assert.AreEqual(origScrollSize.Height * 2 / 3, pubCtrl.AutoScrollMinSize.Height);
            Assert.AreEqual(20, pg1.PageElements[0].OffsetToTopPageBoundary);
            Assert.AreEqual(pg3, pubCtrl.Pages[1]);
            Assert.AreEqual(origTopOfPageThree - divMgr.AvailablePageHeightInPrinterPixels,
                            pg3.PageElements[0].OffsetToTopPageBoundary);
            Assert.AreEqual(40, pg3.PageElements[0].LocationOnPage.Height);
            Assert.IsFalse(pg1.NeedsLayout);
            Assert.IsTrue(pg3.NeedsLayout);
        }