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

            SetPagePositionBegin(pgs);
            PageLine pl = new PageLine();

            SetPagePositionAndStyle(r, pl, row);
            if (!bHidden)
            {
                pgs.CurrentPage.AddObject(pl);
            }
            SetPagePositionEnd(pgs, pl.Y);
        }
Example #2
0
        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;
                }
            }
        }
Example #3
0
        private void DoInstructions(Single Xa, Single Xb, Single Ya, Single Yb, Pen p)
        {
            BorderStyleEnum ls = getLineStyle(p);


            switch (p.Brush.GetType().Name)
            {
            case "SolidBrush":
                System.Drawing.SolidBrush theBrush = (System.Drawing.SolidBrush)p.Brush;
                PageLine pl = new PageLine();
                pl.X  = X + Xa * SCALEFACTOR;
                pl.Y  = Y + Ya * SCALEFACTOR;
                pl.X2 = X + Xb * SCALEFACTOR;
                pl.Y2 = Y + Yb * SCALEFACTOR;

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

            default:
                break;
            }
        }
        private void BuildPrivate(Graphics g)
        {
            this.SI.TextAlign     = TextAlignEnum.Left;
            this.SI.VerticalAlign = VerticalAlignEnum.Top;
            this.SI.WritingMode   = WritingModeEnum.lr_tb;

            PageText model = new PageText("");

            model.AllowSelect = false;
            model.Page        = this.Page;
            model.HyperLink   = null;
            model.Tooltip     = null;
            int fontSizeModel = 3;

            if (_items != null)                         // this has already been built
            {
                return;
            }
            _items      = new List <PageItem>();
            _StyleStack = new Stack();

            // The first item is always a text box with the border and background attributes
            PageText pt = new PageText("");

            pt.AllowSelect      = true;           // This item represents HTML item for selection in RdlViewer
            pt.Page             = this.Page;
            pt.HtmlParent       = this;
            pt.X                = this.X;
            pt.Y                = this.Y;
            pt.H                = this.H;
            pt.W                = this.W;
            pt.CanGrow          = false;
            pt.SI               = this.SI.Clone() as StyleInfo;
            pt.SI.PaddingBottom = pt.SI.PaddingLeft = pt.SI.PaddingRight = pt.SI.PaddingTop = 0;
            _items.Add(pt);

            // Now we create multiple items that represent what is in the box
            PageTextHtmlLexer hl     = new PageTextHtmlLexer(this.Text);
            List <string>     tokens = hl.Lex();

            float textWidth = this.W - pt.SI.PaddingLeft - pt.SI.PaddingRight;
            // Now set the default style for the rest of the members
            StyleInfo si = this.SI.Clone() as StyleInfo;

            si.BStyleBottom           = si.BStyleLeft = si.BStyleRight = si.BStyleTop = BorderStyleEnum.None;
            si.BackgroundColor        = Color.Empty;
            si.BackgroundGradientType = BackgroundGradientTypeEnum.None;
            si.BackgroundImage        = null;

            bool            bFirstInLine  = true;
            StringBuilder   sb            = new StringBuilder(); // this will hold the accumulating line
            float           lineXPos      = 0;
            float           xPos          = 0;
            float           yPos          = 0;
            float           maxLineHeight = 0;
            float           maxDescent    = 0;
            float           descent;                            // working value for descent
            SizeF           ms;
            bool            bWhiteSpace = false;
            List <PageItem> lineItems   = new List <PageItem>();

            foreach (string token in tokens)
            {
                if (token[0] == PageTextHtmlLexer.HTMLCMD)                              // indicates an HTML command
                {
                    // we need to create a PageText since the styleinfo is changing
                    if (sb.Length != 0)
                    {
                        pt             = new PageText(sb.ToString());
                        pt.AllowSelect = false;
                        pt.Page        = this.Page;
                        pt.HtmlParent  = this;
                        pt.HyperLink   = model.HyperLink;
                        pt.Tooltip     = model.Tooltip;
                        pt.NoClip      = true;
                        sb             = new StringBuilder();
                        pt.X           = this.X + lineXPos;
                        pt.Y           = this.Y + yPos;
                        pt.CanGrow     = false;
                        pt.SI          = CurrentStyle(si).Clone() as StyleInfo;
                        _items.Add(pt);
                        lineItems.Add(pt);
                        ms            = this.MeasureString(pt.Text, pt.SI, g, out descent);
                        maxDescent    = Math.Max(maxDescent, descent);
                        pt.W          = ms.Width;
                        pt.H          = ms.Height;
                        pt.Descent    = descent;
                        maxLineHeight = Math.Max(maxLineHeight, ms.Height);
                        lineXPos      = xPos;
                    }
                    // Now reset the styleinfo
                    StyleInfo cs     = CurrentStyle(si);
                    string    ltoken = token.Substring(1, Math.Min(token.Length - 1, 10)).ToLower();
                    if (ltoken == "<b>" || ltoken == "<strong>")
                    {
                        cs.FontWeight = FontWeightEnum.Bold;
                    }
                    else if (ltoken == "</b>" || ltoken == "</strong>")
                    {
                        cs.FontWeight = FontWeightEnum.Normal;
                    }
                    else if (ltoken == "<i>" || ltoken == "<cite>" || ltoken == "<var>" || ltoken == "<em>")
                    {
                        cs.FontStyle = FontStyleEnum.Italic;
                    }
                    else if (ltoken == "</i>" || ltoken == "</cite>" || ltoken == "</var>" || ltoken == "</em>")
                    {
                        cs.FontStyle = FontStyleEnum.Normal;
                    }
                    else if (ltoken == "<code>" || ltoken == "<samp>")
                    {
                        cs.FontFamily = "Courier New";
                    }
                    else if (ltoken == "</code>" || ltoken == "</samp>")
                    {
                        cs.FontFamily = this.SI.FontFamily;
                    }
                    else if (ltoken == "<kbd>")
                    {
                        cs.FontFamily = "Courier New";
                        cs.FontWeight = FontWeightEnum.Bold;
                    }
                    else if (ltoken == "</kdd>")
                    {
                        cs.FontFamily = this.SI.FontFamily;
                        cs.FontWeight = FontWeightEnum.Normal;
                    }
                    else if (ltoken == "<big>")
                    {                           // big makes it bigger by 20% for each time over the baseline of 3
                        fontSizeModel++;
                        float inc = 1;
                        for (int i = 3; i < fontSizeModel; i++)
                        {
                            inc += .2f;
                        }
                        float h = this.SI.FontSize * inc;
                        cs.FontSize = h;
                    }
                    else if (ltoken == "</big>")
                    {                           // undoes the effect of big
                        fontSizeModel--;
                        float inc = 1;
                        for (int i = 3; i < fontSizeModel; i++)
                        {
                            inc += .2f;
                        }
                        float h = this.SI.FontSize / inc;
                        cs.FontSize = h;
                    }
                    else if (ltoken == "<small>")
                    {                           // small makes it smaller by 20% for each time under the baseline of 3
                        fontSizeModel--;
                        float inc = 1;
                        for (int i = 3; i > fontSizeModel; i--)
                        {
                            inc += .2f;
                        }
                        float h = this.SI.FontSize / inc;
                        cs.FontSize = h;
                    }
                    else if (ltoken == "</small>")
                    {                           // undoes the effect of small
                        fontSizeModel++;
                        float inc = 1;
                        for (int i = 3; i > fontSizeModel; i--)
                        {
                            inc += .2f;
                        }
                        float h = this.SI.FontSize * inc;
                        cs.FontSize = h;
                    }
                    else if (ltoken.StartsWith("<br"))
                    {
                        yPos += maxLineHeight;
                        NormalizeLineHeight(lineItems, maxLineHeight, maxDescent);
                        maxLineHeight = xPos = lineXPos = maxDescent = 0;
                        bFirstInLine  = true;
                        bWhiteSpace   = false;
                    }
                    else if (ltoken.StartsWith("<hr"))
                    {   // Add a line
                        // Process existing line if any
                        yPos += maxLineHeight;
                        NormalizeLineHeight(lineItems, maxLineHeight, maxDescent);
                        maxLineHeight = xPos = lineXPos = maxDescent = 0;
                        bFirstInLine  = true;
                        bWhiteSpace   = false;

                        PageLine pl = new PageLine();
                        pl.AllowSelect = false;
                        pl.Page        = this.Page;
                        const int horzLineHeight = 10;
                        pl.SI            = cs.Clone() as StyleInfo;
                        pl.SI.BStyleLeft = BorderStyleEnum.Ridge;
                        pl.Y             = pl.Y2 = this.Y + yPos + horzLineHeight / 2;
                        pl.X             = this.X;
                        pl.X2            = pl.X + this.W;
                        _items.Add(pl);
                        yPos += horzLineHeight;  // skip past horizontal line
                    }
                    else if (ltoken.StartsWith("<p"))
                    {
                        yPos += maxLineHeight * 2;
                        NormalizeLineHeight(lineItems, maxLineHeight, maxDescent);
                        maxLineHeight = xPos = lineXPos = maxDescent = 0;
                        bFirstInLine  = true;
                        bWhiteSpace   = false;
                    }
                    else if (ltoken.StartsWith("<a"))
                    {
                        BuildAnchor(token.Substring(1), cs, model);
                    }
                    else if (ltoken.StartsWith("<img"))
                    {
                        PageImage pimg = BuildImage(g, token.Substring(1), cs, model);
                        if (pimg != null)   // We got an image; add to process list
                        {
                            pimg.Y = this.Y + yPos;
                            pimg.X = this.X;
                            _items.Add(pimg);
                            yPos         += pimg.H;     // Increment y position
                            maxLineHeight = xPos = lineXPos = maxDescent = 0;
                            bFirstInLine  = true;
                            bWhiteSpace   = false;
                        }
                    }
                    else if (ltoken == "</a>")
                    {
                        model.HyperLink = model.Tooltip = null;
                        PopStyle();
                    }
                    else if (ltoken.StartsWith("<span"))
                    {
                        HandleStyle(token.Substring(1), si);
                    }
                    else if (ltoken == "</span>")
                    {   // we really should match span and font but it shouldn't matter very often?
                        PopStyle();
                    }
                    else if (ltoken.StartsWith("<font"))
                    {
                        HandleFont(token.Substring(1), si);
                    }
                    else if (ltoken == "</font>")
                    {   // we really should match span and font but it shouldn't matter very often?
                        PopStyle();
                    }
                    continue;
                }
                if (token == PageTextHtmlLexer.WHITESPACE)
                {
                    if (!bFirstInLine)
                    {
                        bWhiteSpace = true;
                    }
                    continue;
                }

                if (token != PageTextHtmlLexer.EOF)
                {
                    string ntoken;
                    if (token == PageTextHtmlLexer.NBSP.ToString())
                    {
                        ntoken = bWhiteSpace ? "  " : " ";
                    }
                    else
                    {
                        ntoken = bWhiteSpace ? " " + token : token;
                    }
                    ntoken = ntoken.Replace(PageTextHtmlLexer.NBSP, ' ');

                    bWhiteSpace = false;                                        // can only use whitespace once
                    ms          = this.MeasureString(ntoken, CurrentStyle(si), g, out descent);
                    if (xPos + ms.Width < textWidth)
                    {
                        bFirstInLine = false;
                        sb.Append(ntoken);

                        maxDescent    = Math.Max(maxDescent, descent);
                        maxLineHeight = Math.Max(maxLineHeight, ms.Height);
                        xPos         += ms.Width;
                        continue;
                    }
                }
                else if (sb.Length == 0)                        // EOF and no previous string means we're done
                {
                    continue;
                }

                pt             = new PageText(sb.ToString());
                pt.AllowSelect = false;
                pt.Page        = this.Page;
                pt.HtmlParent  = this;
                pt.NoClip      = true;
                pt.HyperLink   = model.HyperLink;
                pt.Tooltip     = model.Tooltip;
                sb             = new StringBuilder();
                sb.Append(token.Replace(PageTextHtmlLexer.NBSP, ' '));
                pt.SI      = CurrentStyle(si).Clone() as StyleInfo;
                ms         = this.MeasureString(pt.Text, pt.SI, g, out descent);
                pt.X       = this.X + lineXPos;
                pt.Y       = this.Y + yPos;
                pt.H       = ms.Height;
                pt.W       = ms.Width;
                pt.Descent = descent;
                pt.CanGrow = false;
                _items.Add(pt);
                lineItems.Add(pt);
                maxDescent    = Math.Max(maxDescent, descent);
                maxLineHeight = Math.Max(maxLineHeight, ms.Height);
                yPos         += maxLineHeight;             // Increment y position
                NormalizeLineHeight(lineItems, maxLineHeight, maxDescent);
                lineXPos = maxLineHeight = maxDescent = 0; // start line height over

                // Now set the xPos just after the current token
                ms   = this.MeasureString(token, CurrentStyle(si), g, out descent);
                xPos = ms.Width;
            }

            _TotalHeight = yPos;                        // set the calculated height of the result
            _StyleStack  = null;
            return;
        }
