/// <summary> /// Generates single page image using specified size and clipping options. /// </summary> /// <param name="printSchedule">The <see cref="C1Scheduler"/> control to print.</param> /// <param name="contentWidth">The content width.</param> /// <param name="contentHeight">The content height.</param> /// <param name="clipHScrollBar">True to clip horizontal scrollbar area.</param> /// <param name="clipVScrollBar">True to clip vertical scrollbar area.</param> private void GeneratePage(C1Scheduler printSchedule, double contentWidth, double contentHeight, bool clipHScrollBar, bool clipVScrollBar) { // Measure control with specified size. printSchedule.Measure(new Size(contentWidth, contentHeight)); // Update content size if it was undefined according to the control's desired size. if (double.IsPositiveInfinity(contentWidth)) { contentWidth = Math.Max(printSchedule.DesiredSize.Width, ContentSize.Width); } if (double.IsPositiveInfinity(contentHeight)) { contentHeight = Math.Max(printSchedule.DesiredSize.Height, ContentSize.Height); } // Set up clip to exclude scrollbars. printSchedule.Clip = new RectangleGeometry(new Rect(0, 0, contentWidth, contentHeight)); // Enlarge size, so that scrollbars go out of printable area. if (clipVScrollBar) { contentWidth += SystemParameters.VerticalScrollBarWidth; } if (clipHScrollBar) { contentHeight += SystemParameters.HorizontalScrollBarHeight; } // Perform layout according to the desired page size. Size contentSize = new Size(contentWidth, contentHeight); printSchedule.Measure(contentSize); printSchedule.Arrange(new Rect(contentSize)); // In some C1Scheduler views not all bindings got updated during Arrange call, so force the whole visual tree update. printSchedule.InvalidateVisualTree(); printSchedule.UpdateLayout(); // Generate page image. _pages.Add(GetImageFromElement(printSchedule)); }