Exemple #1
0
        private void DoInstructions(Single recX, Single recY, Single recWidth, Single recHeight, Pen p)
        {
            BorderStyleEnum ls = getLineStyle(p);

            switch (p.Brush.GetType().Name)
            {
            case "SolidBrush":
                System.Drawing.SolidBrush theBrush = (System.Drawing.SolidBrush)p.Brush;
                PageRectangle             pl       = new PageRectangle();
                pl.X = X + recX * SCALEFACTOR;
                pl.Y = Y + recY * SCALEFACTOR;
                pl.W = recWidth * SCALEFACTOR;
                pl.H = recHeight * SCALEFACTOR;

                StyleInfo SI = new StyleInfo();
                SI.Color     = theBrush.Color;
                SI.BColorTop = SI.BColorBottom = SI.BColorLeft = SI.BColorRight = theBrush.Color;
                SI.BStyleTop = SI.BStyleBottom = SI.BStyleLeft = SI.BStyleRight = ls;
                SI.BWidthTop = SI.BWidthBottom = SI.BWidthLeft = SI.BWidthRight = p.Width * SCALEFACTOR;
                pl.SI        = SI;
                items.Add(pl);
                break;

            default:
                break;
            }
        }
Exemple #2
0
        // render all the objects in a page in PDF
        private void ProcessPage(Pages pgs, IEnumerable items)
        {
            foreach (PageItem pi in items)
            {
                if (pi.SI.BackgroundImage != null)
                {                       // put out any background image
                    PageImage i = pi.SI.BackgroundImage;
                    elements.AddImage(images, i.Name, content.objectNum, i.SI, i.ImgFormat,
                                      pi.X, pi.Y, pi.W, pi.H, i.ImageData, i.SamplesW, i.SamplesH, null);
                }

                if (pi is PageTextHtml)
                {
                    PageTextHtml pth = pi as PageTextHtml;
                    pth.Build(pgs.G);
                    ProcessPage(pgs, pth);
                    continue;
                }

                if (pi is PageText)
                {
                    PageText pt = pi as PageText;
                    float[]  textwidth;
                    string[] sa = MeasureString(pt, pgs.G, out textwidth);
                    elements.AddText(pt.X, pt.Y, pt.H, pt.W, sa, pt.SI,
                                     fonts, textwidth, pt.CanGrow, pt.HyperLink, pt.NoClip);
                    if (pt.BookmarkLink != null)
                    {
                        outline.Bookmarks.Add(new PdfOutlineEntry(anchor, page.objectNum, pt.BookmarkLink, pt.X, elements.PageSize.yHeight - pt.Y));
                    }
                    continue;
                }

                if (pi is PageLine)
                {
                    PageLine pl = pi as PageLine;
                    elements.AddLine(pl.X, pl.Y, pl.X2, pl.Y2, pl.SI);
                    continue;
                }

                if (pi is PageImage)
                {
                    PageImage i = pi as PageImage;
                    float     x = i.X + i.SI.PaddingLeft;
                    float     y = i.Y + i.SI.PaddingTop;
                    float     w = i.W - i.SI.PaddingLeft - i.SI.PaddingRight;
                    float     h = i.H - i.SI.PaddingTop - i.SI.PaddingBottom;
                    elements.AddImage(images, i.Name, content.objectNum, i.SI, i.ImgFormat,
                                      x, y, w, h, i.ImageData, i.SamplesW, i.SamplesH, i.HyperLink);
                    continue;
                }

                if (pi is PageRectangle)
                {
                    PageRectangle pr = pi as PageRectangle;
                    elements.AddRectangle(pr.X, pr.Y, pr.H, pr.W, pi.SI, pi.HyperLink);
                    continue;
                }
            }
        }
        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();

            }
        }
