private void DoInstructions(Font f, StringFormat sf, Brush br, Single recX, Single recY, Single recWidth, Single recHeight, String Text)
        {
            Color Col = Color.Black;

            if (br.GetType().Name.Equals("SolidBrush"))
            {
                SolidBrush sb = (SolidBrush)br;
                Col = sb.Color;
            }

            PageText pt = new PageText(Text);

            pt.X = X + recX * SCALEFACTOR;
            pt.Y = Y + recY * SCALEFACTOR;
            pt.W = recWidth * SCALEFACTOR;
            pt.H = recHeight * SCALEFACTOR;
            StyleInfo SI = new StyleInfo();

            SI.Color      = Col;
            SI.Direction  = DirectionEnum.LTR;
            SI.FontFamily = f.Name;
            SI.FontSize   = f.Size * SCALEFACTOR;
            if (f.Italic)
            {
                SI.FontStyle = FontStyleEnum.Italic;
            }
            if (f.Bold)
            {
                SI.FontWeight = FontWeightEnum.Bold;
            }
            if (f.Underline)
            {
                SI.TextDecoration = TextDecorationEnum.Underline;
            }
            if (sf.LineAlignment == StringAlignment.Center)
            {
                SI.TextAlign = TextAlignEnum.Center;
            }
            else if (sf.LineAlignment == StringAlignment.Far)
            {
                SI.TextAlign = TextAlignEnum.Right;
            }

            if (sf.Alignment == StringAlignment.Center)
            {
                SI.VerticalAlign = VerticalAlignEnum.Middle;
            }
            else if (sf.Alignment == StringAlignment.Far)
            {
                SI.VerticalAlign = VerticalAlignEnum.Bottom;
            }
            if ((sf.FormatFlags & StringFormatFlags.DirectionVertical) == StringFormatFlags.DirectionVertical)
            {
                SI.WritingMode = WritingModeEnum.tb_rl;
            }
            else
            {
                SI.WritingMode = WritingModeEnum.lr_tb;
            }
            pt.SI = SI;
            items.Add(pt);


            //r = Math.Round((r / 255), 3);
            //g = Math.Round((g / 255), 3);
            //b = Math.Round((b / 255), 3);

            //string pdfFont = fonts.GetPdfFont(f.Name);
            ////need a graphics object...
            //Bitmap bm = new Bitmap(1, 1);
            //Graphics gr = Graphics.FromImage(bm);
            //Font scaleFont = new Font(f.Name, (f.Size * ScaleY) * 1.5f, f.Style, f.Unit);
            //SizeF TextSize = gr.MeasureString(Text.Substring(0, Text.Length), scaleFont, (int)(recWidth * ScaleX), sf);
            //float textwidth = TextSize.Width;
            //float textHeight = TextSize.Height;
            //float startX = X + recX * ScaleX;
            //float startY = Y + Height - recY * ScaleY - (scaleFont.Size);
            //if ((sf.FormatFlags & StringFormatFlags.DirectionVertical) != StringFormatFlags.DirectionVertical)
            //{
            //    if (sf.LineAlignment == StringAlignment.Center)
            //    {
            //        startX = (startX + (recWidth * ScaleX) / 2) - (textwidth / 4);
            //    }
            //    else if (sf.LineAlignment == StringAlignment.Far)
            //    {
            //        startX = (startX + recWidth * ScaleX) - (textwidth / 1.8f);
            //    }
            //}
            //else
            //{
            //    startX += textwidth / 4;
            //    if (sf.LineAlignment == StringAlignment.Center)
            //    {
            //        startY = (startY - (recHeight * ScaleY) / 2) + (textHeight / 4);
            //    }
            //    else if (sf.LineAlignment == StringAlignment.Far)
            //    {
            //        startY = (startY - recHeight * ScaleY) + (textHeight / 1.8f);
            //    }
            //}

            //Lines.Append("\r\nq\t");

            //string newtext = PdfUtility.UTF16StringQuoter(Text);
            //if ((sf.FormatFlags & StringFormatFlags.DirectionVertical) != StringFormatFlags.DirectionVertical)
            //{
            //    Lines.AppendFormat(System.Globalization.NumberFormatInfo.InvariantInfo,
            //           "\r\nBT/{0} {1} Tf\t{5} {6} {7} rg\t{2} {3} Td \t({4}) Tj\tET\tQ\t",
            //           pdfFont, scaleFont.SizeInPoints, startX, startY, newtext, r, g, b);
            //}
            //else
            //{
            //    double rads = -283.0 / 180.0;
            //    double radsCos = Math.Cos(rads);
            //    double radsSin = Math.Sin(rads);

            //    Lines.AppendFormat(System.Globalization.NumberFormatInfo.InvariantInfo,
            //                "\r\nBT/{0} {1} Tf\t{5} {6} {7} rg\t{8} {9} {10} {11} {2} {3} Tm \t({4}) Tj\tET\tQ\t",
            //                pdfFont, scaleFont.SizeInPoints, startX, startY, newtext, r, g, b,
            //                radsCos, radsSin, -radsSin, radsCos);
            //}
        }
