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); }
private PlotAreaStyle createStyle(ConfigurationFrame c) { if (m_style != null && m_config != null && m_config.Compare(c)) { return(m_style); } if (m_style != null) { m_style.Dispose(); } m_config = c; return(new SimpleGraphing.PlotAreaStyle(m_config)); }
private void setMinMaxLines(ConfigurationFrame config) { foreach (ConfigurationTargetLine line in config.TargetLines) { if (line.LineType == ConfigurationTargetLine.LINE_TYPE.MIN) { if (m_dfAbsMinY == double.MaxValue) { line.Enabled = false; } else { line.Enabled = true; double dfMin = m_dfAbsMinY; if (config.MarginPercent > 0) { dfMin -= (dfMin * config.MarginPercent); } line.YValue = dfMin; } } else if (line.LineType == ConfigurationTargetLine.LINE_TYPE.MAX) { if (m_dfAbsMaxY == -double.MaxValue) { line.Enabled = false; } else { line.Enabled = true; double dfMax = m_dfAbsMaxY; if (config.MarginPercent > 0) { dfMax += (dfMax * config.MarginPercent); } line.YValue = dfMax; } } } }
public ConfigurationFrame(ConfigurationFrame f) { m_configPlotArea = new ConfigurationPlotArea(f.m_configPlotArea); m_configXAxis = f.m_configXAxis.Clone(); m_configYAxis = f.m_configYAxis.Clone(); m_nDataIndex = f.m_nDataIndex; m_nFrameHeight = f.m_nFrameHeight; m_clrTitle = f.m_clrTitle; m_fontTitle = new Font(f.m_fontTitle, FontStyle.Bold); m_strName = f.m_strName; m_bVisible = f.m_bVisible; m_dfMarginPercent = f.m_dfMarginPercent; m_minmaxTarget = f.m_minmaxTarget; m_bScaleToVisibleWhenRelative = f.m_bScaleToVisibleWhenRelative; m_dfMinYRange = f.m_dfMinYRange; m_rcActivePlotAreaBounds = f.m_rcActivePlotAreaBounds; m_bUseExistingDataMinMax = f.m_bUseExistingDataMinMax; }
public static Configuration LoadFromFile(string strFile) { Configuration config = new Configuration(); string strXml; using (FileStream fs = new FileStream(strFile, FileMode.Open, FileAccess.Read, FileShare.Read)) using (StreamReader sr = new StreamReader(fs)) { strXml = sr.ReadToEnd(); } if ((int)strXml[0] == 65533 && (int)strXml[1] == 65533) { strXml = strXml.Substring(3); } XDocument doc = XDocument.Parse(strXml); config.Surface = ConfigurationSurface.Deserialize(doc.Descendants()); config.Frames = ConfigurationFrame.Deserialize(doc.Descendants()); return(config); }
public void Update(ConfigurationFrame c) { if (m_clrBack != c.PlotArea.BackColor) { lock (m_syncObj) { if (m_brBack != null) { m_brBack.Dispose(); } m_brBack = new SolidBrush(c.PlotArea.BackColor); m_clrBack = c.PlotArea.BackColor; } } if (m_clrTitle != c.TitleColor) { lock (m_syncObj) { if (m_brTitle != null) { m_brTitle.Dispose(); } m_brTitle = new SolidBrush(c.TitleColor); m_clrTitle = c.TitleColor; } } if (m_clrGrid != c.PlotArea.GridColor) { lock (m_syncObj) { if (m_penGrid != null) { m_penGrid.Dispose(); } m_penGrid = new Pen(c.PlotArea.GridColor, 1.0f); m_clrGrid = c.PlotArea.GridColor; } } if (m_clrSeparator != c.PlotArea.SeparatorColor) { lock (m_syncObj) { if (m_penSeparator != null) { m_penSeparator.Dispose(); } m_penSeparator = new Pen(c.PlotArea.SeparatorColor, 2.0f); m_clrSeparator = c.PlotArea.SeparatorColor; } } if (m_clrZero != c.PlotArea.ZeroLine) { lock (m_syncObj) { if (m_penZero != null) { m_penZero.Dispose(); } m_penZero = new Pen(c.PlotArea.ZeroLine, 1.0f); m_clrZero = c.PlotArea.ZeroLine; } } }
public bool Compare(ConfigurationFrame c) { if (m_rgPlots.Count != c.m_rgPlots.Count) { return(false); } for (int i = 0; i < m_rgPlots.Count; i++) { if (!m_rgPlots[i].Compare(c.m_rgPlots[i])) { return(false); } } if (m_rgLines.Count != c.m_rgLines.Count) { return(false); } for (int i = 0; i < m_rgLines.Count; i++) { if (!m_rgLines[i].Compare(c.m_rgLines[i])) { return(false); } } if (m_dfMinYRange != c.m_dfMinYRange) { return(false); } if (!m_configPlotArea.Compare(c.m_configPlotArea)) { return(false); } if (!m_configXAxis.Compare(c.m_configXAxis)) { return(false); } if (!m_configYAxis.Compare(c.m_configYAxis)) { return(false); } if (m_nDataIndex != c.m_nDataIndex) { return(false); } if (m_nFrameHeight != c.m_nFrameHeight) { return(false); } if (m_clrTitle != c.m_clrTitle) { return(false); } if (m_fontTitle.Name != c.m_fontTitle.Name || m_fontTitle.Size != c.m_fontTitle.Size || m_fontTitle.Style != c.m_fontTitle.Style) { return(false); } if (m_strName != c.m_strName) { return(false); } if (m_bVisible != c.m_bVisible) { return(false); } if (m_minmaxTarget != c.m_minmaxTarget) { return(false); } if (m_bScaleToVisibleWhenRelative != c.m_bScaleToVisibleWhenRelative) { return(false); } return(true); }
private void setMinMax(ConfigurationFrame config, PlotCollectionSet data) { double dfMin = m_gx.MinimumY; double dfMax = m_gx.MaximumY; double dfLineMin = 0; double dfLineMax = 0; bool bMin = false; bool bMax = false; foreach (ConfigurationTargetLine line in config.TargetLines) { if (line.Enabled) { if (line.LineType == ConfigurationTargetLine.LINE_TYPE.MIN) { dfLineMin = line.YValue; bMin = true; } else if (line.LineType == ConfigurationTargetLine.LINE_TYPE.MAX) { dfLineMax = line.YValue; bMax = true; } } } double dfAbsMin; double dfAbsMax; data.GetAbsMinMax(0, 0, out dfAbsMin, out dfAbsMax); if (config.UseExistingDataMinMax) { dfMin = dfAbsMin; dfMax = dfAbsMax; } else { if (bMin || dfMin == double.MaxValue) { dfMin = Math.Min(dfMin, dfAbsMin); dfMin = Math.Min(dfMin, dfLineMin); } if (bMax || dfMax == -double.MaxValue) { dfMax = Math.Max(dfMax, dfAbsMax); dfMax = Math.Max(dfMax, dfLineMax); } } m_gx.SetMinMax(dfMin, dfMax); m_gy.SetMinMax(dfMin, dfMax); dfMin = m_gy.ActiveMin; dfMax = m_gy.ActiveMax; m_dfActiveMinY = dfMin; m_dfActiveMaxY = dfMax; m_dfDataMinY = dfAbsMin; m_dfDataMaxY = dfAbsMax; }
private void setBounds(ConfigurationFrame config, PlotCollectionSet data) { if (config.MinimumYRange != 0) { double dfAbsMinY; double dfAbsMaxY; if (!config.UseExistingDataMinMax) { data.SetMinMax(); } data.GetAbsMinMax(0, 0, out dfAbsMinY, out dfAbsMaxY); double dfRange = dfAbsMaxY - dfAbsMinY; if (dfRange < config.MinimumYRange) { double dfMid = dfAbsMinY + dfRange / 2; dfAbsMinY = dfMid - (config.MinimumYRange / 2); dfAbsMaxY = dfMid + (config.MinimumYRange / 2); ConfigurationTargetLine minLine = null; ConfigurationTargetLine maxLine = null; List <ConfigurationTargetLine> rgRemove = new List <ConfigurationTargetLine>(); foreach (ConfigurationTargetLine line in config.TargetLines) { if (line.Name == "bounds_min") { minLine = line; } if (line.Name == "bounds_max") { maxLine = line; } if (line.LineType == ConfigurationTargetLine.LINE_TYPE.MIN || line.LineType == ConfigurationTargetLine.LINE_TYPE.MAX) { rgRemove.Add(line); } if (minLine != null && maxLine != null) { break; } } foreach (ConfigurationTargetLine line in rgRemove) { config.TargetLines.Remove(line); } if (minLine == null) { minLine = new ConfigurationTargetLine(dfAbsMinY, Color.FromArgb(2, Color.White), ConfigurationTargetLine.LINE_TYPE.VALUE); minLine.Name = "bounds_min"; config.TargetLines.Add(minLine); } else { minLine.YValue = dfAbsMinY; } if (maxLine == null) { maxLine = new ConfigurationTargetLine(dfAbsMaxY, Color.FromArgb(2, Color.White), ConfigurationTargetLine.LINE_TYPE.VALUE); maxLine.Name = "bounds_max"; config.TargetLines.Add(maxLine); } else { maxLine.YValue = dfAbsMaxY; } } } }