Exemple #4
0
        override internal void RunPage(Pages pgs, Row row)
        {
            Report r       = pgs.Report;
            bool   bHidden = IsHidden(r, row);

            SetPagePositionBegin(pgs);

            // Handle page breaking at start
            if (this.PageBreakAtStart && !IsTableOrMatrixCell(r) && !pgs.CurrentPage.IsEmpty() && !bHidden)
            {   // force page break at beginning of dataregion
                pgs.NextOrNew();
                pgs.CurrentPage.YOffset = OwnerReport.TopOfPage;
            }

            PageRectangle pr = new PageRectangle();

            SetPagePositionAndStyle(r, pr, row);
            if (pr.SI.BackgroundImage != null)
            {
                pr.SI.BackgroundImage.H = pr.H;                         //   and in the background image
            }
            if (!bHidden)
            {
                Page p = pgs.CurrentPage;
                p.AddObject(pr);

                if (_ReportItems != null)
                {
                    float saveY = p.YOffset;
                    //             p.YOffset += (Top == null ? 0 : this.Top.Points);
                    p.YOffset = pr.Y;       // top of rectangle is base for contained report items
                    _ReportItems.RunPage(pgs, row, GetOffsetCalc(pgs.Report) + LeftCalc(r));
                    p.YOffset = saveY;
                }

                // Handle page breaking at end
                if (this.PageBreakAtEnd && !IsTableOrMatrixCell(r) && !pgs.CurrentPage.IsEmpty())
                {       // force page break at beginning of dataregion
                    pgs.NextOrNew();
                    pgs.CurrentPage.YOffset = OwnerReport.TopOfPage;
                }
            }
//			SetPagePositionEnd(pgs, pgs.CurrentPage.YOffset);
            SetPagePositionEnd(pgs, pr.Y + pr.H);
        }
        private void DoInstructions(Single recX, Single recY, Single recWidth, Single recHeight, Brush b)
        {
            PageRectangle pl = new PageRectangle();
            StyleInfo     SI = new StyleInfo();

            pl.X = X + recX * SCALEFACTOR;
            pl.Y = Y + recY * SCALEFACTOR;
            pl.W = recWidth * SCALEFACTOR;
            pl.H = recHeight * SCALEFACTOR;

            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);
        }
