Esempio n. 1
0
 void SetRectF(MyRectF rect, float x, float y, float width, float heigth)
 {
     rect.X      = rect.Left = x;
     rect.Y      = rect.Top = y;
     rect.Width  = width;
     rect.Height = heigth;
 }
Esempio n. 2
0
        public void ExportPage(int page, ref float htmlWidth, ref float htmlHeight, bool isExport = false, Extension ext = null)
        {
            if (_Pages == null)
            {
                return;
            }
            _Left    = 0;
            _Top     = 0;
            _hScroll = 0;
            _vScroll = 0;
            MyRectF r = rectfPool.Get();

            SetRectF(r, 0, 0, InchesToPixelX(_Pages.PageWidth), InchesToPixelY(_Pages.PageHeight));
            if (htmlWidth == -1f)
            {
                htmlWidth = r.Width;
            }
            if (htmlHeight == -1f)
            {
                htmlHeight = r.Height;
            }
            DrawPage(_Pages.Pages [page], r, ref htmlWidth, ref htmlHeight, isExport, ext);
        }
Esempio n. 3
0
        public void Draw(PointF location, ReportRuntime rptRuntime, MyRectF backRect, bool isExport = false, Extension ext = null)
        {
            if (null == _Tag || null == rptRuntime)
            {
                return;
            }
            try {
                if (location.X < 0)
                {
                    location.X = backRect.X;
                }
                if (location.Y < 0)
                {
                    location.Y = backRect.Y;
                }
                string realText = Text;
                if (_Tag is PmsLabel)
                {
                    //需要二次计算的带页参数的报表元素(页码等)
                    string str = (_Tag as IExpression).Expression;
                    if ((str.IndexOf("PageIndex") >= 0 || str.IndexOf("PageCount") >= 0))
                    {
                        object o = rptRuntime.ExpressionEngine.Execute(str, rptRuntime.DataTables, "");
                        if (o != null)
                        {
                            realText = Convert.ToString(o);
                        }
                    }
                    else
                    {
                        str = Text.ToLower();
                        if (!string.IsNullOrEmpty(str) && (str.IndexOf("[#pageindex#]") >= 0 || str.IndexOf("[#pageCount#]") >= 0))
                        {
                            object objVisible = rptRuntime.ExpressionEngine.ExcuteBindText(Text, rptRuntime.DataTables, "");
                            if (objVisible != null)
                            {
                                realText = Convert.ToString(objVisible);
                            }
                        }
                    }
                }
                else if (_Tag is IVisibleExpression)
                {
                    string str = (_Tag as IVisibleExpression).VisibleExpression;
                    if (!string.IsNullOrEmpty(str) && ((str.IndexOf("PageIndex") >= 0 || str.IndexOf("PageCount") >= 0)))
                    {
                        object o = rptRuntime.ExpressionEngine.Execute(str, rptRuntime.DataTables, "");
                        if (o != null)
                        {
                            bool bVisible = Convert.ToBoolean(o);
                            if (!bVisible)
                            {
                                return;
                            }
                        }
                    }
                }
                float dpiZoom = 1.0f;
                if (null != _Page && null != _Page.PageManager)
                {
                    dpiZoom = 96 / _Page.PageManager.ReportConfigDpiX;
                }

                if (_Tag is ICell)
                {
                    ICell cell = _Tag as ICell;
                    cell.RealText = realText;
                    if (_Parameter != null)
                    {
                        cell.Style = _Parameter as PMS.Libraries.ToolControls.MESTable.CellStyles.Style;
                    }

                    cell.Width  = SizeConversion.ConvertInchesToPixel(_Width, backRect.Width - location.X, 96);
                    cell.Height = SizeConversion.ConvertInchesToPixel(_Height, backRect.Height - location.Y + backRect.Y, 96);
                }
                else if (_Tag is IChartElement)
                {
                    IChartElement curve = _Tag as IChartElement;

                    curve.Width  = (int)SizeConversion.ConvertInchesToPixel(_Width, backRect.Width - location.X, 96);
                    curve.Height = (int)SizeConversion.ConvertInchesToPixel(_Height, backRect.Height - location.Y + backRect.Y, 96);

                    /*if (curve is Control) {
                     * var ctl = (curve as Control);
                     * ctl.Invoke(new Action(() => {
                     * ctl.Width = curve.Width;
                     * ctl.Height = curve.Height;
                     * }));
                     * // (curve as Control).Width = curve.Width;
                     *      //(curve as Control).Height = curve.Height;
                     * }*/
                }
                else if (_Tag is SectionChart)
                {
                    SectionChart curve = _Tag as SectionChart;

                    (curve as IElementExtended).Width  = (int)SizeConversion.ConvertInchesToPixel(_Width, backRect.Width - location.X, 96);
                    (curve as IElementExtended).Height = (int)SizeConversion.ConvertInchesToPixel(_Height, backRect.Height - location.Y + backRect.Y, 96);

                    /*if (curve is Control) {
                     *      //(curve as Control).Width = (curve as IElementExtended).Width;
                     *      //(curve as Control).Height = (curve as IElementExtended).Height;
                     *
                     * var ctl = (curve as Control);
                     * ctl.Invoke(new Action(() => {
                     * ctl.Width = (curve as IElementExtended).Width;
                     * ctl.Height = (curve as IElementExtended).Height;
                     * }));
                     * }*/
                    //curve.DirectDraw (DraqCanvas, location.X, location.Y, dpiZoom);
                }
                else if (_Tag is IDirectDrawable)
                {
                    if (_Tag is IElementContent)
                    {
                        (_Tag as IElementContent).RealText = realText;
                    }
                    if (_Tag is IElement)
                    {
                        (_Tag as IElement).Width  = (int)SizeConversion.ConvertInchesToPixel(_Width, backRect.Width - location.X, 96);
                        (_Tag as IElement).Height = (int)SizeConversion.ConvertInchesToPixel(_Height, backRect.Height - location.Y + backRect.Y, 96);
                    }
                    //(_Tag as IDirectDrawable).DirectDraw (DraqCanvas, location.X, location.Y, dpiZoom);
                }
                //todo:qiuleilei
                if (isExport && CurrentPrjInfo.CurrentEnvironment == MESEnvironment.MESReportServer && ext != null)
                {
                    ext.ToHtml(Page, rptRuntime, _Tag, location, SizeConversion.ConvertInchesToPixel(_Width, backRect.Width - location.X, 96), SizeConversion.ConvertInchesToPixel(_Height, backRect.Height - location.Y + backRect.Y, 96));
//					if (_Tag != null && (_Tag is Control)) {
//						(_Tag as Control).Dispose ();
//						_Tag = null;
//					}
                }
            } catch (System.Exception ex) {
                if (_Tag is IElement)
                {
                    rptRuntime.AddReportLog(ex, (_Tag as IElement).Name);
                }
                else
                {
                    rptRuntime.AddReportLog(ex);
                }
            }
        }
