Beispiel #1
0
 /// <summary>
 /// 调用控件线程方法
 /// </summary>
 /// <param name="args">参数</param>
 public override void OnInvoke(object args)
 {
     base.OnInvoke(args);
     if (args != null)
     {
         CMessage                  message  = (CMessage)args;
         LatestDataInfo            dataInfo = new LatestDataInfo();
         List <SecurityLatestData> datas    = new List <SecurityLatestData>();
         QuoteService.GetLatestDatas(ref dataInfo, datas, message.m_body, message.m_bodyLength);
         int datasSize = datas.Count;
         for (int i = 0; i < datasSize; i++)
         {
             SecurityLatestData latestData = datas[i];
             if (i == 0)
             {
                 if (latestData.m_securityCode == "000001.SH")
                 {
                     if (!latestData.Equal(m_ssLatestData))
                     {
                         m_ssLatestData = latestData;
                     }
                 }
             }
             else if (i == 1)
             {
                 if (latestData.m_securityCode == "399001.SZ")
                 {
                     if (!latestData.Equal(m_szLatestData))
                     {
                         m_szLatestData = latestData;
                     }
                 }
             }
             else if (i == 2)
             {
                 if (latestData.m_securityCode == "399006.SZ")
                 {
                     if (!latestData.Equal(m_cyLatestData))
                     {
                         m_cyLatestData = latestData;
                     }
                 }
             }
         }
         Invalidate();
     }
 }
Beispiel #2
0
 /// <summary>
 /// 调用控件线程方法
 /// </summary>
 /// <param name="args">参数</param>
 public override void OnInvoke(object args)
 {
     base.OnInvoke(args);
     if (args != null)
     {
         CMessage message = (CMessage)args;
         if (message.m_requestID == m_requestID)
         {
             //分时数据
             if (message.m_functionID == QuoteService.FUNCTIONID_QUOTE_PUSHLATESTDATA)
             {
                 LatestDataInfo            dataInfo = new LatestDataInfo();
                 List <SecurityLatestData> datas    = new List <SecurityLatestData>();
                 QuoteService.GetLatestDatas(ref dataInfo, datas, message.m_body, message.m_bodyLength);
                 SecurityLatestData latestData = datas[0];
                 if (latestData != null && latestData.m_securityCode == m_securityCode &&
                     !latestData.Equal(m_latestData))
                 {
                     m_latestData = latestData;
                     //设置保留小数的位数
                     int digit = 2;
                     if (m_latestData.m_securityCode.StartsWith("1") || m_latestData.m_securityCode.StartsWith("5"))
                     {
                         digit = 3;
                     }
                     m_chart.Digit = digit;
                     m_chart.RefreshData();
                 }
             }
             //LV2分时数据
             else if (message.m_functionID == QuoteService.FUNCTIONID_QUOTE_PUSHLATESTDATALV2)
             {
                 LatestDataInfoLV2            dataInfo = new LatestDataInfoLV2();
                 List <SecurityLatestDataLV2> datas    = new List <SecurityLatestDataLV2>();
                 QuoteService.GetLatestDatasLV2(ref dataInfo, datas, message.m_body, message.m_bodyLength);
                 SecurityLatestDataLV2 latestDataLV2 = datas[0];
                 if (latestDataLV2 != null && latestDataLV2.m_securityCode == m_securityCode &&
                     !latestDataLV2.Equal(m_latestDataLV2))
                 {
                     m_latestDataLV2 = latestDataLV2;
                 }
             }
             //成交数据
             else if (message.m_functionID == QuoteService.FUNCTIONID_QUOTE_PUSHTRANSACTIONDATA)
             {
                 String securityCode = "";
                 List <TransactionData> transactionDatas = new List <TransactionData>();
                 QuoteService.GetTransactionDatas(ref securityCode, transactionDatas, message.m_body, message.m_bodyLength);
                 int transactionDatasSize = transactionDatas.Count;
                 for (int i = 0; i < transactionDatasSize; i++)
                 {
                     TransactionData transactionData = transactionDatas[i];
                     DateTime        date            = m_chart.Chart.ConvertNumToDate(transactionData.m_date);
                     GridRow         row             = new GridRow();
                     m_gridTransaction.InsertRow(0, row);
                     TransactionDateCell dateCell = new TransactionDateCell();
                     dateCell.Text = date.ToString("HH:mm:ss");
                     row.AddCell(0, dateCell);
                     GridCellStyle dateCellStyle = new GridCellStyle();
                     dateCellStyle.BackColor = COLOR.EMPTY;
                     dateCellStyle.Font      = new FONT("SimSun", 14, true, false, false);
                     dateCellStyle.ForeColor = CDraw.PCOLORS_FORECOLOR2;
                     dateCell.Style          = dateCellStyle;
                     TransactionDataDoubleCell priceCell = new TransactionDataDoubleCell();
                     priceCell.Digit = 2;
                     priceCell.SetDouble(transactionData.m_price);
                     row.AddCell(1, priceCell);
                     GridCellStyle priceCellStyle = new GridCellStyle();
                     priceCellStyle.BackColor = COLOR.EMPTY;
                     priceCellStyle.Font      = new FONT("SimSun", 14, true, false, false);
                     priceCellStyle.ForeColor = CDraw.GetPriceColor(transactionData.m_price, m_latestData.m_lastClose);
                     priceCell.Style          = priceCellStyle;
                     TransactionDataDoubleCell volumeCell = new TransactionDataDoubleCell();
                     volumeCell.SetDouble(transactionData.m_volume);
                     row.AddCell(2, volumeCell);
                     GridCellStyle volumeCellStyle = new GridCellStyle();
                     volumeCellStyle.BackColor = COLOR.EMPTY;
                     volumeCellStyle.Font      = new FONT("SimSun", 14, true, false, false);
                     if (transactionData.m_type == 0)
                     {
                         volumeCellStyle.ForeColor = CDraw.PCOLORS_FORECOLOR;
                     }
                     else if (transactionData.m_type == 1)
                     {
                         volumeCellStyle.ForeColor = CDraw.PCOLORS_UPCOLOR;
                     }
                     else
                     {
                         volumeCellStyle.ForeColor = CDraw.PCOLORS_DOWNCOLOR;
                     }
                     volumeCell.Style = volumeCellStyle;
                 }
                 m_gridTransaction.Update();
             }
         }
         Invalidate();
     }
 }