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(); } }
public PlotCollectionSet BuildGraph(ConfigurationFrame config, List <ConfigurationPlot> plots, PlotCollectionSet data, bool bAddToParams = false, GETDATAORDER order = GETDATAORDER.PRE) { PlotCollectionSet data1 = new PlotCollectionSet(); if (order == GETDATAORDER.PRE) { if (!config.UseExistingDataMinMax) { data.SetMinMax(); } data.GetAbsMinMax(0, 0, out m_dfAbsMinY, out m_dfAbsMaxY); setMinMaxLines(config); m_rgPlots = new SimpleGraphing.GraphPlotCollection(); m_rgData = new PlotCollectionSet(); m_rgData.Add(data); } for (int i = 0; i < plots.Count; i++) { if ((plots[i].HasCustomBuild || plots[i].Visible) && plots[i].BuildOrder == order) { GraphPlot graphPlot = new SimpleGraphing.GraphPlot(m_cache, m_gx, m_gy); int nLookahead = Math.Max(config.PlotArea.Lookahead, config.PlotArea.CalculationLookahead); PlotCollectionSet set = graphPlot.BuildGraph(plots[i], m_rgData, plots[i].DataIndex, nLookahead, m_rgPlots, bAddToParams); if (set != null) { data1.Add(set, true); } if (graphPlot.Plots != null) { m_rgPlots.Add(graphPlot); m_rgData.Add(graphPlot.Plots, true); } } } if (order == GETDATAORDER.PRE) { m_style = createStyle(config); } return(data1); }
private void drawTitle(Graphics g, ConfigurationFrame config, PlotAreaStyle style) { if (config.Name.Length == 0) { return; } PointF pt = new PointF(m_rcBounds.Left + m_rcBounds.Width / 2.0f, m_rcBounds.Top); SizeF sz = g.MeasureString(m_config.Name, m_config.TitleFont); pt.X -= sz.Width / 2.0f; pt.Y += 2.0f; g.DrawString(config.Name, config.TitleFont, style.TitleBrush, pt); }
public void Dispose() { if (m_fontNote != null) { m_fontNote.Dispose(); m_fontNote = null; } if (m_rgPlots != null) { m_rgPlots.Dispose(); m_rgPlots = null; } if (m_style != null) { m_style.Dispose(); m_style = null; } if (m_colLabelBrushes != null) { m_colLabelBrushes.Dispose(); m_colLabelBrushes = null; } if (m_colLineBrushes != null) { m_colLineBrushes.Dispose(); m_colLineBrushes = null; } if (m_colLinePens != null) { m_colLinePens.Dispose(); m_colLinePens = null; } if (m_colGridBrushes != null) { m_colGridBrushes.Dispose(); m_colGridBrushes = null; } }
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); }