public static ConfigurationFrame Deserialize(XElement elm) { ConfigurationFrame frame = new ConfigurationFrame(); frame.m_nDataIndex = SerializeToXml.LoadInt(elm, "DataIndex").Value; frame.m_nFrameHeight = SerializeToXml.LoadInt(elm, "FrameHeight").Value; frame.m_clrTitle = SerializeToXml.LoadColor(elm, "TitleColor").Value; frame.m_fontTitle = SerializeToXml.LoadFont(elm, "TitleFont"); frame.Name = SerializeToXml.LoadText(elm, "Name"); frame.Visible = SerializeToXml.LoadBool(elm, "Visible").Value; frame.MinMaxTarget = (PlotCollection.MINMAX_TARGET)SerializeToXml.LoadInt(elm, "MinMaxTarget"); frame.ScaleToVisibleWhenRelative = SerializeToXml.LoadBool(elm, "ScaleToVisible").Value; frame.m_rgPlots = ConfigurationPlot.Deserialize(elm.Descendants()); frame.m_rgLines = ConfigurationTargetLine.Deserialize(elm.Descendants()); frame.m_configPlotArea = ConfigurationPlotArea.Deserialize(elm); frame.m_configXAxis = ConfigurationAxis.Deserialize(elm, "X"); frame.m_configYAxis = ConfigurationAxis.Deserialize(elm, "Y"); double?dfVal = SerializeToXml.LoadDouble(elm, "MinYRange"); if (dfVal.HasValue) { frame.MinimumYRange = dfVal.Value; } return(frame); }
public GraphPlotStyle(ConfigurationPlot c) { if (c.Transparency > 0) { double dfTransparency = c.Transparency; if (dfTransparency < 0) { dfTransparency = 0; } if (dfTransparency > 1) { dfTransparency = 1; } int nAlpha = (int)(255 * (1.0 - dfTransparency)); Color clrPlotFill = Color.FromArgb(nAlpha, c.PlotFillColor); Color clrPlotLine = Color.FromArgb(nAlpha, c.PlotLineColor); Color clrLine = Color.FromArgb(nAlpha, c.LineColor); Color clrPlotLineOverride = Color.FromArgb(nAlpha, c.PlotLineColorOverride); m_brPlotFill = new SolidBrush(clrPlotFill); m_penPlotLine = new Pen(clrPlotLine, c.LineWidth); m_penPlotLineOverride = new Pen(clrPlotLineOverride, c.LineWidth); m_penLine = new Pen(clrLine, c.LineWidth); } else { m_brPlotFill = new SolidBrush(c.PlotFillColor); m_penPlotLine = new Pen(c.PlotLineColor, c.LineWidth); m_penLine = new Pen(c.LineColor, c.LineWidth); } }
public static ConfigurationPlot Deserialize(XElement elm) { ConfigurationPlot plot = new ConfigurationPlot(); plot.LineColor = SerializeToXml.LoadColor(elm, "LineColor").Value; plot.PlotFillColor = SerializeToXml.LoadColor(elm, "PlotFillColor").Value; plot.PlotLineColor = SerializeToXml.LoadColor(elm, "PlotLineColor").Value; plot.ActionActive1Color = SerializeToXml.LoadColor(elm, "ActionActive1Color").Value; plot.ActionActive2Color = SerializeToXml.LoadColor(elm, "ActionActive2Color").Value; plot.ActionActiveColorAlpha = SerializeToXml.LoadInt(elm, "ActionActiveColorAlpha").Value; plot.LineWidth = (float)SerializeToXml.LoadDouble(elm, "LineWidth").Value; plot.EnableFlag = SerializeToXml.LoadBool(elm, "EnableFlag").Value; plot.FlagColor = SerializeToXml.LoadColor(elm, "FlagColor").Value; plot.FlagBorderColor = SerializeToXml.LoadColor(elm, "FlagBorderColor").Value; plot.FlagTextColor = SerializeToXml.LoadColor(elm, "FlagTextColor").Value; plot.DataParam = SerializeToXml.LoadText(elm, "DataParam"); plot.DataIndex = SerializeToXml.LoadInt(elm, "DataIndex").Value; plot.DataIndexOnRender = SerializeToXml.LoadInt(elm, "DataIndexOnRender").Value; plot.DataName = SerializeToXml.LoadText(elm, "DataName"); plot.Name = SerializeToXml.LoadText(elm, "Name"); plot.Visible = SerializeToXml.LoadBool(elm, "Visible").Value; plot.Interval = (uint)SerializeToXml.LoadInt(elm, "Interval").Value; plot.PlotType = plotTypeFromString(SerializeToXml.LoadText(elm, "PlotType")); plot.CustomName = SerializeToXml.LoadText(elm, "CustomName"); plot.ExcludeFromMinMax = SerializeToXml.LoadBool(elm, "ExcludeFromMinMax").Value; plot.LookaheadActive = SerializeToXml.LoadBool(elm, "LookaheadActive").Value; plot.MarginPercent = SerializeToXml.LoadDouble(elm, "MarginPercent").Value; plot.Transparency = SerializeToXml.LoadDouble(elm, "Transparency").Value; plot.MidPoint = SerializeToXml.LoadDouble(elm, "MidPoint").Value; plot.ExtraSettings = new Dictionary <string, double>(); List <XElement> rgExtra = SerializeToXml.GetElements(elm.Descendants(), "Extra"); foreach (XElement elm1 in rgExtra) { string strName = SerializeToXml.LoadText(elm1, "ExtraName"); string strVal = SerializeToXml.LoadText(elm1, "ExtraValue"); double dfVal; if (double.TryParse(strVal, out dfVal)) { plot.ExtraSettings.Add(strName, dfVal); } } bool?bVal = SerializeToXml.LoadBool(elm, "EnableTopMostFlag"); if (bVal.HasValue) { plot.EnableTopMostFlag = bVal.Value; } bVal = SerializeToXml.LoadBool(elm, "EnableLabel"); if (bVal.HasValue) { plot.EnableLabel = bVal.Value; } return(plot); }
public ConfigurationFrame(SerializationInfo info, StreamingContext context) { int nCount = info.GetInt32("plotCount"); for (int i = 0; i < nCount; i++) { ConfigurationPlot plot = (ConfigurationPlot)info.GetValue("plot_" + i.ToString(), typeof(ConfigurationPlot)); m_rgPlots.Add(plot); } nCount = info.GetInt32("targetLineCount"); for (int i = 0; i < nCount; i++) { ConfigurationTargetLine line = (ConfigurationTargetLine)info.GetValue("targetline_" + i.ToString(), typeof(ConfigurationTargetLine)); m_rgLines.Add(line); } m_configPlotArea = (ConfigurationPlotArea)info.GetValue("plotArea", typeof(ConfigurationPlotArea)); m_configXAxis = (ConfigurationAxis)info.GetValue("axisX", typeof(ConfigurationAxis)); m_configYAxis = (ConfigurationAxis)info.GetValue("axisY", typeof(ConfigurationAxis)); m_nDataIndex = info.GetInt32("plotCollectionIdx"); m_nFrameHeight = info.GetInt32("frameHeight"); m_clrTitle = (Color)info.GetValue("clrTitle", typeof(Color)); m_fontTitle = (Font)info.GetValue("fontTitle", typeof(Font)); m_strName = info.GetString("name"); m_bVisible = info.GetBoolean("visible"); try { m_minmaxTarget = (PlotCollection.MINMAX_TARGET)info.GetInt32("minmax_target"); } catch (Exception) { } try { m_bScaleToVisibleWhenRelative = info.GetBoolean("scale_to_visible"); } catch (Exception) { } try { m_dfMinYRange = info.GetDouble("min_y_range"); } catch (Exception) { } }
public static List <ConfigurationPlot> Deserialize(IEnumerable <XElement> elms) { List <ConfigurationPlot> rgPlot = new List <ConfigurationPlot>(); List <XElement> rgElm = SerializeToXml.GetElements(elms, "Plot"); foreach (XElement elm in rgElm) { ConfigurationPlot plot = ConfigurationPlot.Deserialize(elm); rgPlot.Add(plot); } return(rgPlot); }
public ConfigurationPlot(ConfigurationPlot p) { m_clrLine = p.m_clrLine; m_clrPlotFill = p.m_clrPlotFill; m_clrPlotLine = p.m_clrPlotLine; m_clrPlotLineOverride = p.m_clrPlotLineOverride; m_clrAction1Active = p.m_clrAction1Active; m_clrAction2Active = p.m_clrAction2Active; m_nActionActiveAlpha = p.m_nActionActiveAlpha; m_fLineWidth = p.m_fLineWidth; m_bEnableFlag = p.m_bEnableFlag; m_bEnableTopMostFlag = p.m_bEnableTopMostFlag; m_bEnableLabel = p.m_bEnableLabel; m_clrFlag = p.m_clrFlag; m_clrFlagBorder = p.m_clrFlagBorder; m_clrFlagText = p.m_clrFlagText; m_strDataParam = p.m_strDataParam; m_strDataName = p.m_strDataName; m_nDataIdx = p.m_nDataIdx; m_nDataIdxOnRender = p.m_nDataIdxOnRender; m_strName = p.m_strName; m_bVisible = p.m_bVisible; m_nInterval = p.m_nInterval; m_plotType = p.m_plotType; m_strCustomName = p.m_strCustomName; m_bExcludeFromMinMax = p.m_bExcludeFromMinMax; m_bLookaheadActive = p.m_bLookaheadActive; m_dfMarginPercent = p.m_dfMarginPercent; m_dfTransparency = p.m_dfTransparency; m_dfMidPoint = p.m_dfMidPoint; m_plotShape = p.m_plotShape; foreach (KeyValuePair <string, double> kv in p.m_rgExtraSettings) { m_rgExtraSettings.Add(kv.Key, kv.Value); } m_custiomBuildOrder = p.m_custiomBuildOrder; if (p.m_properties != null) { foreach (PropertyValue prop in p.m_properties) { m_properties.Add(prop); } } }
public PlotCollectionSet BuildGraph(ConfigurationPlot config, PlotCollectionSet data, int nDataIdx, int nLookahead, GraphPlotCollection plots, bool bAddToParams = false) { m_config = config; m_style = createStyle(m_config); PlotCollectionSet dataOut = data; if (!config.TryCustomBuild(data)) { if (m_idata != null) { string strRequiredDataName = m_idata.RequiredDataName; if (strRequiredDataName != null) { foreach (GraphPlot plot in plots) { if (plot.DataName == strRequiredDataName || (plot.DataName == null && plot.ToString() == strRequiredDataName)) { PlotCollectionSet data1 = new PlotCollectionSet(); if (data.Count > 1 || plot.Plots[0] != data[0]) { data1.Add(data); } data1.Add(plot.Plots, true); dataOut = data1; break; } } } dataOut = m_idata.GetData(data, nDataIdx, nLookahead, config.ID, bAddToParams); if (dataOut != null) { dataOut.ExcludeFromMinMax(config.ExcludeFromMinMax); dataOut.SetMarginPercent(config.MarginPercent); } } } m_rgPlots = dataOut; return(dataOut); }
public virtual bool Compare(ConfigurationPlot c) { if (m_clrLine != c.m_clrLine) { return(false); } if (m_clrPlotFill != c.m_clrPlotFill) { return(false); } if (m_clrPlotLine != c.m_clrPlotLine) { return(false); } if (m_fLineWidth != c.m_fLineWidth) { return(false); } if (m_bEnableFlag != c.m_bEnableFlag) { return(false); } if (m_bEnableTopMostFlag != c.m_bEnableTopMostFlag) { return(false); } if (m_bEnableLabel != c.m_bEnableLabel) { return(false); } if (m_clrFlag != c.m_clrFlag) { return(false); } if (m_clrFlagBorder != c.m_clrFlagBorder) { return(false); } if (m_clrFlagText != c.m_clrFlagText) { return(false); } if (m_nDataIdx != c.m_nDataIdx) { return(false); } if (m_nDataIdxOnRender != c.m_nDataIdxOnRender) { return(false); } if (m_strName != c.m_strName) { return(false); } if (m_bVisible != c.m_bVisible) { return(false); } if (m_nInterval != c.m_nInterval) { return(false); } if (m_plotType != c.m_plotType) { return(false); } if (m_bExcludeFromMinMax != c.m_bExcludeFromMinMax) { return(false); } if (m_clrAction1Active != c.m_clrAction1Active) { return(false); } if (m_clrAction2Active != c.m_clrAction2Active) { return(false); } if (m_nActionActiveAlpha != c.m_nActionActiveAlpha) { return(false); } if (m_bLookaheadActive != c.m_bLookaheadActive) { return(false); } if (m_strDataParam != c.m_strDataParam) { return(false); } if (m_dfTransparency != c.m_dfTransparency) { return(false); } if (m_rgExtraSettings == null && c.m_rgExtraSettings != null) { return(false); } if (m_rgExtraSettings != null && c.m_rgExtraSettings == null) { return(false); } if (m_rgExtraSettings != null && c.m_rgExtraSettings != null) { if (m_rgExtraSettings.Count != c.m_rgExtraSettings.Count) { return(false); } } return(true); }
public static Image QuickRenderEx(PlotCollectionSet set, Configuration cfg, int nWidth = -1, int nHeight = -1, bool bConvertToEastern = false, ConfigurationAxis.VALUE_RESOLUTION?timeResolution = null, bool bIncludeTitle = true, List <ConfigurationTargetLine> rgTargetLines = null, bool bUseTimeResolutionForValueType = false) { foreach (PlotCollection col in set) { if (col.AbsoluteMinYVal == double.MaxValue || col.AbsoluteMaxYVal == -double.MaxValue) { col.SetMinMax(); } } SimpleGraphingControl simpleGraphingControl1 = new SimpleGraphingControl(); simpleGraphingControl1.Name = "SimpleGraphing"; int nValCount = 1; if (set.Count > 0 && set[0].Count > 0) { nValCount = set[0][0].Y_values.Length; } simpleGraphingControl1.SetConfigurationToQuickRenderDefault(set[0].Name, (string)set[0].Tag, nValCount, bConvertToEastern, timeResolution, bUseTimeResolutionForValueType); if (set.Count > 1) { List <Color> rgColor = new List <Color>() { Color.Red, Color.Blue, Color.Green, Color.Purple, Color.Orange, Color.Aquamarine, Color.Fuchsia, Color.OrangeRed, Color.Lavender, Color.Navy, Color.Cyan, Color.DarkCyan }; for (int i = 0; i < set.Count; i++) { int nClrIdx = i % rgColor.Count; Color clr = rgColor[nClrIdx]; ConfigurationPlot plotConfig; if (i > 0) { plotConfig = new ConfigurationPlot(); simpleGraphingControl1.Configuration.Frames[0].Plots.Add(plotConfig); } plotConfig = simpleGraphingControl1.Configuration.Frames[0].Plots[i]; plotConfig.LineColor = clr; plotConfig.PlotLineColor = Color.Transparent; plotConfig.PlotFillColor = Color.Transparent; plotConfig.PlotType = ConfigurationPlot.PLOTTYPE.LINE; plotConfig.Visible = true; plotConfig.EnableLabel = true; plotConfig.EnableFlag = false; plotConfig.FlagColor = clr; plotConfig.Name = set[i].Name; plotConfig.DataIndexOnRender = i; } simpleGraphingControl1.Configuration.Frames[0].EnableRelativeScaling(true, true); } simpleGraphingControl1.LoadModuleCache(); simpleGraphingControl1.Configuration = cfg; List <PlotCollectionSet> rgSet = new List <PlotCollectionSet>() { set }; if (!bIncludeTitle) { simpleGraphingControl1.Configuration.Frames[0].Name = ""; } if (rgTargetLines != null && rgTargetLines.Count > 0) { simpleGraphingControl1.Configuration.Frames[0].TargetLines.AddRange(rgTargetLines); } simpleGraphingControl1.BuildGraph(rgSet, false, true); if (nWidth <= 0) { nWidth = 600; } if (nHeight <= 0) { nHeight = 300; } simpleGraphingControl1.ScrollToEnd(false); return(simpleGraphingControl1.Render(nWidth, nHeight)); }
private GraphPlotStyle createStyle(ConfigurationPlot 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; GraphPlotStyle style = new SimpleGraphing.GraphPlotStyle(c); m_idata = null; m_irender = new GraphRenderLine(m_config, m_gx, m_gy, style); switch (c.PlotType) { case ConfigurationPlot.PLOTTYPE.SMA: m_idata = new GraphDataSMA(m_config); break; case ConfigurationPlot.PLOTTYPE.EMA: m_idata = new GraphDataEMA(m_config); break; case ConfigurationPlot.PLOTTYPE.CANDLE: m_irender = new GraphRenderCandle(m_config, m_gx, m_gy, style); break; case ConfigurationPlot.PLOTTYPE.VOLUME: m_irender = new GraphRenderVolume(m_config, m_gx, m_gy, style); break; case ConfigurationPlot.PLOTTYPE.LINE_FILL: m_irender = new GraphRenderLineFill(m_config, m_gx, m_gy, style); break; case ConfigurationPlot.PLOTTYPE.RSI: m_idata = new GraphDataRSI(m_config); m_irender = new GraphRenderRSI(m_config, m_gx, m_gy, style); break; case ConfigurationPlot.PLOTTYPE.HIGHLOW: m_idata = new GraphDataHighLow(m_config); m_irender = new GraphRenderHighLow(m_config, m_gx, m_gy, style); break; case ConfigurationPlot.PLOTTYPE.ZONE: GraphDataZones gdz = new GraphDataZones(m_config); gdz.OnScale += Gdz_OnScale; m_idata = gdz; m_irender = new GraphRenderZones(m_config, m_gx, m_gy, style); break; case ConfigurationPlot.PLOTTYPE.BOLLINGERBANDS: m_idata = new GraphDataBB(m_config); m_irender = new GraphRenderBB(m_config, m_gx, m_gy, style); break; case ConfigurationPlot.PLOTTYPE.CUSTOM: IGraphPlotDataEx idata = m_cache.Find(m_config.CustomName, true); idata.Initialize(m_config); m_irender = idata.CreateRender(m_config, m_gx, m_gy, style); m_idata = idata; break; } return(style); }