Exemple #6
0
        // render all the objects in a page in PDF
        private void ProcessPage(Pages pgs, IEnumerable items)
        {
            foreach (PageItem pi in items)
            {
                if (pi.SI.BackgroundImage != null)
                {                       // put out any background image
                    PageImage bgImg = pi.SI.BackgroundImage;
//					elements.AddImage(images, i.Name, content.objectNum, i.SI, i.ImgFormat,
//						pi.X, pi.Y, pi.W, pi.H, i.ImageData,i.SamplesW, i.SamplesH, null);

                    //Duc Phan modified 10 Dec, 2007 to support on background image
                    float imW     = RSize.PointsFromPixels(pgs.G, bgImg.SamplesW);
                    float imH     = RSize.PointsFromPixels(pgs.G, bgImg.SamplesH);
                    int   repeatX = 0;
                    int   repeatY = 0;
                    float itemW   = pi.W - (pi.SI.PaddingLeft + pi.SI.PaddingRight);
                    float itemH   = pi.H - (pi.SI.PaddingTop + pi.SI.PaddingBottom);
                    switch (bgImg.Repeat)
                    {
                    case ImageRepeat.Repeat:
                        repeatX = (int)Math.Floor(itemW / imW);
                        repeatY = (int)Math.Floor(itemH / imH);
                        break;

                    case ImageRepeat.RepeatX:
                        repeatX = (int)Math.Floor(itemW / imW);
                        repeatY = 1;
                        break;

                    case ImageRepeat.RepeatY:
                        repeatY = (int)Math.Floor(itemH / imH);
                        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  = pi.X + pi.SI.PaddingLeft;
                    float currY  = pi.Y + pi.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 * imW;
                            currY = startY + j * imH;
                            elements.AddImage(images, bgImg.Name,
                                              content.objectNum, bgImg.SI, bgImg.ImgFormat,
                                              currX, currY, imW, imH, RectangleF.Empty, bgImg.ImageData, bgImg.SamplesW, bgImg.SamplesH, null);
                        }
                    }
                }

                if (pi is PageTextHtml)
                {
                    PageTextHtml pth = pi as PageTextHtml;
                    pth.Build(pgs.G);
                    ProcessPage(pgs, pth);
                    continue;
                }

                if (pi is PageText)
                {
                    PageText pt = pi as PageText;

                    float[]  textwidth;
                    string[] sa = MeasureString(pt, pgs.G, out textwidth);
                    elements.AddText(pt.X, pt.Y, pt.H, pt.W, sa, pt.SI,
                                     fonts, textwidth, pt.CanGrow, pt.HyperLink, pt.NoClip);
                    if (pt.Bookmark != null)
                    {
                        outline.Bookmarks.Add(new PdfOutlineEntry(anchor, page.objectNum, pt.Bookmark, pt.X, elements.PageSize.yHeight - pt.Y));
                    }
                    continue;
                }

                if (pi is PageLine)
                {
                    PageLine pl = pi as PageLine;
                    elements.AddLine(pl.X, pl.Y, pl.X2, pl.Y2, pl.SI);
                    continue;
                }

                if (pi is PageImage)
                {
                    //PageImage i = pi as PageImage;
                    //float x = i.X + i.SI.PaddingLeft;
                    //float y = i.Y + i.SI.PaddingTop;
                    //float w = i.W - i.SI.PaddingLeft - i.SI.PaddingRight;
                    //float h = i.H - i.SI.PaddingTop - i.SI.PaddingBottom;
                    //elements.AddImage(images, i.Name, content.objectNum, i.SI, i.ImgFormat,
                    //    x, y, w, h, i.ImageData,i.SamplesW, i.SamplesH, i.HyperLink);
                    //continue;

                    PageImage i = pi as PageImage;

                    //Duc Phan added 20 Dec, 2007 to support sized image
                    RectangleF r2 = new RectangleF(i.X + i.SI.PaddingLeft, i.Y + i.SI.PaddingTop, i.W - i.SI.PaddingLeft - i.SI.PaddingRight, i.H - i.SI.PaddingTop - i.SI.PaddingBottom);

                    RectangleF adjustedRect;   // work rectangle
                    RectangleF clipRect = RectangleF.Empty;

                    switch (i.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,
                                                      i.SamplesW, i.SamplesH);
                        clipRect = new RectangleF(r2.Left, r2.Top,
                                                  r2.Width, r2.Height);
                        break;

                    case ImageSizingEnum.FitProportional:
                        float height;
                        float width;
                        float ratioIm = (float)i.SamplesH / i.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;
                    }

                    elements.AddImage(images, i.Name, content.objectNum, i.SI, i.ImgFormat,
                                      adjustedRect.X, adjustedRect.Y, adjustedRect.Width, adjustedRect.Height, clipRect, i.ImageData, i.SamplesW, i.SamplesH, i.HyperLink);
                    continue;
                }

                if (pi is PageRectangle)
                {
                    PageRectangle pr = pi as PageRectangle;
                    elements.AddRectangle(pr.X, pr.Y, pr.H, pr.W, pi.SI, pi.HyperLink);
                    continue;
                }
            }
        }
        private void DrawRectangle(PageRectangle pr, StringBuilder sb, Rectangle r)
        {
            StyleInfo si = pr.SI;

            // adjust drawing rectangle based on padding
            //PJR recalculating width needs to ADD the padding values not SUBTRACT 
            Rectangle r2 = new Rectangle(r.X + PixelsX(si.PaddingLeft),
                               r.Y + PixelsY(si.PaddingTop),
                               r.Width - PixelsX(si.PaddingLeft + si.PaddingRight),
                               r.Height - PixelsY(si.PaddingTop + si.PaddingBottom));

            sb.AppendFormat("<Rectangle Canvas.Left=\"{0}\" Canvas.Top=\"{1}\" Height=\"{2}\" Width=\"{3}\">",
                r2.Left, r2.Top, r2.Height, r2.Width);
            sb.Append("<Rectangle.Fill>");
            DrawBackground(sb, si);
            sb.Append("</Rectangle.Fill>");
            sb.Append("</Rectangle>");
        }
