Example #1
0
 /// <summary>
 /// 鼠标按下事件
 /// </summary>
 /// <param name="e"></param>
 protected override void OnMouseDown(System.Windows.Forms.MouseEventArgs e)
 {
     base.OnMouseDown(e);
     System.Drawing.Point mp = e.Location;
     if (curPaintLine != null && curPaintLine.Length > 0)
     {
         ChartDiv mouseOverDiv = GetMouseOverDiv();
         if (mouseOverDiv != null)
         {
             if (curPaintLine == "LINEB")
             {
                 TradeLine tradeLine = new TradeLine();
                 tradeLine.Bs = "多头";
                 AddPlot(this, tradeLine, System.Drawing.Color.FromArgb(200, 200, 200), System.Drawing.Color.White, mp, 1, null, mouseOverDiv);
             }
             else if (curPaintLine == "LINES")
             {
                 TradeLine tradeLine = new TradeLine();
                 tradeLine.Bs = "空头";
                 AddPlot(this, tradeLine, System.Drawing.Color.FromArgb(200, 200, 200), System.Drawing.Color.White, mp, 1, null, mouseOverDiv);
             }
             else
             {
                 AddPlot(System.Drawing.Color.FromArgb(200, 200, 200), System.Drawing.Color.White, curPaintLine, mp, 1, null, mouseOverDiv);
             }
             Cursor       = System.Windows.Forms.Cursors.Default;
             curPaintLine = "";
             RefreshGraph();
         }
     }
 }
Example #2
0
 /// <summary>
 /// 秒表事件
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void thisTimer_Tick(object sender, EventArgs e)
 {
     if (minuteMode)
     {
         if (minuteDatasPos < minuteDatas.Count)
         {
             minuteDatasPos++;
             UpdateDataToGraphMinute(minuteDatas, false);
             Invalidate();
         }
     }
     else
     {
         SecurityLatestData newData = new SecurityLatestData();
         SecurityService.GetLatestData(currentCode, ref newData);
         if (!newData.equal(lastData) && newData.m_volume > 0)
         {
             double close = newData.m_close;
             //画线交易
             for (int i = 0; i < tradeLines.Count; i++)
             {
                 TradeLine trendLine = tradeLines[i];
                 if (trendLine.Bs == "多头")
                 {
                     if (close <= trendLine.Value)
                     {
                         trendLine.Bs += "已成交";
                     }
                 }
                 else if (trendLine.Bs == "空头")
                 {
                     if (close >= trendLine.Value)
                     {
                         trendLine.Bs += "已成交";
                     }
                 }
             }
             double dVolume = 0;
             if (lastData.m_code.Length > 0)
             {
                 dVolume = newData.m_volume - lastData.m_volume;
             }
             SecurityData securityData = new SecurityData();
             securityData.date = (double)((long)newData.m_date / (cycle * 60) * (cycle * 60));
             if (cycle != 1440)
             {
                 securityData.date += (cycle * 60);
             }
             securityData.close = close;
             if (DataSource.RowsCount > 0)
             {
                 if (DataSource.GetXValue(DataSource.RowsCount - 1) == securityData.date)
                 {
                     if (securityData.close > DataSource.Get2(DataSource.RowsCount - 1, COLUMN_HIGH))
                     {
                         securityData.high = close;
                     }
                     else
                     {
                         securityData.high = DataSource.Get2(DataSource.RowsCount - 1, COLUMN_HIGH);
                     }
                     if (securityData.close < DataSource.Get2(DataSource.RowsCount - 1, COLUMN_LOW))
                     {
                         securityData.low = close;
                     }
                     else
                     {
                         securityData.low = DataSource.Get2(DataSource.RowsCount - 1, COLUMN_LOW);
                     }
                     securityData.open = DataSource.Get2(DataSource.RowsCount - 1, COLUMN_OPEN);
                     double oldVolume = DataSource.Get2(DataSource.RowsCount - 1, COLUMN_VOLUME);
                     oldVolume          += dVolume;
                     securityData.volume = oldVolume;
                 }
                 else
                 {
                     securityData.high   = close;
                     securityData.low    = close;
                     securityData.open   = close;
                     securityData.volume = dVolume;
                 }
             }
             else
             {
                 securityData.high   = close;
                 securityData.low    = close;
                 securityData.open   = close;
                 securityData.volume = dVolume;
             }
             List <SecurityData> datas = new List <SecurityData>();
             datas.Add(securityData);
             UpdateDataToGraph(datas, false);
             datas.Clear();
             lastData = newData;
         }
     }
 }