Exemplo n.º 1
0
		/* L O G  P R I N T  R E G I O N */
		/*----------------------------------------------------------------------------
			%%Function: LogPrintRegion
			%%Qualified: bg.BgGraph.LogPrintRegion
			%%Contact: rlittle

		----------------------------------------------------------------------------*/
		GraphicBox LogPrintRegion(RectangleF rcf, PrintPageEventArgs ev, bool fColor)
		{
			Reporter rpt = new Reporter(rcf, ev.Graphics);

			rpt.SetProps(gpPrint);
			rpt.SetDataPoints(m_oData, null, null);
//			rpt.SetFirstLine(rptRef.GetFirstLine());
			rpt.SetColor(fColor);
			return (GraphicBox)rpt;
		}
Exemplo n.º 2
0
        /* P R I N T  P A G E  H A N D L E R */

        /*----------------------------------------------------------------------------
        *       %%Function: PrintPageHandler
        *       %%Qualified: bg.BgGraph.PrintPageHandler
        *       %%Contact: rlittle
        *
        *  ----------------------------------------------------------------------------*/
        private void PrintPageHandler(object sender, PrintPageEventArgs ev)
        {
            Rectangle     rectMargins = ev.MarginBounds;
            Rectangle     rectPage    = ev.PageBounds;
            PrintDocument ppd         = (PrintDocument)sender;

            rectMargins = new Rectangle((int)Reporter.DxpFromDxaPrint(ev.Graphics, (float)(ev.MarginBounds.X * 14.40)),
                                        (int)Reporter.DypFromDyaPrint(ev.Graphics, (float)(ev.MarginBounds.Y * 14.40)),
                                        (int)Reporter.DxpFromDxaPrint(ev.Graphics, (float)(ev.MarginBounds.Width * 14.40)),
                                        (int)Reporter.DypFromDyaPrint(ev.Graphics, (float)(ev.MarginBounds.Height * 14.40)));


            // adjust the bottom margin...
            rectMargins.Height -= (int)Reporter.DypFromDyaPrint(ev.Graphics, 70);

            // page size is 8.5 x 11.  we are shooting for 8" x 10.5"

//			ev.Graphics.DrawRectangle(new Pen(new SolidBrush(Color.Blue), 1.0F), rectMargins);
            int  nPctUpper      = 70;
            int  nMarginTop     = (int)Reporter.DypFromDyaPrint(ev.Graphics, 25);
            int  nMarginBetween = nMarginTop;
            bool fColor         = ppd.PrinterSettings.SupportsColor;

            int nHeightTotal = (int)Reporter.DypFromDyaPrint(ev.Graphics, 1440.0F * 10.5F);
            int nWidthTotal  = (int)Reporter.DxpFromDxaPrint(ev.Graphics, 1440.0F * 8.0F);

            if (ev.PageSettings.Landscape)
            {
                nWidthTotal  = (int)Reporter.DypFromDyaPrint(ev.Graphics, 1440.0F * 10.5F);
                nHeightTotal = (int)Reporter.DxpFromDxaPrint(ev.Graphics, 1440.0F * 8.0F);
            }

            int nHeightAvail = nHeightTotal - nMarginBetween - nMarginTop;
            int nWidth       = nWidthTotal - (int)Reporter.DxpFromDxaPrint(ev.Graphics, 10);

            if (m_bvUpper == BoxView.None)
            {
                nPctUpper = 0;
            }
            else if (m_bvLower == BoxView.None)
            {
                nPctUpper = 100;
            }

            // we have to apportion the regions...
            RectangleF rcfUpperBanner = new RectangleF(0, 0, nWidth, nMarginTop);
            RectangleF rcfUpper       = new RectangleF(0, rcfUpperBanner.Bottom, nWidth, ((nHeightAvail) * nPctUpper) / 100);
            RectangleF rcfLowerBanner = new RectangleF(0, rcfUpper.Bottom, nWidth, nMarginBetween);
            RectangleF rcfLower       = new RectangleF(0, rcfUpper.Bottom + nMarginBetween, nWidth, nHeightAvail - (rcfUpper.Bottom + nMarginBetween * 2));

            // whenever we go to print, if there's a log, then the first date in the log becomes the first date for the graph too

            // paint the upper region
            GraphicBox gbUpper = null;
            GraphicBox gbLower = null;

            switch (m_bvUpper)
            {
            case BoxView.Graph:
            {
                Grapher grph = (Grapher)m_picbUpper.Tag;
                gbUpper = GraphPrintRegion(rcfUpper, rcfUpperBanner, ev, fColor);
                break;
            }

            case BoxView.Log:
            {
                Reporter rpt = (Reporter)m_picbUpper.Tag;
                gbUpper = LogPrintRegion(rcfUpper, ev, fColor);
                break;
            }
            }

            switch (m_bvLower)
            {
            case BoxView.Graph:
            {
                Grapher grph = (Grapher)m_picbLower.Tag;
                gbLower = GraphPrintRegion(rcfLower, rcfLowerBanner, ev, fColor);
                break;
            }

            case BoxView.Log:
            {
                Reporter rpt = (Reporter)m_picbLower.Tag;
                gbLower = LogPrintRegion(rcfLower, ev, fColor);
                break;
            }
            }

            AutosizeGraph(m_bvUpper, m_bvLower, gbUpper, gbLower, ref gpPrint);
            PaintPrintRegion(gbUpper, m_bvUpper, ev.Graphics, dttmCurPage);
            PaintPrintRegion(gbLower, m_bvLower, ev.Graphics, dttmCurPage);

            // setup dttmCurPage for the next page
            // again, the log wins
            bool fMore = false;

            if (gbUpper != null)
            {
                fMore = gbUpper.FGetLastDateTimeOnPage(out dttmCurPage);

                // if we are getting the "last date" from a graph region, then
                // don't overlap the last day of page N with the page N+1.
                if (fMore && m_bvUpper == BoxView.Graph)
                {
                    dttmCurPage = dttmCurPage.AddDays(1.0f);
                }
            }

            if (m_bvLower == BoxView.Log)
            {
                fMore = gbLower.FGetLastDateTimeOnPage(out dttmCurPage);
            }

            ev.HasMorePages = fMore;
        }