Exemple #8
0
        /// <summary>
        /// 处理单个页面。
        /// </summary>
        /// <param name="pgs"></param>
        /// <param name="items"></param>
        private void ProcessPage(Pages pgs, IEnumerable items)
        {
            foreach (PageItem pi in items)
            {
                //if (pi.SI.BackgroundImage != null)
                //{
                //    PageImage bgImg = pi.SI.BackgroundImage;
                //    iTextSharp.text.Image image = iTextSharp.text.Image.GetInstance(bgImg.ImageData);
                //    document.Add(image);
                //}

                if (pi is PageTextHtml)
                {
                    PageTextHtml pth = pi as PageTextHtml;
                    pth.Build(pgs.G);
                    ProcessPage(pgs, pth);
                    continue;
                }

                if (pi is PageText)
                {
                    PageText pt = pi as PageText;

                    iTextSharp.text.pdf.PdfContentByte cb = this.pdfWriter.DirectContent;

                    float y = getYvalue(pi.Y, pt.H);

                    //边线

                    if (pi.SI.BStyleLeft != BorderStyleEnum.None)
                    {
                        cb.MoveTo(pt.X, y);
                        cb.SetLineWidth(pi.SI.BWidthLeft);
                        cb.SetRGBColorStrokeF(pi.SI.BColorLeft.R, pi.SI.BColorLeft.G, pi.SI.BColorLeft.B);

                        cb.LineTo(pt.X, y + pt.H);

                        cb.Stroke();
                    }

                    if (pi.SI.BStyleRight != BorderStyleEnum.None)
                    {
                        cb.MoveTo(pt.X + pt.W, y);
                        cb.SetLineWidth(pi.SI.BWidthRight);
                        cb.SetRGBColorStrokeF(pi.SI.BColorRight.R, pi.SI.BColorRight.G, pi.SI.BColorRight.B);

                        cb.LineTo(pt.X + pt.W, y + pt.H);

                        cb.Stroke();
                    }

                    if (pi.SI.BStyleTop != BorderStyleEnum.None)
                    {
                        cb.MoveTo(pt.X, y + pt.H);
                        cb.SetLineWidth(pi.SI.BWidthTop);
                        cb.SetRGBColorStrokeF(pi.SI.BColorTop.R, pi.SI.BColorTop.G, pi.SI.BColorTop.B);

                        cb.LineTo(pt.X + pt.W, y + pt.H);

                        cb.Stroke();
                    }

                    if (pi.SI.BStyleBottom != BorderStyleEnum.None)
                    {
                        cb.MoveTo(pt.X, y);
                        cb.SetLineWidth(pi.SI.BWidthTop);
                        cb.SetRGBColorStrokeF(pi.SI.BColorTop.R, pi.SI.BColorTop.G, pi.SI.BColorTop.B);

                        cb.LineTo(pt.X + pt.W, y);

                        cb.Stroke();
                    }

                    //绝对定义文字

                    iTextSharp.text.Font font = TextUtility.GetFont(pi.SI, pt.Text);

                    float[]  widih;
                    string[] sa = MeasureString(pt, pgs.G, out widih);

                    int rows = sa.Length;

                    //x标准固定

                    float x     = pt.X + pi.SI.PaddingLeft;
                    int   align = iTextSharp.text.pdf.PdfContentByte.ALIGN_LEFT;

                    if (pi.SI.TextAlign == TextAlignEnum.Right)
                    {
                        align = iTextSharp.text.pdf.PdfContentByte.ALIGN_RIGHT;
                        x     = pt.X + pt.W - pi.SI.PaddingRight - 1;
                    }
                    else if (pi.SI.TextAlign == TextAlignEnum.Center)
                    {
                        align = iTextSharp.text.pdf.PdfContentByte.ALIGN_CENTER;
                        x     = pt.X + pt.W / 2;
                    }

                    cb.BeginText();
                    cb.SetFontAndSize(font.BaseFont, font.Size);

                    for (int i = 0; i < rows; i++)
                    {
                        float Yt = y + i * font.Size + 1;

                        if (pi.SI.VerticalAlign == VerticalAlignEnum.Top)
                        {
                            Yt = y + pt.H - font.Size * (rows - (i + 1)) - 1;
                        }
                        else if (pi.SI.VerticalAlign == VerticalAlignEnum.Middle)
                        {
                            Yt = y + (pt.H - font.Size * rows) / 2 + i * font.Size + 1;
                        }

                        cb.ShowTextAligned(align, sa[rows - i - 1], x, Yt, 0);
                        cb.EndText();
                    }

                    continue;
                }

                if (pi is PageLine)
                {
                    PageLine pl = pi as PageLine;

                    iTextSharp.text.pdf.PdfContentByte cb = this.pdfWriter.DirectContent;

                    float y1 = getYvalue(pl.Y, 0);
                    float y2 = getYvalue(pl.Y2, 0);

                    cb.MoveTo(pl.X, y1);
                    cb.LineTo(pl.X2, y2);

                    cb.Stroke();

                    continue;
                }

                if (pi is PageImage)
                {
                    PageImage i = pi as PageImage;

                    iTextSharp.text.pdf.PdfContentByte cb = this.pdfWriter.DirectContent;

                    float y = this.getYvalue(i.Y, i.H);

                    System.Drawing.RectangleF r2 = new System.Drawing.RectangleF(i.X + i.SI.PaddingLeft, y - i.SI.PaddingTop, i.W - i.SI.PaddingLeft - i.SI.PaddingRight, i.H - i.SI.PaddingTop - i.SI.PaddingBottom);

                    iTextSharp.text.Image image = iTextSharp.text.Image.GetInstance(i.ImageData);

                    image.SetAbsolutePosition(i.X, y);
                    image.ScaleAbsoluteHeight(i.H);
                    image.ScaleAbsoluteWidth(i.W);

                    cb.AddImage(image);

                    cb.Stroke();

                    continue;
                }

                if (pi is PageRectangle)
                {
                    PageRectangle pr = pi as PageRectangle;

                    iTextSharp.text.Rectangle r2 = new iTextSharp.text.Rectangle(pr.X, pr.Y, pr.W, pr.H);
                    r2.Border = 1;
                    document.Add(r2);
                    continue;
                }
            }
        }
