public FormMain() { InitializeComponent(); List <string> rgstrNames = simpleGraphingControl1.LoadModuleCache(); foreach (string strName in rgstrNames) { IGraphPlotDataEx idata = simpleGraphingControl1.CustomModules.Find(strName, false); if (idata != null) { IGraphPlotUserEdit iedit = idata.CreateUserEdit(); if (iedit != null) { ToolStripItem item = testToolStripMenuItem.DropDownItems.Add(iedit.Name + "..."); item.Tag = iedit; item.Click += Item_Click; } ConfigurationPlot plotConfig = new ConfigurationPlot(Guid.NewGuid()); plotConfig.PlotType = ConfigurationPlot.PLOTTYPE.CUSTOM; plotConfig.CustomName = idata.Name; plotConfig.SetCustomBuildOrder(idata.BuildOrder); simpleGraphingControl1.Configuration.Frames[0].Plots.Add(plotConfig); plotConfig = new ConfigurationPlot(Guid.NewGuid()); plotConfig.PlotType = ConfigurationPlot.PLOTTYPE.CUSTOM; plotConfig.CustomName = idata.Name; plotConfig.DataIndex = 1; simpleGraphingControl1.Configuration.Frames[1].Plots.Add(plotConfig); } } }
private IGraphPlotDataEx load(string strPath, out Exception err) { err = null; try { Assembly a = Assembly.LoadFile(strPath); AssemblyName aName = a.GetName(); IGraphPlotDataEx idata = null; foreach (Type t in a.GetTypes()) { if (t.IsPublic) { Type iface = t.GetInterface("IGraphPlotDataEx"); if (iface != null) { object obj = Activator.CreateInstance(t); idata = (IGraphPlotDataEx)obj; return(idata); } } } return(null); } catch (Exception excpt) { Exception[] rgLoaderExceptions = null; if (excpt is System.Reflection.ReflectionTypeLoadException) { var typeLoadException = excpt as ReflectionTypeLoadException; rgLoaderExceptions = typeLoadException.LoaderExceptions; } if (rgLoaderExceptions != null && rgLoaderExceptions.Length > 0) { excpt = new Exception(excpt.Message, rgLoaderExceptions[0]); Trace.WriteLine("Loader Exception: " + rgLoaderExceptions[0].Message); } err = excpt; return(null); } }
public List <string> Load() { List <string> rgstrNames = new List <string>(); string strPath = Modules.CustomGraphingDirectory; string[] rgstrFiles = null; if (Directory.Exists(strPath)) { rgstrFiles = Directory.GetFiles(strPath); } if (rgstrFiles == null || rgstrFiles.Length == 0) { rgstrFiles = Directory.GetFiles(Modules.AssemblyDirectory, "CustomGraphing.*"); } foreach (string strFile in rgstrFiles) { FileInfo fi = new FileInfo(strFile); if (fi.Extension.ToLower() == ".dll") { Exception err; IGraphPlotDataEx idata = load(strFile, out err); if (idata != null) { if (!m_rgModules.ContainsKey(idata.Name)) { string strName = idata.Name; m_rgModules.Add(strName, idata); rgstrNames.Add(strName); } } } } return(rgstrNames); }
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); }