A GraphicBox is a graphic group that does not extend its size to match the extents of its children. Furthermore, it encapsulates many of the properties that can be found in the CSS style sheets for the Box object type. Margin Padding Border
Inheritance: ActiveArea
Ejemplo n.º 1
0
        /* P I C T U R E  B O X  S I Z E  C H A N G E */

        /*----------------------------------------------------------------------------
        *       %%Function: PictureBoxSizeChange
        *       %%Qualified: bg.BgGraph.PictureBoxSizeChange
        *       %%Contact: rlittle
        *
        *  ----------------------------------------------------------------------------*/
        void PictureBoxSizeChange(PictureBox pb, HScrollBar sbh, VScrollBar sbv)
        {
            Graphics   gr  = this.CreateGraphics();
            RectangleF rcf = new RectangleF(Reporter.DxpFromDxa(gr, 100),
                                            Reporter.DypFromDya(gr, 100),
                                            pb.Width - Reporter.DxpFromDxa(gr, 200),
                                            pb.Height - Reporter.DypFromDya(gr, 200));

            if (pb.Tag != null)
            {
                int        iFirst = ((GraphicBox)pb.Tag).GetFirstForScroll();
                GraphicBox gb     = null;

                if (BvFromPb(pb) == BoxView.Graph)
                {
                    pb.Tag = gb = (GraphicBox) new Grapher(rcf, gr);
                }
                else if (BvFromPb(pb) == BoxView.Log)
                {
                    pb.Tag = gb = (GraphicBox) new Reporter(rcf, gr);
                }

                if (gb != null)
                {
                    gb.SetProps(m_gp);
                    gb.SetDataPoints(m_oData, sbv, sbh);
                    gb.Calc();
                    gb.SetFirstFromScroll(iFirst);
                }

                pb.Invalidate();
            }
        }
Ejemplo n.º 2
0
        public void AutosizeGraph(BoxView bvUpper, BoxView bvLower, GraphicBox gbUpper, GraphicBox gbLower, ref GrapherParams gp)
        {
            int nDays;

            if (bvUpper == BoxView.Log)
            {
                // get the number of lines expected in this item
                nDays = gbUpper.GetDaysPerPage();
                if (bvLower == BoxView.Graph)
                {
                    gbLower.SetDaysPerPage(nDays);
                    gp.nHalfDays = nDays * 2;
                }
            }
            else if (bvLower == BoxView.Log)
            {
                // get the number of lines expected in this item
                nDays = gbLower.GetDaysPerPage();
                if (bvUpper == BoxView.Graph)
                {
                    gbUpper.SetDaysPerPage(nDays);
                    gp.nHalfDays = nDays * 2;
                }
            }
        }
Ejemplo n.º 3
0
        void PaintPrintRegion(GraphicBox gb, BoxView bv, Graphics gr, DateTime dttmFirst)
        {
            if (gb == null)
            {
                return;
            }

            gb.Calc();

            if (bv == BoxView.Log)
            {
                gb.SetFirstDateTime(dttmFirst);
            }
            else if (bv == BoxView.Graph)
            {
                gb.SetFirstDateTime(dttmFirst.AddDays(-1.0));
            }

            gb.Paint(gr);
        }
Ejemplo n.º 4
0
        internal void UpdateVisibility()
        {
            if (ModelBox != null)
            {
                ModelBox.Visible = visible;
                ModelBox.Locked  = locked;
            }

            GraphicBox.Visible = visible && state.ShowGraphics;
            GraphicBox.Locked  = locked;

            if (HiddenBox != null)
            {
                HiddenBox.Visible = visible && state.ShowGraphics;
                HiddenBox.Locked  = locked;
            }

            TextBox.Visible = visible && graphicNode.TagVisible && state.ShowTags;
            TextBox.Locked  = locked;

            if (locked)
            {
                if (ModelBox != null)
                {
                    ModelBox.ZBottom();
                }

                GraphicBox.ZBottom();

                if (HiddenBox != null)
                {
                    HiddenBox.ZBottom();
                }

                TextBox.ZBottom();
            }
            else
            {
                if (ModelBox != null)
                {
                    ModelBox.ZIndex = GraphicBox.ZIndex + 100;
                    //linkHovered = false;
                    foreach (Arrow arrow in ModelBox.IncomingArrows)
                    {
                        (arrow.Tag as EditorLink).UpdateVisibility();
                        //arrow.ZIndex = Math.Max(arrow.Origin.ZIndex, arrow.Destination.ZIndex) + 10000;
                        //if ((arrow.Tag as EditorLink).Hovered)
                        //  linkHovered = true;
                    }
                    foreach (Arrow arrow in ModelBox.OutgoingArrows)
                    {
                        (arrow.Tag as EditorLink).UpdateVisibility();
                        // arrow.ZIndex = Math.Max(arrow.Origin.ZIndex, arrow.Destination.ZIndex) + 10000;
                        //if ((arrow.Tag as EditorLink).Hovered)
                        //  linkHovered = true;
                    }

                    ModelBox.CustomDraw = CustomDraw.Additional;
                }

                TextBox.ZIndex = GraphicBox.ZIndex + 200;

                if (HiddenBox != null)
                {
                    HiddenBox.ZBottom();
                }
            }

            opacityTimer.Start();
        }
Ejemplo n.º 5
0
		void PaintPrintRegion(GraphicBox gb, BoxView bv, Graphics gr, DateTime dttmFirst)
		{
			if (gb == null)
				return;

			gb.Calc();

			if (bv == BoxView.Log)
				gb.SetFirstDateTime(dttmFirst);
			else if (bv == BoxView.Graph)
				gb.SetFirstDateTime(dttmFirst.AddDays(-1.0));

			gb.Paint(gr);
		}
Ejemplo n.º 6
0
		public void AutosizeGraph(BoxView bvUpper, BoxView bvLower, GraphicBox gbUpper, GraphicBox gbLower, ref GrapherParams gp)
		{
			int nDays;

			if (bvUpper == BoxView.Log)
				{
				// get the number of lines expected in this item
				nDays = gbUpper.GetDaysPerPage();
				if (bvLower == BoxView.Graph)
					{
					gbLower.SetDaysPerPage(nDays);
					gp.nHalfDays = nDays * 2;
					}
				}
			else if (bvLower == BoxView.Log)
				{
				// get the number of lines expected in this item
				nDays = gbLower.GetDaysPerPage();
				if (bvUpper == BoxView.Graph)
					{
					gbUpper.SetDaysPerPage(nDays);
					gp.nHalfDays = nDays * 2;
					}
				}
		}
Ejemplo n.º 7
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;
        }