Exemple #2
0
        override internal void RunPage(Pages pgs, Row row)
        {
            Report r = pgs.Report;

            if (IsHidden(r, row))
            {
                return;
            }

            base.RunPage(pgs, row);

            // need to save the owner report and nest in this defintion
            ReportDefn   saveReport = r.ReportDefinition;
            NeedPassword np         = r.GetDataSourceReferencePassword; // get current password

            r.SetReportDefinition(_ReportDefn);
            r.Folder = _ReportDefn.ParseFolder;                         // folder needs to get set since the id of the report is used by the cache
            r.GetDataSourceReferencePassword = np;

            DataSourcesDefn saveDS = r.ParentConnections;

            if (this.MergeTransactions)
            {
                r.ParentConnections = saveReport.DataSourcesDefn;
            }
            else
            {
                r.ParentConnections = null;
            }

            r.SubreportDataRetrievalTriggerEvent();

            int   iStartPage    = pgs.CurrentPage.PageNumber; // http://fyireporting.com/forum/viewtopic.php?t=774
            float fStartYOffset = pgs.CurrentPage.YOffset;    // http://fyireporting.com/forum/viewtopic.php?t=774

            bool bRows = true;

            if (_Parameters == null)
            {                   // When no parameters we only retrieve data once
                SubreportWorkClass wc = r.Cache.Get(this, "report") as SubreportWorkClass;

                if (wc == null)
                {                                                                   // run report first time;
                    bRows = r.RunGetData(null);
                    if (!r.IsSubreportDataRetrievalDefined)                         // if use has defined subreportdataretrieval they might set data
                    {
                        r.Cache.Add(this, "report", new SubreportWorkClass(bRows)); // so we can't cache
                    }
                }
                else
                {
                    bRows = wc.bRows;
                }
            }
            else
            {
                SetSubreportParameters(r, row);                         // apply the parameters
                bRows = r.RunGetData(null);
            }

            SetPageLeft(r);                                     // Set the Left attribute since this will be the margin for this report

            SetPagePositionBegin(pgs);

            float yOffset;

            if (bRows)  // Only run subreport if have a row in some Dataset
            {
                //
                // Run the subreport -- this is the major effort in creating the display objects in the page
                //
                r.ReportDefinition.Body.RunPage(pgs);           // create a the subreport items
                yOffset = pgs.CurrentPage.YOffset;
            }
            else
            {   // Handle NoRows message
                string msg;
                if (this.NoRows != null)
                {
                    msg = this.NoRows.EvaluateString(pgs.Report, null);
                }
                else
                {
                    msg = null;
                }

                if (msg != null)
                {
                    PageText pt = new PageText(msg);
                    SetPagePositionAndStyle(pgs.Report, pt, null);

                    if (pt.SI.BackgroundImage != null)
                    {
                        pt.SI.BackgroundImage.H = pt.H;         //   and in the background image
                    }
                    pgs.CurrentPage.AddObject(pt);

                    yOffset = pt.Y + pt.H;
                }
                else
                {
                    yOffset = pgs.CurrentPage.YOffset;
                }
            }

            r.SetReportDefinition(saveReport);                                  // restore the current report
            r.ParentConnections = saveDS;                                       // restore the data connnections

            // http://fyireporting.com/forum/viewtopic.php?t=774 - START
            if (iStartPage == pgs.CurrentPage.PageNumber)
            {
                _yOffset = yOffset - fStartYOffset;
            }
            else
            {
                float tmp = 0;
                if (iStartPage != pgs.CurrentPage.PageNumber - 1)
                {
                    tmp = (pgs.CurrentPage.PageNumber - iStartPage - 1) * pgs.PageHeight;
                }
                _yOffset = tmp + (pgs.PageHeight - fStartYOffset) + yOffset;
            }
            // http://fyireporting.com/forum/viewtopic.php?t=774 - END

            SetPagePositionEnd(pgs, yOffset);
        }