/// <summary> /// Pre-Processes the HTML prior to rendering it in a page. /// </summary> public static void ProcessHtml(PageTextHtml pth, Graphics g, RectangleF clipRect, bool bHitList, CanvasProperties cp, ref PageItemManager cpim) { pth.Build(g); // Builds the subobjects that make up the html CanvasPainter.ProcessPage(g, pth, clipRect, bHitList, cp, ref cpim); }
/// <summary> /// Renders all the objects in a Page or composite object. /// </summary> private static void ProcessPage(Graphics g, IEnumerable p, RectangleF clipRect, bool bHitList, CanvasProperties cp, ref PageItemManager cpim) { foreach (PageItem pi in p) { if (pi is PageTextHtml) { // PageTextHtml is actually a composite object (just like a page) if (cpim.SelectToolEnabled && bHitList) { RectangleF hr = new RectangleF( Measurement.PixelsFromPoints(pi.X + cp.Left - cp.Scroll.X, cp.Dpi.X), Measurement.PixelsFromPoints(pi.Y + cp.Scroll.X - cp.Scroll.Y, cp.Dpi.Y), Measurement.PixelsFromPoints(pi.W, cp.Dpi.X), Measurement.PixelsFromPoints(pi.H, cp.Dpi.Y)); cpim.HitList.Add(new HitListEntry(hr, pi)); } ProcessHtml(pi as PageTextHtml, g, clipRect, bHitList, cp, ref cpim); continue; } if (pi is PageLine) { PageLine pl = pi as PageLine; CanvasPainter.DrawLine( pl.SI.BColorLeft, pl.SI.BStyleLeft, pl.SI.BWidthLeft, g, Measurement.PixelsFromPoints(pl.X + cp.Left - cp.Scroll.X, cp.Dpi.X), Measurement.PixelsFromPoints(pl.Y + cp.Top - cp.Scroll.Y, cp.Dpi.Y), Measurement.PixelsFromPoints(pl.X2 + cp.Left - cp.Scroll.X, cp.Dpi.X), Measurement.PixelsFromPoints(pl.Y2 + cp.Top - cp.Scroll.Y, cp.Dpi.Y)); continue; } RectangleF rect = new RectangleF( Measurement.PixelsFromPoints(pi.X + cp.Left - cp.Scroll.X, cp.Dpi.X), Measurement.PixelsFromPoints(pi.Y + cp.Top - cp.Scroll.Y, cp.Dpi.Y), Measurement.PixelsFromPoints(pi.W, cp.Dpi.X), Measurement.PixelsFromPoints(pi.H, cp.Dpi.Y)); // Maintain the hit list if (bHitList) { if (cpim.SelectToolEnabled) { // we need all PageText and PageImage items that have been displayed if (pi is PageText || pi is PageImage) { cpim.HitList.Add(new HitListEntry(rect, pi)); } } // Only care about items with links and tips else if (pi.HyperLink != null || pi.BookmarkLink != null || pi.Tooltip != null) { HitListEntry hle; if (pi is PagePolygon) { hle = new HitListEntry(pi as PagePolygon, cp.Left - cp.Scroll.X, cp.Top - cp.Scroll.Y, ((Canvas)cp.Parent)); } else { hle = new HitListEntry(rect, pi); } cpim.HitList.Add(hle); } } if ((pi is PagePolygon) || (pi is PageCurve)) { // intentionally empty; polygon's rectangles aren't calculated } else if (!rect.IntersectsWith(clipRect)) { continue; } if (pi.SI.BackgroundImage != null) { // put out any background image PageImage i = pi.SI.BackgroundImage; CanvasPainter.DrawImageBackground(i, pi.SI, g, rect); } if (pi is PageText) { PageText pt = pi as PageText; CanvasPainter.DrawString(pt, g, rect, cp, cpim); } else if (pi is PageImage) { PageImage i = pi as PageImage; CanvasPainter.DrawImage(i, g, rect, cp, cpim); } else if (pi is PageRectangle) { CanvasPainter.DrawBackground(g, rect, pi.SI); } else if (pi is PageEllipse) { PageEllipse pe = pi as PageEllipse; CanvasPainter.DrawEllipse(pe, g, rect); } else if (pi is PagePie) { PagePie pp = pi as PagePie; CanvasPainter.DrawPie(pp, g, rect); } else if (pi is PagePolygon) { PagePolygon ppo = pi as PagePolygon; CanvasPainter.FillPolygon(ppo, g, rect, cp); } else if (pi is PageCurve) { PageCurve pc = pi as PageCurve; CanvasPainter.DrawCurve(pc.SI.BColorLeft, pc.SI.BStyleLeft, pc.SI.BWidthLeft, g, pc.Points, pc.Offset, pc.Tension, cp); } CanvasPainter.DrawBorder(pi, g, rect); } }