public List<PageItem> Process(int Flags, byte[] RecordData) { MemoryStream _ms = null; BinaryReader _br = null; try { _ms = new MemoryStream(RecordData); _br = new BinaryReader(_ms); Byte[] PrivateData = _br.ReadBytes(RecordData.Length); //Ok we should have our private data which I am storing my tooltip value in... //now lets interpret it... string PData = new System.Text.ASCIIEncoding().GetString(PrivateData); //If string starts with "ToolTip" then lets do something with it.. otherwise I don't care about it. if (PData.StartsWith("ToolTip")) { PageRectangle pr = new PageRectangle(); StyleInfo si = new StyleInfo(); pr.SI = si; //si.BackgroundColor = Color.Blue;// Just a test to see where the tooltip is being drawn string[] ttd = PData.Split('|'); pr.Tooltip = ttd[0].Split(':')[1]; pr.X = X + Single.Parse(ttd[1].Split(':')[1]) * SCALEFACTOR; pr.Y = Y + Single.Parse(ttd[2].Split(':')[1]) * SCALEFACTOR; pr.W = Single.Parse(ttd[3].Split(':')[1]) * SCALEFACTOR; pr.H = Single.Parse(ttd[4].Split(':')[1]) * SCALEFACTOR; items.Add(pr); } else if (PData.StartsWith("PolyToolTip")) { PagePolygon pp = new PagePolygon(); StyleInfo si = new StyleInfo(); pp.SI = si; //si.BackgroundColor = Color.Blue;// Just a test to see where the tooltip is being drawn string[] ttd = PData.Split('|'); PointF[] pts = new PointF[(ttd.Length - 1) / 2]; pp.Points = pts; pp.Tooltip = ttd[0].Split(':')[1]; for (int i = 0; i < pts.Length; i++) { pts[i].X = X + Single.Parse(ttd[i*2 +1]) * SCALEFACTOR; pts[i].Y = Y + Single.Parse(ttd[i*2 +2]) * SCALEFACTOR; } items.Add(pp); } return items; } finally { if (_br != null) _br.Close(); if (_ms != null) _ms.Dispose(); } }
private void FillPolygon(PagePolygon pp, Graphics g, RectangleF r) { StyleInfo si = pp.SI; PointF[] tmp = new PointF[pp.Points.Length]; if (!si.BackgroundColor.IsEmpty) { for (int i = 0; i < pp.Points.Length; i++) { tmp[i].X = PixelsX(pp.Points[i].X); tmp[i].Y = PixelsY(pp.Points[i].Y); } g.FillPolygon(new SolidBrush(si.BackgroundColor), tmp); } }
private void AddObjectInternal(PageItem pi) { pi.Page = this; pi.ItemNumber = _items.Count; if (_items.Count == 0) { _lastZIndex = pi.ZIndex; } else if (_lastZIndex != pi.ZIndex) { _needSort = true; } // adjust the page item locations pi.X += _xOffset; pi.Y += _yOffset; if (pi is PageLine) { PageLine pl = pi as PageLine; pl.X2 += _xOffset; pl.Y2 += _yOffset; } else if (pi is PagePolygon) { PagePolygon pp = pi as PagePolygon; for (int i = 0; i < pp.Points.Length; i++) { pp.Points[i].X += _xOffset; pp.Points[i].Y += _yOffset; } } else if (pi is PageCurve) { PageCurve pc = pi as PageCurve; for (int i = 0; i < pc.Points.Length; i++) { pc.Points[i].X += _xOffset; pc.Points[i].Y += _yOffset; } } }
private void DoInstructions(PointF[] Ps, Brush b) { PagePolygon pl = new PagePolygon(); //pl.X = X * SCALEFACTOR; //pl.Y = Y * SCALEFACTOR; pl.Points = Ps; StyleInfo SI = new StyleInfo(); switch (b.GetType().Name) { case "SolidBrush": System.Drawing.SolidBrush theBrush = (System.Drawing.SolidBrush)b; SI.Color = theBrush.Color; SI.BackgroundColor = theBrush.Color; break; case "LinearGradientBrush": System.Drawing.Drawing2D.LinearGradientBrush linBrush = (System.Drawing.Drawing2D.LinearGradientBrush)b; SI.BackgroundGradientType = BackgroundGradientTypeEnum.LeftRight; SI.BackgroundColor = linBrush.LinearColors[0]; SI.BackgroundGradientEndColor = linBrush.LinearColors[1]; break; case "HatchBrush": System.Drawing.Drawing2D.HatchBrush hatBrush = (System.Drawing.Drawing2D.HatchBrush)b; SI.BackgroundColor = hatBrush.BackgroundColor; SI.Color = hatBrush.ForegroundColor; SI.PatternType = StyleInfo.GetPatternType(hatBrush.HatchStyle); break; default: break; } pl.SI = SI; items.Add(pl); }
internal HitListEntry(PagePolygon pp, float x, float y, PageDrawing pd) { pi = pp; poly = new PointF[pp.Points.Length]; for (int i = 0; i < pp.Points.Length; i++) { poly[i].X = pd.PixelsX(pp.Points[i].X + x); poly[i].Y = pd.PixelsY(pp.Points[i].Y + y); } rect = RectangleF.Empty; }
private void FillPolygon(PagePolygon pp, Graphics g, RectangleF r) { StyleInfo si = pp.SI; PointF[] tmp = new PointF[pp.Points.Length]; if (!si.BackgroundColor.IsEmpty) //RectangleF(PixelsX(pi.X + _left - _hScroll), PixelsY(pi.Y + _top - _vScroll), // PixelsX(pi.W), PixelsY(pi.H)) { for (int i = 0; i < pp.Points.Length; i++) { tmp[i].X = PixelsX(pp.Points[i].X + _left - _hScroll); tmp[i].Y = PixelsY(pp.Points[i].Y + _top - _vScroll); } g.FillPolygon(new SolidBrush(si.BackgroundColor), tmp); } }
public List <PageItem> Process(int Flags, byte[] RecordData) { MemoryStream _ms = null; BinaryReader _br = null; try { _ms = new MemoryStream(RecordData); _br = new BinaryReader(_ms); Byte[] PrivateData = _br.ReadBytes(RecordData.Length); //Ok we should have our private data which I am storing my tooltip value in... //now lets interpret it... string PData = new System.Text.ASCIIEncoding().GetString(PrivateData); //If string starts with "ToolTip" then lets do something with it.. otherwise I don't care about it. if (PData.StartsWith("ToolTip")) { PageRectangle pr = new PageRectangle(); StyleInfo si = new StyleInfo(); pr.SI = si; //si.BackgroundColor = Color.Blue;// Just a test to see where the tooltip is being drawn string[] ttd = PData.Split('|'); pr.Tooltip = ttd[0].Split(':')[1]; pr.X = X + Single.Parse(ttd[1].Split(':')[1]) * SCALEFACTOR; pr.Y = Y + Single.Parse(ttd[2].Split(':')[1]) * SCALEFACTOR; pr.W = Single.Parse(ttd[3].Split(':')[1]) * SCALEFACTOR; pr.H = Single.Parse(ttd[4].Split(':')[1]) * SCALEFACTOR; items.Add(pr); } else if (PData.StartsWith("PolyToolTip")) { PagePolygon pp = new PagePolygon(); StyleInfo si = new StyleInfo(); pp.SI = si; //si.BackgroundColor = Color.Blue;// Just a test to see where the tooltip is being drawn string[] ttd = PData.Split('|'); PointF[] pts = new PointF[(ttd.Length - 1) / 2]; pp.Points = pts; pp.Tooltip = ttd[0].Split(':')[1]; for (int i = 0; i < pts.Length; i++) { pts[i].X = X + Single.Parse(ttd[i * 2 + 1]) * SCALEFACTOR; pts[i].Y = Y + Single.Parse(ttd[i * 2 + 2]) * SCALEFACTOR; } items.Add(pp); } return(items); } finally { if (_br != null) { _br.Close(); } if (_ms != null) { _ms.Dispose(); } } }
/// <summary> /// Render all the objects in a page /// </summary> private void processPage(Pages pages, IEnumerable page) { //loop thru the items in the page foreach (PageItem pageItem in page) { if (pageItem.SI.BackgroundImage != null) { //put out any background image PageImage backgroundImage = pageItem.SI.BackgroundImage; float imageWidth = RSize.PointsFromPixels(pages.G, backgroundImage.SamplesW); float imageHeight = RSize.PointsFromPixels(pages.G, backgroundImage.SamplesH); int repeatX = 0; int repeatY = 0; float itemWidth = pageItem.W - (pageItem.SI.PaddingLeft + pageItem.SI.PaddingRight); float itemHeight = pageItem.H - (pageItem.SI.PaddingTop + pageItem.SI.PaddingBottom); switch (backgroundImage.Repeat) { case ImageRepeat.Repeat: repeatX = (int)Math.Floor(itemWidth / imageWidth); repeatY = (int)Math.Floor(itemHeight / imageHeight); break; case ImageRepeat.RepeatX: repeatX = (int)Math.Floor(itemWidth / imageWidth); repeatY = 1; break; case ImageRepeat.RepeatY: repeatY = (int)Math.Floor(itemHeight / imageHeight); repeatX = 1; break; case ImageRepeat.NoRepeat: default: repeatX = repeatY = 1; break; } //make sure the image is drawn at least 1 times repeatX = Math.Max(repeatX, 1); repeatY = Math.Max(repeatY, 1); float currX = pageItem.X + pageItem.SI.PaddingLeft; float currY = pageItem.Y + pageItem.SI.PaddingTop; float startX = currX; float startY = currY; for (int i = 0; i < repeatX; i++) { for (int j = 0; j < repeatY; j++) { currX = startX + i * imageWidth; currY = startY + j * imageHeight; addImage(backgroundImage.SI, currX, currY, imageWidth, imageHeight, RectangleF.Empty, backgroundImage.ImageData, null, pageItem.Tooltip); } } } else if (pageItem is PageTextHtml) { PageTextHtml pageTextHtml = pageItem as PageTextHtml; pageTextHtml.Build(pages.G); processPage(pages, pageTextHtml); continue; } else if (pageItem is PageText) { PageText pageText = pageItem as PageText; float[] textwidth; string[] measureStrings = RenderUtility.MeasureString(pageText, pages.G, out textwidth); addText(pageText.X, pageText.Y, pageText.W, pageText.H, measureStrings, pageText.SI, textwidth, pageText.CanGrow, pageText.HyperLink, pageText.NoClip, pageText.Tooltip); continue; } else if (pageItem is PageLine) { PageLine pageLine = pageItem as PageLine; addLine(pageLine.X, pageLine.Y, pageLine.X2, pageLine.Y2, pageLine.SI); continue; } else if (pageItem is PageEllipse) { PageEllipse pageEllipse = pageItem as PageEllipse; addEllipse(pageEllipse.X, pageEllipse.Y, pageEllipse.W, pageEllipse.H, pageEllipse.SI, pageEllipse.HyperLink); continue; } else if (pageItem is PageImage) { PageImage pageImage = pageItem as PageImage; //Duc Phan added 20 Dec, 2007 to support sized image RectangleF r2 = new RectangleF(pageImage.X + pageImage.SI.PaddingLeft, pageImage.Y + pageImage.SI.PaddingTop, pageImage.W - pageImage.SI.PaddingLeft - pageImage.SI.PaddingRight, pageImage.H - pageImage.SI.PaddingTop - pageImage.SI.PaddingBottom); //work rectangle RectangleF adjustedRect; RectangleF clipRect = RectangleF.Empty; switch (pageImage.Sizing) { case ImageSizingEnum.AutoSize: adjustedRect = new RectangleF(r2.Left, r2.Top, r2.Width, r2.Height); break; case ImageSizingEnum.Clip: adjustedRect = new RectangleF(r2.Left, r2.Top, RSize.PointsFromPixels(pages.G, pageImage.SamplesW), RSize.PointsFromPixels(pages.G, pageImage.SamplesH)); clipRect = new RectangleF(r2.Left, r2.Top, r2.Width, r2.Height); break; case ImageSizingEnum.FitProportional: float height; float width; float ratioIm = (float)pageImage.SamplesH / pageImage.SamplesW; float ratioR = r2.Height / r2.Width; height = r2.Height; width = r2.Width; if (ratioIm > ratioR) { //this means the rectangle width must be corrected width = height * (1 / ratioIm); } else if (ratioIm < ratioR) { //this means the rectangle height must be corrected height = width * ratioIm; } adjustedRect = new RectangleF(r2.X, r2.Y, width, height); break; case ImageSizingEnum.Fit: default: adjustedRect = r2; break; } if (pageImage.ImgFormat != System.Drawing.Imaging.ImageFormat.Wmf && pageImage.ImgFormat != System.Drawing.Imaging.ImageFormat.Emf) { addImage(pageImage.SI, adjustedRect.X, adjustedRect.Y, adjustedRect.Width, adjustedRect.Height, clipRect, pageImage.ImageData, pageImage.HyperLink, pageImage.Tooltip); } continue; } else if (pageItem is PageRectangle) { PageRectangle pageRectangle = pageItem as PageRectangle; addRectangle(pageRectangle.X, pageRectangle.Y, pageRectangle.W, pageRectangle.H, pageItem.SI, pageItem.HyperLink, pageItem.Tooltip); continue; } else if (pageItem is PagePie) { PagePie pagePie = pageItem as PagePie; addPie(pagePie.X, pagePie.Y, pagePie.W, pagePie.H, pageItem.SI, pageItem.HyperLink, pageItem.Tooltip); continue; } else if (pageItem is PagePolygon) { PagePolygon pagePolygon = pageItem as PagePolygon; addPolygon(pagePolygon.Points, pageItem.SI, pageItem.HyperLink); continue; } else if (pageItem is PageCurve) { PageCurve pageCurve = pageItem as PageCurve; addCurve(pageCurve.Points, pageItem.SI); continue; } } }
private void ProcessPage(Graphics g, IEnumerable p) { foreach (PageItem pi in p) { if (pi is PageTextHtml) { // PageTextHtml is actually a composite object (just like a page) ProcessHtml(pi as PageTextHtml, g); continue; } if (pi is PageLine) { PageLine pl = pi as PageLine; DrawLine( pl.SI.BColorLeft, pl.SI.BStyleLeft, pl.SI.BWidthLeft, g, PixelsX(pl.X), PixelsY(pl.Y), PixelsX(pl.X2), PixelsY(pl.Y2) ); continue; } RectangleF rect = new RectangleF(PixelsX(pi.X), PixelsY(pi.Y), PixelsX(pi.W), PixelsY(pi.H)); if (pi.SI.BackgroundImage != null) { // put out any background image PageImage i = pi.SI.BackgroundImage; DrawImage(i, g, rect); } if (pi is PageText) { PageText pt = pi as PageText; DrawString(pt, g, rect); } else if (pi is PageImage) { PageImage i = pi as PageImage; DrawImage(i, g, rect); } else if (pi is PageRectangle) { this.DrawBackground(g, rect, pi.SI); } else if (pi is PageEllipse) { PageEllipse pe = pi as PageEllipse; DrawEllipse(pe, g, rect); } else if (pi is PagePie) { PagePie pp = pi as PagePie; DrawPie(pp, g, rect); } else if (pi is PagePolygon) { PagePolygon ppo = pi as PagePolygon; FillPolygon(ppo, g, rect); } else if (pi is PageCurve) { PageCurve pc = pi as PageCurve; DrawCurve(pc.SI.BColorLeft, pc.SI.BStyleLeft, pc.SI.BWidthLeft, g, pc.Points, pc.Offset, pc.Tension); } DrawBorder(pi, g, rect); } }