Example #5
0
        /// <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;
                }
            }
        }
Example #6
0
        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);
            }
        }
Example #7
0
        internal void SetPagePositionAndStyle(Report rpt, PageItem pi, Row row)
        {
            WorkClass wc = GetWC(rpt);

            pi.X = GetOffsetCalc(rpt) + LeftCalc(rpt);
            if (this._TC != null)
            {                   // must be part of a table
                Table t        = _TC.OwnerTable;
                int   colindex = _TC.ColIndex;

                // Calculate width: add up all columns within the column span
                float       width = 0;
                TableColumn tc;
                for (int ci = colindex; ci < colindex + _TC.ColSpan; ci++)
                {
                    tc     = (TableColumn)(t.TableColumns.Items[ci]);
                    width += tc.Width.Points;
                }
                pi.W = width;
                pi.Y = 0;

                TableRow tr = (TableRow)(_TC.Parent.Parent);
                pi.H = tr.HeightCalc(rpt);                      // this is a cached item; note tr.HeightOfRow must already be called on row
            }
            else if (wc.MC != null)
            {                   // must be part of a matrix
                pi.W = wc.MC.Width;
                pi.Y = 0;
                pi.H = wc.MC.Height;
            }
            else if (pi is PageLine)
            {   // don't really handle if line is part of table???  TODO
                PageLine pl = (PageLine)pi;
                if (Top != null)
                {
                    pl.Y = this.Gap(rpt);                //  y will get adjusted when pageitem added to page
                }
                float y2 = pl.Y;
                if (Height != null)
                {
                    y2 += Height.Points;
                }
                pl.Y2 = y2;
                pl.X2 = pl.X;
                if (Width != null)
                {
                    pl.X2 += Width.Points;
                }
            }
            else
            {   // not part of a table or matrix
                if (Top != null)
                {
                    pi.Y = this.Gap(rpt);                //  y will get adjusted when pageitem added to page
                }
                if (Height != null)
                {
                    pi.H = Height.Points;
                }
                else
                {
                    pi.H = this.HeightOrOwnerHeight;
                }
                if (Width != null)
                {
                    pi.W = Width.Points;
                }
                else
                {
                    pi.W = this.WidthOrOwnerWidth(rpt);
                }
            }
            if (Style != null)
            {
                pi.SI = Style.GetStyleInfo(rpt, row);
            }
            else
            {
                pi.SI = new StyleInfo();    // this will just default everything
            }
            pi.ZIndex = this.ZIndex;        // retain the zindex of the object

            // Catch any action needed
            if (this._Action != null)
            {
                pi.BookmarkLink = _Action.BookmarkLinkValue(rpt, row);
                pi.HyperLink    = _Action.HyperLinkValue(rpt, row);
            }

            if (this._Bookmark != null)
            {
                pi.Bookmark = _Bookmark.EvaluateString(rpt, row);
            }

            if (this._ToolTip != null)
            {
                pi.Tooltip = _ToolTip.EvaluateString(rpt, row);
            }
        }
