// To intermix custom drawing with the drawing performed by an associated print formatter, // this method is called for each print formatter associated with a given page. // // We do this to intermix/overlay our custom drawing onto the recipe presentation. // We draw the upper portion of the recipe presentation by hand (image, title, desc), // and the bottom portion is drawn via the UIMarkupTextPrintFormatter. public override void DrawPrintFormatterForPage(UIPrintFormatter printFormatter, int page) { base.DrawPrintFormatterForPage(printFormatter, page); // To keep our custom drawing in sync with the printFormatter, base our drawing // on the formatters rect. RectangleF rect = printFormatter.RectangleForPage(page); // Use a bezier path to draw the borders. // We may potentially choose not to draw either the top or bottom line // of the border depending on whether our recipe extended from the previous // page, or carries onto the subsequent page. UIBezierPath border = new UIBezierPath(); if (page == printFormatter.StartPage) { // For border drawing, get the rect that includes the formatter area plus the header area. // Move the formatter's rect up the size of the custom drawn recipe presentation // and essentially grow the rect's height by this amount. rect.Height += RecipeInfoHeight; rect.Y -= RecipeInfoHeight; border.MoveTo(rect.Location); border.AddLineTo(new PointF(rect.Right, rect.Top)); Recipe recipe = recipeFormatterMap[printFormatter]; // Run custom code to draw upper portion of the recipe presentation (image, title, desc) DrawRecipe(recipe, rect); } // Draw the left border border.MoveTo(rect.Location); border.AddLineTo(new PointF(rect.Left, rect.Bottom)); // Draw the right border border.MoveTo(new PointF(rect.Right, rect.Top)); border.AddLineTo(new PointF(rect.Right, rect.Bottom)); if (page == printFormatter.StartPage + printFormatter.PageCount - 1) { border.AddLineTo(new PointF(rect.Left, rect.Bottom)); } // Set the UIColor to be used by the current graphics context, and then stroke // stroke the current path that is defined by the border bezier path. UIColor.Black.SetColor(); border.Stroke(); }
// To intermix custom drawing with the drawing performed by an associated print formatter, // this method is called for each print formatter associated with a given page. // // We do this to intermix/overlay our custom drawing onto the recipe presentation. // We draw the upper portion of the recipe presentation by hand (image, title, desc), // and the bottom portion is drawn via the UIMarkupTextPrintFormatter. public override void DrawPrintFormatterForPage (UIPrintFormatter printFormatter, int page) { base.DrawPrintFormatterForPage (printFormatter, page); // To keep our custom drawing in sync with the printFormatter, base our drawing // on the formatters rect. RectangleF rect = printFormatter.RectangleForPage (page); // Use a bezier path to draw the borders. // We may potentially choose not to draw either the top or bottom line // of the border depending on whether our recipe extended from the previous // page, or carries onto the subsequent page. UIBezierPath border = new UIBezierPath (); if (page == printFormatter.StartPage) { // For border drawing, get the rect that includes the formatter area plus the header area. // Move the formatter's rect up the size of the custom drawn recipe presentation // and essentially grow the rect's height by this amount. rect.Height += RecipeInfoHeight; rect.Y -= RecipeInfoHeight; border.MoveTo (rect.Location); border.AddLineTo (new PointF (rect.Right, rect.Top)); Recipe recipe = recipeFormatterMap[printFormatter]; // Run custom code to draw upper portion of the recipe presentation (image, title, desc) DrawRecipe (recipe, rect); } // Draw the left border border.MoveTo (rect.Location); border.AddLineTo (new PointF (rect.Left, rect.Bottom)); // Draw the right border border.MoveTo (new PointF (rect.Right, rect.Top)); border.AddLineTo (new PointF (rect.Right, rect.Bottom)); if (page == printFormatter.StartPage + printFormatter.PageCount - 1) border.AddLineTo (new PointF (rect.Left, rect.Bottom)); // Set the UIColor to be used by the current graphics context, and then stroke // stroke the current path that is defined by the border bezier path. UIColor.Black.SetColor (); border.Stroke (); }