//This method does all of the heavy lifting for us, calculating the size of the page, //setting margins, and saving them to the pages List<>. private RichTextBlockOverflow AddOnePrintPreviewPage(RichTextBlockOverflow lastRTBOAdded, PrintPageDescription printPageDescription) { //This method does all of the heavy lifting for us, calculating the size of the //page, setting margins, and saving them to the pages List<>. FrameworkElement page; RichTextBlockOverflow link; if (lastRTBOAdded == null) { page = page1; } else { page = new ContinuesPage(lastRTBOAdded); } page.Width = printPageDescription.PageSize.Width; page.Height = printPageDescription.PageSize.Height; Grid printableArea = (Grid)page.FindName("printableArea"); double marginWidth = Math.Max(printPageDescription.PageSize.Width - printPageDescription.ImageableRect.Width, printPageDescription.PageSize.Width * left * 2); double marginHeight = Math.Max(printPageDescription.PageSize.Height - printPageDescription.ImageableRect.Height, printPageDescription.PageSize.Height * top * 2); printableArea.Width = page1.Width - marginWidth; printableArea.Height = page1.Height - marginHeight; PrintContainer.Children.Add(page); PrintContainer.InvalidateMeasure(); PrintContainer.UpdateLayout(); // Find the last text container and see if the content is overflowing link = (RichTextBlockOverflow)page.FindName("continuationPageLinkedContainer"); // Add the page to the page preview collection pages.Add(page); return(link); }
//This method does all of the heavy lifting for us, calculating the size of the page, //setting margins, and saving them to the pages List<>. private RichTextBlockOverflow AddOnePrintPreviewPage(RichTextBlockOverflow lastRTBOAdded, PrintPageDescription printPageDescription) { //This method does all of the heavy lifting for us, calculating the size of the //page, setting margins, and saving them to the pages List<>. FrameworkElement page; RichTextBlockOverflow link; if (lastRTBOAdded == null) { page = page1; } else { page = new ContinuesPage(lastRTBOAdded); } page.Width = printPageDescription.PageSize.Width; page.Height = printPageDescription.PageSize.Height; Grid printableArea = (Grid)page.FindName("printableArea"); double marginWidth = Math.Max(printPageDescription.PageSize.Width - printPageDescription.ImageableRect.Width, printPageDescription.PageSize.Width * left * 2); double marginHeight = Math.Max(printPageDescription.PageSize.Height - printPageDescription.ImageableRect.Height, printPageDescription.PageSize.Height * top * 2); printableArea.Width = page1.Width - marginWidth; printableArea.Height = page1.Height - marginHeight; PrintContainer.Children.Add(page); PrintContainer.InvalidateMeasure(); PrintContainer.UpdateLayout(); // Find the last text container and see if the content is overflowing link = (RichTextBlockOverflow)page.FindName("continuationPageLinkedContainer"); // Add the page to the page preview collection pages.Add(page); return link; }