예제 #1
0
        private void drawGrid(Graphics g, PlotAreaStyle style)
        {
            List <int> rgXTicks = m_gx.TickPositions;
            List <int> rgYTicks = m_gy.TickPositions;

            try
            {
                style.Lock();
                g.FillRectangle(style.BackBrush, m_rcBounds);

                if (m_config.PlotArea.TimeZones != null)
                {
                    foreach (ConfigurationTimeZone tz in m_config.PlotArea.TimeZones)
                    {
                        List <int> rgX0 = ((GraphAxisX)m_gx).GetTickPositions(tz.StartTime, tz.Relative);
                        List <int> rgX1 = ((GraphAxisX)m_gx).GetTickPositions(tz.EndTime, tz.Relative, rgX0.Count);

                        for (int i = 0; i < rgX0.Count; i++)
                        {
                            int nX0 = rgX0[i];
                            int nX1 = rgX1[i];

                            Brush     br = m_colGridBrushes.Add(tz.BackColor);
                            Rectangle rc = new Rectangle(nX0, m_rcBounds.Top, nX1 - nX0, m_rcBounds.Height);
                            g.FillRectangle(br, rc);
                        }
                    }
                }

                for (int i = 0; i < rgXTicks.Count; i++)
                {
                    g.DrawLine(style.GridPen, rgXTicks[i], m_rcBounds.Bottom, rgXTicks[i], m_rcBounds.Top);
                }

                for (int i = 0; i < rgYTicks.Count; i++)
                {
                    g.DrawLine(style.GridPen, m_rcBounds.Left, rgYTicks[i], m_rcBounds.Right, rgYTicks[i]);
                }

                if (m_gy.ZeroLinePosition >= 0)
                {
                    g.DrawLine(style.ZeroPen, m_rcBounds.Left, m_gy.ZeroLinePosition, m_rcBounds.Right, m_gy.ZeroLinePosition);
                }

                if (m_gx.ZeroLinePosition >= 0)
                {
                    g.DrawLine(style.ZeroPen, m_gx.ZeroLinePosition, m_rcBounds.Top, m_gx.ZeroLinePosition, m_rcBounds.Bottom);
                }

                g.DrawRectangle(style.GridPen, m_rcBounds);
            }
            finally
            {
                style.Unlock();
            }
        }
예제 #2
0
        private float drawLabel(Graphics g, float fX, float fY, GraphPlot plot)
        {
            if (!plot.Configuration.Visible)
            {
                return(0);
            }

            if (!plot.Configuration.EnableLabel)
            {
                return(0);
            }

            if (plot.Configuration.Name.Length == 0)
            {
                return(0);
            }

            Color clr = plot.Configuration.FlagColor;

            if (clr == Color.Transparent)
            {
                clr = plot.Configuration.LineColor;
            }

            if (clr == Color.Transparent)
            {
                clr = plot.Configuration.PlotFillColor;
            }

            if (clr == Color.Transparent)
            {
                clr = plot.Configuration.PlotLineColor;
            }

            if (clr == Color.Transparent)
            {
                return(0);
            }

            Brush br = m_colLabelBrushes.Add(clr);

            g.DrawString(plot.Configuration.Name, m_config.PlotArea.LabelFont, br, m_rcBounds.Left + fX, m_rcBounds.Top + fY);

            return(g.MeasureString(plot.Configuration.Name, m_config.PlotArea.LabelFont).Height);
        }
예제 #3
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);
        }
예제 #4
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);
        }