/// <summary> /// 销毁方法 /// </summary> public override void Dispose() { if (!IsDisposed) { int divsSize = m_divs.Count; for (int i = 0; i < divsSize; i++) { SandBoxCandleDiv div = m_divs[i]; if (div.Moving) { m_native.RemoveControl(div); } else { m_window.RemoveControl(div); } div.Dispose(); } m_divs.Clear(); if (m_window != null) { m_window.UnRegisterEvent(m_timerEvent, EVENTID.TIMER); m_timerEvent = null; m_window.StopTimer(m_timerID); m_window.Close(); m_window.Dispose(); m_window = null; } base.Dispose(); } }
/// <summary> /// 执行秒表方法 /// </summary> /// <param name="timerID">秒表ID</param> public void OnTimer(int timerID) { if (m_timerID == timerID) { INativeBase native = Native; ChartA chart = m_chart.Chart; CTable dataSource = chart.DataSource; int divsSize = m_divs.Count; bool painting = false; int cx = native.ClientX(m_window); int cy = native.ClientY(m_window); List <SandBoxCandleDiv> removeDivs = new List <SandBoxCandleDiv>(); for (int i = 0; i < divsSize; i++) { SandBoxCandleDiv div = m_divs[i]; //判断是否需要重绘 if (div.Moving) { painting = true; } //执行秒表 if (m_divs[i].OnTimer()) { SecurityData data = div.Data; int rowIndex = dataSource.GetRowIndex(data.m_date); int[] fields = new int[7]; fields[0] = KeyFields.CLOSE_INDEX; fields[1] = KeyFields.HIGH_INDEX; fields[2] = KeyFields.LOW_INDEX; fields[3] = KeyFields.OPEN_INDEX; fields[4] = KeyFields.VOL_INDEX; fields[5] = KeyFields.AMOUNT_INDEX; fields[6] = KeyFields.AVGPRICE_INDEX; //插入数据 SecurityDataHelper.InsertLatestData(m_chart.Chart, dataSource, m_chart.Indicators, fields, data); removeDivs.Add(div); } } //移除控件 int removeDivsSize = removeDivs.Count; if (removeDivsSize > 0) { for (int i = 0; i < removeDivsSize; i++) { SandBoxCandleDiv div = removeDivs[i]; m_native.RemoveControl(div); m_divs.Remove(div); div.Dispose(); } removeDivs.Clear(); m_chart.Chart.Update(); } //重绘 if (painting) { m_native.Invalidate(); } } }