/// ------------------------------------------------------------------------------------ /// <summary> /// Constructs a Page object to represent a publication page that can be laid out. /// </summary> /// <param name="pub">Publication that owns this page</param> /// <param name="iFirstDivOnPage">Index (into array of divisions in the publication) of /// the first division expected to lay out on this page</param> /// <param name="ypOffsetFromTopOfDiv">Estimated number of pixels (in source/layout /// units) from the top of the division to the top of this page</param> /// <param name="pageNumber">The page number for this page. Page numbers can restart for /// different divisions, so this should not be regarded as an index into an array of /// pages.</param> /// <param name="dypTopMarginInPrinterPixels">The top margin in printer pixels.</param> /// <param name="dypBottomMarginInPrinterPixels">The bottom margin in printer pixels. /// </param> /// ------------------------------------------------------------------------------------ public Page(PublicationControl pub, int iFirstDivOnPage, int ypOffsetFromTopOfDiv, int pageNumber, int dypTopMarginInPrinterPixels, int dypBottomMarginInPrinterPixels) { m_pub = new WeakReference(pub); m_iFirstDivOnPage = iFirstDivOnPage; m_ypOffsetFromTopOfDiv = ypOffsetFromTopOfDiv; m_pageNumber = pageNumber; m_freeSpace = new Rectangle(0, dypTopMarginInPrinterPixels, pub.PageWidthInPrinterPixels, pub.PageHeightInPrinterPixels - dypTopMarginInPrinterPixels - dypBottomMarginInPrinterPixels); m_hPage = ++g_hPage; }
/// ------------------------------------------------------------------------------------ /// <summary> /// Creates the page. /// </summary> /// <param name="pub">Publication that owns this page</param> /// <param name="iFirstDivOnPage">Index (into array of divisions in the publication) of /// the first division expected to lay out on this page</param> /// <param name="ypOffsetFromTopOfDiv">Estimated number of pixels (in source/layout /// units) from the top of the division to the top of this page</param> /// <param name="pageNumber">The page number for this page. Page numbers can restart for /// different divisions, so this should not be regarded as an index into an array of /// pages.</param> /// <param name="dypTopMarginInPrinterPixels">The top margin in printer pixels.</param> /// <param name="dypBottomMarginInPrinterPixels">The bottom margin in printer pixels. /// </param> /// <returns>The new page</returns> /// <remarks>We do this in a virtual method so that tests can create special pages. /// </remarks> /// ------------------------------------------------------------------------------------ protected virtual Page CreatePage(PublicationControl pub, int iFirstDivOnPage, int ypOffsetFromTopOfDiv, int pageNumber, int dypTopMarginInPrinterPixels, int dypBottomMarginInPrinterPixels) { return new Page(pub, iFirstDivOnPage, ypOffsetFromTopOfDiv, pageNumber, dypTopMarginInPrinterPixels, dypBottomMarginInPrinterPixels); }
/// ------------------------------------------------------------------------------------ /// <summary> /// Constructs a Page object to represent a publication page that can be laid out. /// </summary> /// <param name="pub">Publication that owns this page</param> /// <param name="iFirstDivOnPage">Index (into array of divisions in the publication) of /// the first division expected to lay out on this page</param> /// <param name="ypOffsetFromTopOfDiv">Estimated number of pixels (in source/layout /// units) from the top of the division to the top of this page</param> /// <param name="pageNumber">The page number for this page. Page numbers can restart for /// different divisions, so this should not be regarded as an index into an array of /// pages.</param> /// <param name="dypTopMarginInPrinterPixels">The top margin in printer pixels.</param> /// <param name="dypBottomMarginInPrinterPixels">The bottom margin in printer pixels. /// </param> /// ------------------------------------------------------------------------------------ public DummyPage(PublicationControl pub, int iFirstDivOnPage, int ypOffsetFromTopOfDiv, int pageNumber, int dypTopMarginInPrinterPixels, int dypBottomMarginInPrinterPixels) : base(pub, iFirstDivOnPage, ypOffsetFromTopOfDiv, pageNumber, dypTopMarginInPrinterPixels, dypBottomMarginInPrinterPixels) { }
/// ------------------------------------------------------------------------------------ /// <summary> /// Determine the rectangle of this element in a target device (Publication window or /// printer page) in target device coordinates. /// </summary> /// <param name="pageIndex">The index of the page (within entire publication) on which /// this element is laid out.</param> /// <param name="pub">The publication</param> /// <param name="targetDpiX">horizontal DPI resolution of target device</param> /// <param name="targetDpiY">vertical DPI resololution of target device</param> /// <param name="unprintableAdjustment">for printers, defines the amount of /// space to adjust coordinates to account for unprintable space on the page.</param> /// <param name="gutterAdjustment">When actually printing, defines the amount of /// space to adjust coordinates to account for the gutter.</param> /// <param name="fScreen">true if displaying on screen, false for printers</param> /// <returns>The rectangle of this element in the publication output, in target device /// coordinates</returns> /// ------------------------------------------------------------------------------------ public Rectangle PositionInLayout(int pageIndex, PublicationControl pub, float targetDpiX, float targetDpiY, Point unprintableAdjustment, Point gutterAdjustment, bool fScreen) { CheckDisposed(); if (fScreen) return PositionInLayoutForScreen(pageIndex, pub, targetDpiX, targetDpiY); // If the output is to a printer, then we need to account for the visible // bounds and gutter. Rectangle rectPos; rectPos = m_locationOnPage; rectPos.Offset(gutterAdjustment); rectPos.Offset(unprintableAdjustment); return rectPos; }
/// ------------------------------------------------------------------------------------ /// <summary> /// Determine the rectangle of this element in a target device (Publication window or /// printer page) in target device coordinates. /// </summary> /// <param name="pageIndex">The index of the page (within entire publication) on which /// this element is laid out.</param> /// <param name="pub">The publication</param> /// <param name="targetDpiX">horizontal DPI resolution of target device</param> /// <param name="targetDpiY">vertical DPI resololution of target device</param> /// <returns>The rectangle of this element in the publication output, in target device /// coordinates</returns> /// ------------------------------------------------------------------------------------ public Rectangle PositionInLayoutForScreen(int pageIndex, PublicationControl pub, float targetDpiX, float targetDpiY) { CheckDisposed(); Rectangle rectPos; // For screen output, we need to transform the position on page to a // position on the screen. Start by transforming the coordinates to // screen coordinates. rectPos = new Rectangle( pub.ConvertPrintDistanceToTargetX(m_locationOnPage.Left, targetDpiX), pub.ConvertPrintDistanceToTargetY(m_locationOnPage.Top, targetDpiY), pub.ConvertPrintDistanceToTargetX(m_locationOnPage.Width, targetDpiX), pub.ConvertPrintDistanceToTargetY(m_locationOnPage.Height, targetDpiY)); // Offset to account for which page we're on rectPos.Offset(0, pageIndex * pub.PageHeightPlusGapInScreenPixels); // Offset to account for scroll position - only for screen rectPos.Offset(pub.AutoScrollPosition); return rectPos; }
/// -------------------------------------------------------------------------------- /// <summary> /// Initializes a new instance of the <see cref="DummyPage"/> class. /// </summary> /// -------------------------------------------------------------------------------- public DummyPage(PublicationControl pub) : base(pub, 0, 0, 1, 0, 0) { }