Example #8
0
        internal override void RunPage(Pages pgs, Row row)
        {
            Report r = pgs.Report;
            bool bHidden = IsHidden(r, row);

            SetPagePositionBegin(pgs);
            PageLine pl = new PageLine();
            SetPagePositionAndStyle(r, pl, row);
            if (!bHidden)
                pgs.CurrentPage.AddObject(pl);
            SetPagePositionEnd(pgs, pl.Y);
        }
        private void BuildPrivate(Graphics g)
        {
            this.SI.TextAlign = TextAlignEnum.Left;
            this.SI.VerticalAlign = VerticalAlignEnum.Top;
            this.SI.WritingMode = WritingModeEnum.lr_tb;

            PageText model = new PageText("");
            model.AllowSelect = false;
            model.Page = this.Page;
            model.HyperLink=null;
            model.Tooltip=null;
            int fontSizeModel = 3;

            if (_items != null)		// this has already been built
                return;
            _items = new List<PageItem>();
            _StyleStack = new Stack();

            // The first item is always a text box with the border and background attributes
            PageText pt = new PageText("");
            pt.AllowSelect = true;                // This item represents HTML item for selection in RdlViewer
            pt.Page = this.Page;
            pt.HtmlParent = this;
            pt.X = this.X;
            pt.Y = this.Y;
            pt.H = this.H;
            pt.W = this.W;
            pt.CanGrow = false;
            pt.SI = this.SI.Clone() as StyleInfo;
            pt.SI.PaddingBottom = pt.SI.PaddingLeft = pt.SI.PaddingRight = pt.SI.PaddingTop = 0;
            _items.Add(pt);

            // Now we create multiple items that represent what is in the box
            PageTextHtmlLexer hl = new PageTextHtmlLexer(this.Text);
            List<string> tokens = hl.Lex();

            float textWidth = this.W - pt.SI.PaddingLeft - pt.SI.PaddingRight;
            // Now set the default style for the rest of the members
            StyleInfo si = this.SI.Clone() as StyleInfo;
            si.BStyleBottom = si.BStyleLeft = si.BStyleRight = si.BStyleTop = BorderStyleEnum.None;
            si.BackgroundColor = Color.Empty;
            si.BackgroundGradientType = BackgroundGradientTypeEnum.None;
            si.BackgroundImage = null;

            bool bFirstInLine=true;
            StringBuilder sb = new StringBuilder(); // this will hold the accumulating line
            float lineXPos=0;
            float xPos = 0;
            float yPos = 0;
            float maxLineHeight=0;
            float maxDescent=0;
            float descent;				// working value for descent
            SizeF ms;
            bool bWhiteSpace=false;
            List<PageItem> lineItems = new List<PageItem>();
            foreach (string token in tokens)
            {
                if (token[0] == PageTextHtmlLexer.HTMLCMD)		// indicates an HTML command
                {
                    // we need to create a PageText since the styleinfo is changing
                    if (sb.Length != 0)
                    {
                        pt = new PageText(sb.ToString());
                        pt.AllowSelect = false;
                        pt.Page = this.Page;
                        pt.HtmlParent = this;
                        pt.HyperLink = model.HyperLink;
                        pt.Tooltip = model.Tooltip;
                        pt.NoClip = true;
                        sb = new StringBuilder();
                        pt.X = this.X + lineXPos;
                        pt.Y = this.Y + yPos;
                        pt.CanGrow = false;
                        pt.SI = CurrentStyle(si).Clone() as StyleInfo;
                        _items.Add(pt);
                        lineItems.Add(pt);
                        ms = this.MeasureString(pt.Text, pt.SI, g, out descent);
                        maxDescent = Math.Max(maxDescent, descent);
                        pt.W = ms.Width;
                        pt.H = ms.Height;
                        pt.Descent = descent;
                        maxLineHeight = Math.Max(maxLineHeight, ms.Height);
                        lineXPos = xPos;
                    }
                    // Now reset the styleinfo
                    StyleInfo cs = CurrentStyle(si);
                    string ltoken = token.Substring(1,Math.Min(token.Length-1,10)).ToLower();
                    if (ltoken == "<b>" || ltoken == "<strong>")
                        cs.FontWeight = FontWeightEnum.Bold;
                    else if (ltoken == "</b>" || ltoken == "</strong>")
                        cs.FontWeight = FontWeightEnum.Normal;
                    else if (ltoken == "<i>" || ltoken == "<cite>" || ltoken == "<var>" || ltoken == "<em>")
                        cs.FontStyle = FontStyleEnum.Italic;
                    else if (ltoken == "</i>" || ltoken == "</cite>" || ltoken == "</var>" || ltoken == "</em>")
                        cs.FontStyle = FontStyleEnum.Normal;
                    else if (ltoken == "<code>" || ltoken == "<samp>")
                        cs.FontFamily = "Courier New";
                    else if (ltoken == "</code>" || ltoken == "</samp>")
                        cs.FontFamily = this.SI.FontFamily;
                    else if (ltoken == "<kbd>")
                    {
                        cs.FontFamily = "Courier New";
                        cs.FontWeight = FontWeightEnum.Bold;
                    }
                    else if (ltoken == "</kdd>")
                    {
                        cs.FontFamily = this.SI.FontFamily;
                        cs.FontWeight = FontWeightEnum.Normal;
                    }
                    else if (ltoken == "<big>")
                    {	// big makes it bigger by 20% for each time over the baseline of 3
                        fontSizeModel++;
                        float inc = 1;
                        for (int i=3; i < fontSizeModel; i++)
                        {
                            inc += .2f;
                        }
                        float h = this.SI.FontSize * inc;
                        cs.FontSize = h;
                    }
                    else if (ltoken == "</big>")
                    {	// undoes the effect of big
                        fontSizeModel--;
                        float inc = 1;
                        for (int i=3; i < fontSizeModel; i++)
                        {
                            inc += .2f;
                        }
                        float h = this.SI.FontSize / inc;
                        cs.FontSize = h;
                    }
                    else if (ltoken == "<small>")
                    {	// small makes it smaller by 20% for each time under the baseline of 3
                        fontSizeModel--;
                        float inc = 1;
                        for (int i=3; i > fontSizeModel; i--)
                        {
                            inc += .2f;
                        }
                        float h = this.SI.FontSize / inc;
                        cs.FontSize = h;
                    }
                    else if (ltoken == "</small>")
                    {	// undoes the effect of small
                        fontSizeModel++;
                        float inc = 1;
                        for (int i=3; i > fontSizeModel; i--)
                        {
                            inc += .2f;
                        }
                        float h = this.SI.FontSize * inc;
                        cs.FontSize = h;
                    }
                    else if (ltoken.StartsWith("<br"))
                    {
                        yPos += maxLineHeight;
                        NormalizeLineHeight(lineItems, maxLineHeight, maxDescent);
                        maxLineHeight = xPos = lineXPos = maxDescent = 0;
                        bFirstInLine = true;
                        bWhiteSpace = false;
                    }
                    else if (ltoken.StartsWith("<hr"))
                    {   // Add a line
                        // Process existing line if any
                        yPos += maxLineHeight;
                        NormalizeLineHeight(lineItems, maxLineHeight, maxDescent);
                        maxLineHeight = xPos = lineXPos = maxDescent = 0;
                        bFirstInLine = true;
                        bWhiteSpace = false;

                        PageLine pl = new PageLine();
                        pl.AllowSelect = false;
                        pl.Page = this.Page;
                        const int horzLineHeight = 10;
                        pl.SI = cs.Clone() as StyleInfo;
                        pl.SI.BStyleLeft = BorderStyleEnum.Ridge;
                        pl.Y = pl.Y2 = this.Y + yPos + horzLineHeight / 2;
                        pl.X = this.X;
                        pl.X2 = pl.X + this.W;
                        _items.Add(pl);
                        yPos += horzLineHeight;  // skip past horizontal line
                    }
                    else if (ltoken.StartsWith("<p"))
                    {
                        yPos += maxLineHeight * 2;
                        NormalizeLineHeight(lineItems, maxLineHeight, maxDescent);
                        maxLineHeight = xPos = lineXPos = maxDescent = 0;
                        bFirstInLine = true;
                        bWhiteSpace = false;
                    }
                    else if (ltoken.StartsWith("<a"))
                    {
                        BuildAnchor(token.Substring(1), cs, model);
                    }
                    else if (ltoken.StartsWith("<img"))
                    {
                        PageImage pimg = BuildImage(g, token.Substring(1), cs, model);
                        if (pimg != null)   // We got an image; add to process list
                        {
                            pimg.Y = this.Y + yPos;
                            pimg.X = this.X;
                            _items.Add(pimg);
                            yPos += pimg.H;	        // Increment y position
                            maxLineHeight = xPos = lineXPos = maxDescent = 0;
                            bFirstInLine = true;
                            bWhiteSpace = false;
                        }
                    }
                    else if (ltoken == "</a>")
                    {
                        model.HyperLink = model.Tooltip = null;
                        PopStyle();
                    }
                    else if (ltoken.StartsWith("<span"))
                    {
                        HandleStyle(token.Substring(1), si);
                    }
                    else if (ltoken == "</span>")
                    {   // we really should match span and font but it shouldn't matter very often?
                        PopStyle();
                    }
                    else if (ltoken.StartsWith("<font"))
                    {
                        HandleFont(token.Substring(1), si);
                    }
                    else if (ltoken == "</font>")
                    {   // we really should match span and font but it shouldn't matter very often?
                        PopStyle();
                    }
                    continue;
                }
                if (token == PageTextHtmlLexer.WHITESPACE)
                {
                    if (!bFirstInLine)
                        bWhiteSpace = true;
                    continue;
                }

                if (token != PageTextHtmlLexer.EOF)
                {
                    string ntoken;
                    if (token == PageTextHtmlLexer.NBSP.ToString())
                        ntoken = bWhiteSpace ? "  " : " ";
                    else
                        ntoken = bWhiteSpace ? " " + token : token;
                    ntoken = ntoken.Replace(PageTextHtmlLexer.NBSP, ' ');

                    bWhiteSpace = false;			// can only use whitespace once
                    ms = this.MeasureString(ntoken, CurrentStyle(si), g, out descent);
                    if (xPos + ms.Width < textWidth)
                    {
                        bFirstInLine = false;
                        sb.Append(ntoken);

                        maxDescent = Math.Max(maxDescent, descent);
                        maxLineHeight = Math.Max(maxLineHeight, ms.Height);
                        xPos += ms.Width;
                        continue;
                    }
                }
                else if (sb.Length == 0)	// EOF and no previous string means we're done
                    continue;

                pt = new PageText(sb.ToString());
                pt.AllowSelect = false;
                pt.Page = this.Page;
                pt.HtmlParent = this;
                pt.NoClip = true;
                pt.HyperLink = model.HyperLink;
                pt.Tooltip = model.Tooltip;
                sb = new StringBuilder();
                sb.Append(token.Replace(PageTextHtmlLexer.NBSP, ' '));
                pt.SI = CurrentStyle(si).Clone() as StyleInfo;
                ms = this.MeasureString(pt.Text, pt.SI, g, out descent);
                pt.X = this.X + lineXPos;
                pt.Y = this.Y + yPos;
                pt.H = ms.Height;
                pt.W = ms.Width;
                pt.Descent = descent;
                pt.CanGrow = false;
                _items.Add(pt);
                lineItems.Add(pt);
                maxDescent = Math.Max(maxDescent, descent);
                maxLineHeight = Math.Max(maxLineHeight, ms.Height);
                yPos += maxLineHeight;	// Increment y position
                NormalizeLineHeight(lineItems, maxLineHeight, maxDescent);
                lineXPos = maxLineHeight = maxDescent = 0;	// start line height over

                // Now set the xPos just after the current token
                ms = this.MeasureString(token, CurrentStyle(si), g, out descent);
                xPos = ms.Width;
            }

            _TotalHeight = yPos;		// set the calculated height of the result
            _StyleStack = null;
            return;
        }
Example #10
0
        private void DoInstructions(Single Xa,Single Xb, Single Ya, Single Yb,Pen p)
        {
            BorderStyleEnum ls = getLineStyle(p);

            switch (p.Brush.GetType().Name)
            {
                case "SolidBrush":
                    System.Drawing.SolidBrush theBrush = (System.Drawing.SolidBrush)p.Brush;
                    PageLine pl = new PageLine();
                    pl.X = X + Xa * SCALEFACTOR;
                    pl.Y = Y + Ya * SCALEFACTOR;
                    pl.X2 = X + Xb * SCALEFACTOR;
                    pl.Y2 = Y + Yb * SCALEFACTOR;

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