Ejemplo n.º 1
0
        public void Render(Graphics g)
        {
            PlotAreaStyle style = m_style;

            drawGrid(g, style);

            foreach (ConfigurationTargetLine line in m_config.TargetLines)
            {
                float fY1 = m_gy.ScaleValue(line.YValue, true);
                line.SetActiveValues(fY1);

                if (line.Enabled && line.Visible)
                {
                    Color      clrFill = Color.FromArgb(32, line.LineColor);
                    Pen        p       = m_colLinePens.Add(line.LineColor);
                    Brush      br      = m_colLineBrushes.Add(clrFill);
                    RectangleF rc;

                    if (!float.IsNaN(fY1) && !float.IsInfinity(fY1))
                    {
                        if (fY1 > Bounds.Top && fY1 < Bounds.Bottom)
                        {
                            if (line.YValueRange > 0)
                            {
                                float fYTop = m_gy.ScaleValue(line.YValue - (line.YValueRange / 2.0f), true);
                                float fYBtm = m_gy.ScaleValue(line.YValue + (line.YValueRange / 2.0f), true);

                                rc = new RectangleF(m_rcBounds.Left, fYBtm, m_rcBounds.Width, fYTop - fYBtm);
                            }
                            else
                            {
                                rc = new RectangleF(m_rcBounds.Left, fY1 - 2, m_rcBounds.Width, 5);
                            }

                            g.FillRectangle(br, rc);
                            g.DrawLine(p, m_rcBounds.Left, fY1, m_rcBounds.Right, fY1);

                            if (!string.IsNullOrEmpty(line.Note))
                            {
                                SizeF sz     = g.MeasureString(line.Note, m_fontNote);
                                Brush brNote = m_colLineBrushes.Add(line.NoteColor);

                                g.DrawString(line.Note, m_fontNote, brNote, new PointF(100, fY1 - sz.Height));
                            }
                        }
                    }
                }
            }

            g.SetClip(Bounds);

            // Draw the pre-render
            foreach (GraphPlot graphPlot in m_rgPlots)
            {
                graphPlot.PreRender(g, m_config.PlotArea.Lookahead);
            }

            // Draw the action actives (if any)
            foreach (GraphPlot graphPlot in m_rgPlots)
            {
                graphPlot.RenderActions(g, m_config.PlotArea.Lookahead);
            }

            // Draw the plots
            foreach (GraphPlot graphPlot in m_rgPlots)
            {
                graphPlot.Render(g, m_config.PlotArea.Lookahead);
            }

            // Draw the look ahead bar if one exists
            if (m_config.PlotArea.Lookahead > 0)
            {
                float fX1 = m_rgPlots[0].GetXPositionFromEnd(m_config.PlotArea.Lookahead);
                Pen   pen = new Pen(Color.FromArgb(64, 0, 0, 255), 1.0f);
                pen.DashStyle = System.Drawing.Drawing2D.DashStyle.Dash;
                g.DrawLine(pen, fX1, m_rcBounds.Top, fX1, m_rcBounds.Bottom);

                pen.Dispose();
            }

            g.ResetClip();

            float fX  = 3;
            float fY  = 3;
            float fHt = 0;

            foreach (GraphPlot graphPlot in m_rgPlots)
            {
                if (m_rcBounds.Y + fY + fHt > m_rcBounds.Bottom)
                {
                    break;
                }

                fHt = drawLabel(g, fX, fY, graphPlot);
                fY += fHt;
            }

            drawTitle(g, m_config, m_style);
        }
Ejemplo n.º 2
0
        private void drawFlag(Graphics g, double dfY, bool bEnableFlag, Color flagColor, Color flagText, Color flagBorder, string strFmt = null, double?dfDisplayYVal = null)
        {
            if (!bEnableFlag)
            {
                return;
            }

            if (flagColor == Color.Transparent)
            {
                return;
            }

            float fY = ScaleValue(dfY, true);

            if (float.IsNaN(fY) || float.IsInfinity(fY))
            {
                return;
            }

            double dfDisplayY = dfY;

            if (dfDisplayYVal.HasValue)
            {
                dfDisplayY = dfDisplayYVal.Value;
            }

            string strVal = (strFmt != null) ? dfDisplayY.ToString(strFmt) : dfDisplayY.ToString("N" + m_config.Decimals.ToString());

            SizeF szVal = g.MeasureString(strVal, m_config.LabelFont);
            float fHalf = szVal.Height / 2;

            if (fY < Bounds.Top || fY > Bounds.Bottom)
            {
                return;
            }

            PointF[] rgpt = m_rgpt;
            rgpt[0].X = m_rcBounds.Left;
            rgpt[0].Y = fY;
            rgpt[1].X = m_rcBounds.Left + fHalf;
            rgpt[1].Y = fY - fHalf;
            rgpt[2].X = m_rcBounds.Left + fHalf + szVal.Width + 2;
            rgpt[2].Y = fY - fHalf;
            rgpt[3].X = m_rcBounds.Left + fHalf + szVal.Width + 2;
            rgpt[3].Y = fY + fHalf;
            rgpt[4].X = m_rcBounds.Left + fHalf;
            rgpt[4].Y = fY + fHalf;
            rgpt[5].X = m_rcBounds.Left;
            rgpt[5].Y = fY;

            m_colFlagColor.Add(flagColor);
            Brush br = m_colFlagColor[flagColor];

            g.FillPolygon(br, rgpt);

            m_colFlagText.Add(flagText);
            br = m_colFlagText[flagText];
            g.DrawString(strVal, m_config.LabelFont, br, m_rcBounds.Left + fHalf, fY - (fHalf + 1));

            m_colFlagBorder.Add(flagBorder);
            Pen p = m_colFlagBorder[flagBorder];

            g.DrawPolygon(p, rgpt);
        }