Exemple #9
0
        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();
                }
            }
        }
Exemple #10
0
     private void DoInstructions(Single recX, Single recY, Single recWidth, Single recHeight, Brush b)
     {
         PageRectangle pl = new PageRectangle();
         StyleInfo SI = new StyleInfo();            
 		pl.X = X + recX * SCALEFACTOR;
         pl.Y = Y + recY * SCALEFACTOR;
         pl.W = recWidth * SCALEFACTOR;
         pl.H = recHeight * SCALEFACTOR; 
                 
         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);
     }
        private void DrawRectangle(PageRectangle pr, StringBuilder sb, Rectangle r)
        {
            StyleInfo si = pr.SI;

            // adjust drawing rectangle based on padding
            Rectangle r2 = new Rectangle(r.Left + PixelsX(si.PaddingLeft),
                                           r.Top + PixelsY(si.PaddingTop),
                                           r.Width - PixelsX(si.PaddingLeft - si.PaddingRight),
                                           r.Height - PixelsY(si.PaddingTop - si.PaddingBottom));

            sb.AppendFormat("<Rectangle Canvas.Left=\"{0}\" Canvas.Top=\"{1}\" Height=\"{2}\" Width=\"{3}\">",
                r2.Left, r2.Top, r2.Height, r2.Width);
            sb.Append("<Rectangle.Fill>");
            DrawBackground(sb, si);
            sb.Append("</Rectangle.Fill>");
            sb.Append("</Rectangle>");
        }
