Ejemplo n.º 1
0
        // Iterate through the recipes setting each of their html representations into
        // a UIMarkupTextPrintFormatter and add that formatter to the printing job.
        void SetupPrintFormatters()
        {
            RectangleF contentArea           = ContentArea;
            float      previousFormatterMaxY = contentArea.Top;
            int        page = 0;

            foreach (Recipe recipe in recipes)
            {
                string html = recipe.HtmlRepresentation;

                UIMarkupTextPrintFormatter formatter = new UIMarkupTextPrintFormatter(html);
                recipeFormatterMap.Add(formatter, recipe);

                // Make room for the recipe info
                UIEdgeInsets contentInsets = new UIEdgeInsets(0.0f, 0.0f, 0.0f, 0.0f);

                contentInsets.Top = previousFormatterMaxY + RecipeInfoHeight;
                if (contentInsets.Top > contentArea.Bottom)
                {
                    // Move to the next page
                    contentInsets.Top = contentArea.Top + RecipeInfoHeight;
                    page++;
                }

                formatter.ContentInsets = contentInsets;

                // Add the formatter to the renderer at the specified page
                AddPrintFormatter(formatter, page);

                page = formatter.StartPage + formatter.PageCount - 1;

                previousFormatterMaxY = formatter.RectangleForPage(page).Bottom;
            }
        }
Ejemplo n.º 2
0
        // Iterate through the recipes setting each of their html representations into
        // a UIMarkupTextPrintFormatter and add that formatter to the printing job.
        void SetupPrintFormatters()
        {
            CGRect contentArea           = ContentArea;
            nfloat previousFormatterMaxY = contentArea.Top;
            nint   page = 0;

            foreach (Recipe recipe in recipes)
            {
                string html = recipe.HtmlRepresentation;

                // ios9 calls NumberOfPages -> SetupPrintFormatters not from main thread, but UIMarkupTextPrintFormatter is UIKit class (must be accessed from main thread)
                DispatchQueue.MainQueue.DispatchSync(() => {
                    var formatter = new UIMarkupTextPrintFormatter(html);
                    recipeFormatterMap.Add(formatter, recipe);

                    // Make room for the recipe info
                    UIEdgeInsets contentInsets = UIEdgeInsets.Zero;

                    contentInsets.Top = previousFormatterMaxY + RecipeInfoHeight;
                    if (contentInsets.Top > contentArea.Bottom)
                    {
                        // Move to the next page
                        contentInsets.Top = contentArea.Top + RecipeInfoHeight;
                        page++;
                    }

                    formatter.ContentInsets = contentInsets;

                    // Add the formatter to the renderer at the specified page
                    AddPrintFormatter(formatter, page);

                    page = formatter.StartPage + formatter.PageCount - 1;

                    previousFormatterMaxY = formatter.RectangleForPage(page).Bottom;
                });
            }
        }
		// Iterate through the recipes setting each of their html representations into 
		// a UIMarkupTextPrintFormatter and add that formatter to the printing job.
		void SetupPrintFormatters ()
		{
			RectangleF contentArea = ContentArea;
			float previousFormatterMaxY = contentArea.Top;
			int page = 0;
			
			foreach (Recipe recipe in recipes) {
				string html = recipe.HtmlRepresentation;
				
				UIMarkupTextPrintFormatter formatter = new UIMarkupTextPrintFormatter (html);
				recipeFormatterMap.Add (formatter, recipe);
				
				// Make room for the recipe info
				UIEdgeInsets contentInsets = new UIEdgeInsets (0.0f, 0.0f, 0.0f, 0.0f);
				
				contentInsets.Top = previousFormatterMaxY + RecipeInfoHeight;
				if (contentInsets.Top > contentArea.Bottom) {
					// Move to the next page
					contentInsets.Top = contentArea.Top + RecipeInfoHeight;
					page++;
				}
				
				formatter.ContentInsets = contentInsets;
				
				// Add the formatter to the renderer at the specified page
				AddPrintFormatter (formatter, page);
				
				page = formatter.StartPage + formatter.PageCount - 1;
				
				previousFormatterMaxY = formatter.RectangleForPage (page).Bottom;
			}
		}
Ejemplo n.º 4
0
		// Iterate through the recipes setting each of their html representations into
		// a UIMarkupTextPrintFormatter and add that formatter to the printing job.
		void SetupPrintFormatters ()
		{
			CGRect contentArea = ContentArea;
			nfloat previousFormatterMaxY = contentArea.Top;
			nint page = 0;

			foreach (Exercise recipe in exercises) {
				string html = recipe.HtmlRepresentation;

				// ios9 calls NumberOfPages -> SetupPrintFormatters not from main thread, but UIMarkupTextPrintFormatter is UIKit class (must be accessed from main thread)
				DispatchQueue.MainQueue.DispatchSync (() => {
					var formatter = new UIMarkupTextPrintFormatter (html);
					recipeFormatterMap.Add (formatter, recipe);

					// Make room for the recipe info
					UIEdgeInsets contentInsets = UIEdgeInsets.Zero;

					contentInsets.Top = previousFormatterMaxY + RecipeInfoHeight;
					if (contentInsets.Top > contentArea.Bottom) {
						// Move to the next page
						contentInsets.Top = contentArea.Top + RecipeInfoHeight;
						page++;
					}

					formatter.ContentInsets = contentInsets;

					// Add the formatter to the renderer at the specified page
					AddPrintFormatter (formatter, page);

					page = formatter.StartPage + formatter.PageCount - 1;

					previousFormatterMaxY = formatter.RectangleForPage (page).Bottom;
				});
			}
		}