Esempio n. 4
0
        private void DrawPage(ReportPage p, MyRectF clipRect, ref float htmlWidth, ref float htmlHeight, bool isExport = false, Extension ext = null)          //todo: qiuleilei
        {
            if (_Pages == null)
            {
                return;
            }
            PointF location = new PointF(0, 0);

            if (p.PageType == ReportPageType.Data)
            {
                //页眉
                MyRectF rfC = rectfPool.Get();
                SetRectF(rfC, clipRect.X + InchesToPixelX(_Pages.PageLeftMargin), clipRect.Y + InchesToPixelY(_Pages.PageTopMargin) - 1,
                         clipRect.Width - (InchesToPixelX(_Pages.PageRightMargin) + InchesToPixelX(_Pages.PageLeftMargin)), InchesToPixelY(_Pages.PageHeadHeight));
                var top    = rfC.Top;
                var height = rfC.Height;
//				if (htmlWidth == -1f) {
//					htmlWidth = rfC.Width;
//				}
//				if (htmlHeight == -1f) {
//					htmlHeight = rfC.Height;
//				}
                if (ext != null)
                {
                    ext.ReportPageType2Html(p, rfC, _Pages.PageHeadBackColor, isExport);
                }

                foreach (ReportElement pi in p.PageManager.PageHeadReportElements)
                {
                    if (pi.Tag is IVisibleExpression)
                    {
                        string str = (pi.Tag as IVisibleExpression).VisibleExpression;
                        if (!string.IsNullOrEmpty(str) && ((str.IndexOf("PageIndex") >= 0 || str.IndexOf("PageCount") >= 0)))
                        {
                            object o = _Pages.ReportRuntime.ExpressionEngine.Execute(str, _Pages.ReportRuntime.DataTables, "");
                            if (o != null)
                            {
                                bool bVisible = Convert.ToBoolean(o);
                                if (!bVisible)
                                {
                                    if (pi.Tag is IPanelElement)
                                    {
                                        SetDrawingChildControlVisibleExpression(pi.Tag as Control, str);
                                    }
                                    continue;
                                }
                            }
                        }
                    }

                    SetPointF(ref location, InchesToPixelX(pi.Location.X + _Pages.PageLeftMargin) + _Left - _hScroll, InchesToPixelY(pi.Location.Y + p.PageManager.PageTopMargin) + _Top - _vScroll);
                    pi.Page = p;
                    pi.Draw(location, _Pages.ReportRuntime, rfC, isExport, ext);
                }

                //数据区
                rfC = rectfPool.Get();
                SetRectF(rfC, clipRect.X + InchesToPixelX(_Pages.PageLeftMargin), clipRect.Y + InchesToPixelY(_Pages.PageTopMargin + _Pages.PageHeadHeight) - 1,
                         clipRect.Width - (InchesToPixelX(_Pages.PageRightMargin) + InchesToPixelX(_Pages.PageLeftMargin)), InchesToPixelY(_Pages.PageDataRegionHeight));

                if (ext != null)
                {
                    ext.ReportPageType2Html(p, rfC, _Pages.DataRegionBackColor, isExport);
                }

                foreach (ReportElement pi in p.Elements)
                {
                    SetPointF(ref location, InchesToPixelX(pi.Location.X + _Pages.PageLeftMargin) + _Left - _hScroll, InchesToPixelY(pi.Location.Y + p.PageManager.PageHeadHeight + p.PageManager.PageTopMargin) + _Top - _vScroll);
                    pi.Page = p;
                    if (location.Y < top)
                    {
                        location.Y = top + height;
                        //pi.Height=
                    }
                    pi.Draw(location, _Pages.ReportRuntime, rfC, isExport, ext);
                }

                //页脚
                rfC = rectfPool.Get();
                SetRectF(rfC, clipRect.X + InchesToPixelX(_Pages.PageLeftMargin), clipRect.Y + InchesToPixelY(_Pages.PageTopMargin + _Pages.PageHeadHeight + _Pages.PageDataRegionHeight) - 1,
                         clipRect.Width - (InchesToPixelX(_Pages.PageRightMargin) + InchesToPixelX(_Pages.PageLeftMargin)), InchesToPixelY(_Pages.PageFootHeight));

                if (ext != null)
                {
                    ext.ReportPageType2Html(p, rfC, _Pages.PageFootBackColor, isExport);
                }



                foreach (ReportElement pi in p.PageManager.PageFootReportElements)
                {
                    if (pi.Tag is IVisibleExpression)
                    {
                        string str = (pi.Tag as IVisibleExpression).VisibleExpression;
                        if (!string.IsNullOrEmpty(str) && ((str.IndexOf("PageIndex") >= 0 || str.IndexOf("PageCount") >= 0)))
                        {
                            object o = _Pages.ReportRuntime.ExpressionEngine.Execute(str, _Pages.ReportRuntime.DataTables, "");
                            if (o != null)
                            {
                                bool bVisible = Convert.ToBoolean(o);
                                if (!bVisible)
                                {
                                    if (pi.Tag is IPanelElement)
                                    {
                                        SetDrawingChildControlVisibleExpression(pi.Tag as Control, str);
                                    }
                                    continue;
                                }
                            }
                        }
                    }

                    //PointF location = pointfPool.Get ();
                    SetPointF(ref location, InchesToPixelX(pi.Location.X + _Pages.PageLeftMargin) + _Left - _hScroll, InchesToPixelY(pi.Location.Y + p.PageManager.PageHeadHeight + p.PageManager.PageTopMargin + p.PageManager.PageDataRegionHeight) + _Top - _vScroll);
                    pi.Page = p;
                    pi.Draw(location, _Pages.ReportRuntime, rfC, isExport, ext);
                }
            }
            else                 //报表头、报表尾
                                 //数据区
            {
                MyRectF rfC = rectfPool.Get();
                SetRectF(rfC, clipRect.X + InchesToPixelX(_Pages.PageLeftMargin), clipRect.Y + InchesToPixelY(_Pages.PageTopMargin) - 1,
                         clipRect.Width - (InchesToPixelX(_Pages.PageRightMargin) + InchesToPixelX(_Pages.PageLeftMargin)), InchesToPixelY(_Pages.PageDrawRegionHeight));
//				if (htmlWidth == -1f) {
//					htmlWidth = rfC.Width;
//				}
//				if (htmlHeight == -1f) {
//					htmlHeight = rfC.Height;
//				}
                var top    = rfC.Top;
                var height = rfC.Height;
                if (p.PageType == ReportPageType.ReportHead)
                {
                    if (ext != null)
                    {
                        ext.ReportPageType2Html(p, rfC, _Pages.ReportHeadBackColor, isExport);
                    }
                }
                else
                {
                    if (ext != null)
                    {
                        ext.ReportPageType2Html(p, rfC, _Pages.ReportFootBackColor, isExport);
                    }
                }
                foreach (ReportElement pi in p.Elements)
                {
                    //PointF location = pointfPool.Get ();
                    SetPointF(ref location, InchesToPixelX(pi.Location.X + _Pages.PageLeftMargin) + _Left - _hScroll, InchesToPixelY(pi.Location.Y + p.PageManager.PageTopMargin) + _Top - _vScroll);
                    pi.Page = p;
                    if (location.Y < top)
                    {
                        location.Y = top + height;
                        //pi.Height=
                    }
                    pi.Draw(location, _Pages.ReportRuntime, rfC, isExport, ext);
                }
            }
        }