Exemple #12
0
        // render all the objects in a page in PDF
        private void ProcessPage(Pages pgs, IEnumerable items)
        {
            foreach (PageItem pi in items)
            {
                if (pi.SI.BackgroundImage != null)
                {       // put out any background image
                    PageImage bgImg = pi.SI.BackgroundImage;
                    //					elements.AddImage(images, i.Name, content.objectNum, i.SI, i.ImgFormat,
                    //						pi.X, pi.Y, pi.W, pi.H, i.ImageData,i.SamplesW, i.SamplesH, null);
                    //Duc Phan modified 10 Dec, 2007 to support on background image
                    float imW     = Measurement.PointsFromPixels(bgImg.SamplesW, pgs.G.DpiX);
                    float imH     = Measurement.PointsFromPixels(bgImg.SamplesH, pgs.G.DpiY);
                    int   repeatX = 0;
                    int   repeatY = 0;
                    float itemW   = pi.W - (pi.SI.PaddingLeft + pi.SI.PaddingRight);
                    float itemH   = pi.H - (pi.SI.PaddingTop + pi.SI.PaddingBottom);
                    switch (bgImg.Repeat)
                    {
                    case ImageRepeat.Repeat:
                        repeatX = (int)Math.Floor(itemW / imW);
                        repeatY = (int)Math.Floor(itemH / imH);
                        break;

                    case ImageRepeat.RepeatX:
                        repeatX = (int)Math.Floor(itemW / imW);
                        repeatY = 1;
                        break;

                    case ImageRepeat.RepeatY:
                        repeatY = (int)Math.Floor(itemH / imH);
                        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  = pi.X + pi.SI.PaddingLeft;
                    float currY  = pi.Y + pi.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 * imW;
                            currY = startY + j * imH;



                            AddImage(bgImg.Name, bgImg.SI, bgImg.ImgFormat,
                                     currX, currY, imW, imH, RectangleF.Empty, bgImg.ImageData, bgImg.SamplesW, bgImg.SamplesH, null, pi.Tooltip);
                        }
                    }
                }

                if (pi is PageTextHtml)
                {
                    PageTextHtml pth = pi as PageTextHtml;
                    pth.Build(pgs.G);
                    ProcessPage(pgs, pth);
                    continue;
                }

                if (pi is PageText)
                {
                    PageText pt = pi as PageText;
                    float[]  textwidth;
                    string[] sa = MeasureString(pt, pgs.G, out textwidth);


                    AddText(pt.X, pt.Y, pt.H, pt.W, sa, pt.SI, textwidth, pt.CanGrow, pt.HyperLink, pt.NoClip, pt.Tooltip);

                    if (pt.Bookmark != null)
                    {
                        AddBookmark(pt);
                    }
                    continue;
                }

                if (pi is PageLine)
                {
                    PageLine pl = pi as PageLine;
                    AddLine(pl.X, pl.Y, pl.X2, pl.Y2, pl.SI);
                    continue;
                }

                if (pi is PageEllipse)
                {
                    PageEllipse pe = pi as PageEllipse;
                    AddEllipse(pe.X, pe.Y, pe.H, pe.W, pe.SI, pe.HyperLink);
                    continue;
                }



                if (pi is PageImage)
                {
                    PageImage i = pi as PageImage;

                    //Duc Phan added 20 Dec, 2007 to support sized image
                    RectangleF r2 = new RectangleF(i.X + i.SI.PaddingLeft, i.Y + i.SI.PaddingTop, i.W - i.SI.PaddingLeft - i.SI.PaddingRight, i.H - i.SI.PaddingTop - i.SI.PaddingBottom);

                    RectangleF adjustedRect;   // work rectangle
                    RectangleF clipRect = RectangleF.Empty;
                    switch (i.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,
                                                      Measurement.PointsFromPixels(i.SamplesW, pgs.G.DpiX), Measurement.PointsFromPixels(i.SamplesH, pgs.G.DpiY));
                        clipRect = new RectangleF(r2.Left, r2.Top,
                                                  r2.Width, r2.Height);
                        break;

                    case ImageSizingEnum.FitProportional:
                        float height;
                        float width;
                        float ratioIm = (float)i.SamplesH / i.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 (i.ImgFormat == System.DrawingCore.Imaging.ImageFormat.Wmf || i.ImgFormat == System.DrawingCore.Imaging.ImageFormat.Emf)
                    {
                        //We dont want to add it - its already been broken down into page items;
                    }
                    else
                    {
                        AddImage(i.Name, i.SI, i.ImgFormat,
                                 adjustedRect.X, adjustedRect.Y, adjustedRect.Width, adjustedRect.Height, clipRect, i.ImageData, i.SamplesW, i.SamplesH, i.HyperLink, i.Tooltip);
                    }
                    continue;
                }

                if (pi is PageRectangle)
                {
                    PageRectangle pr = pi as PageRectangle;
                    AddRectangle(pr.X, pr.Y, pr.H, pr.W, pi.SI, pi.HyperLink, pi.Tooltip);
                    continue;
                }
                if (pi is PagePie)
                {   // TODO
                    PagePie pp = pi as PagePie;
                    //
                    AddPie(pp.X, pp.Y, pp.H, pp.W, pi.SI, pi.HyperLink, pi.Tooltip);
                    continue;
                }
                if (pi is PagePolygon)
                {
                    PagePolygon ppo = pi as PagePolygon;
                    AddPolygon(ppo.Points, pi.SI, pi.HyperLink);
                    continue;
                }
                if (pi is PageCurve)
                {
                    PageCurve pc = pi as PageCurve;
                    AddCurve(pc.Points, pi.SI);
                    continue;
                }
            }
        }
