/// <summary> /// 建構子 /// </summary> /// <param name="master">CStudyControl 類別</param> /// <param name="defaultVal">預設值</param> /// <param name="dataStream">資料串流編號</param> public VariableSeries(IStudyControl master, T defaultVal, int dataStream) { __cDefault = defaultVal; this.DataStream = dataStream; __cBars = master.BarsOfData(dataStream) as Instrument; __cBars.BindResetEvent(SeriesSymbolData_onReset); //設定清盤重置事件 SeriesSymbolDataRand cSeriesRand = __cBars.FullSymbolData as SeriesSymbolDataRand; this.Initialize(cSeriesRand.BarsSize); master.AddVariable(this); }
/// <summary> /// 加入 Series 資料來源 /// </summary> /// <param name="series">資料來源</param> /// <param name="data_stream">資料串流編號(從 1 開始編號)</param> public void AddSeries(object series, int data_stream) { if (__cAxisX == null && series is IInstrument) { __cInstrument = series as Instrument; __cInstrument.BindResetEvent(onReset); __cAxisX = new AxisX(__cInstrument); __cAxisX.AxisRectangle = __cChartRect; __cAxisX.FontMetrics = __cPainter.GetFontMetrics("0", __cProperty.AxisFont); } Layer cLayer = null; ChartSetting cSetting = __cProperty.ChartSettings[data_stream - 1]; int iCount = __cLayers.Count; if (cSetting.LayerIndex < iCount) { cLayer = __cLayers[cSetting.LayerIndex]; } else { cLayer = CreateLayer(); cLayer.LayerIndex = iCount; __cLayers.Add(cLayer); } __bNewSeries = true; this.Resize(); AbstractPlot cPlot = __cPainter.GetPlot(this, series, cSetting); if (cPlot != null) { cPlot.DataStream = data_stream; cPlot.AdjustAxisScaleFromX(__cAxisX); cLayer.AddPlot(cPlot); } }