Exemple #13
0
        internal override void RunPage(Pages pgs, Row row)
        {
            Report r = pgs.Report;
            bool bHidden = IsHidden(r, row);

            SetPagePositionBegin(pgs);

            // Handle page breaking at start
            if (this.PageBreakAtStart && !IsTableOrMatrixCell(r) && !pgs.CurrentPage.IsEmpty() && !bHidden)
            {	// force page break at beginning of dataregion
                pgs.NextOrNew();
                pgs.CurrentPage.YOffset = OwnerReport.TopOfPage;
            }

            PageRectangle pr = new PageRectangle();
            SetPagePositionAndStyle(r, pr, row);
            if (pr.SI.BackgroundImage != null)
                pr.SI.BackgroundImage.H = pr.H;		//   and in the background image

            if (!bHidden)
            {
                Page p = pgs.CurrentPage;
                p.AddObject(pr);

                if (_ReportItems != null)
                {
                    float saveY = p.YOffset;
               //             p.YOffset += (Top == null ? 0 : this.Top.Points);
                    p.YOffset = pr.Y;       // top of rectangle is base for contained report items
                    _ReportItems.RunPage(pgs, row, GetOffsetCalc(pgs.Report) + LeftCalc(r));
                    p.YOffset = saveY;
                }

                // Handle page breaking at end
                if (this.PageBreakAtEnd && !IsTableOrMatrixCell(r) && !pgs.CurrentPage.IsEmpty())
                {	// force page break at beginning of dataregion
                    pgs.NextOrNew();
                    pgs.CurrentPage.YOffset = OwnerReport.TopOfPage;
                }
            }
            //			SetPagePositionEnd(pgs, pgs.CurrentPage.YOffset);
            SetPagePositionEnd(pgs, pr.Y + pr.H);
        }
Exemple #14
0
        private void DoInstructions(Single recX, Single recY, Single recWidth, Single recHeight, Pen p)
        {
            BorderStyleEnum ls = getLineStyle(p);           
            switch (p.Brush.GetType().Name)
            {
                case "SolidBrush":
                    System.Drawing.SolidBrush theBrush = (System.Drawing.SolidBrush)p.Brush;
                    PageRectangle pl = new PageRectangle();
                    pl.X = X + recX * SCALEFACTOR;
                    pl.Y = Y + recY * SCALEFACTOR;
                    pl.W = recWidth * SCALEFACTOR;
                    pl.H = recHeight * SCALEFACTOR;

                    StyleInfo SI = new StyleInfo();
                    SI.Color = theBrush.Color;
                    SI.BColorTop = SI.BColorBottom = SI.BColorLeft = SI.BColorRight = theBrush.Color;
                    SI.BStyleTop = SI.BStyleBottom = SI.BStyleLeft = SI.BStyleRight = ls;
                    SI.BWidthTop = SI.BWidthBottom = SI.BWidthLeft = SI.BWidthRight = p.Width * SCALEFACTOR;
                    pl.SI = SI;
                    items.Add(pl);  
                    break;
                default:
                    break;
            }
        }