Beispiel #1
0
 /// <summary>
 /// 控件添加方法
 /// </summary>
 public override void OnAdd()
 {
     base.OnAdd();
     if (m_gridTransaction == null)
     {
         m_latestData                    = new SecurityLatestData();
         m_latestDataLV2                 = new SecurityLatestDataLV2();
         m_gridTransaction               = new GridA();
         m_gridTransaction.BackColor     = COLOR.EMPTY;
         m_gridTransaction.BorderColor   = COLOR.EMPTY;
         m_gridTransaction.GridLineColor = COLOR.EMPTY;
         m_gridTransaction.HeaderVisible = false;
         m_gridTransaction.SelectionMode = GridSelectionMode.SelectNone;
         AddControl(m_gridTransaction);
         GridColumn dateColumn = new GridColumn();
         dateColumn.Width = 80;
         m_gridTransaction.AddColumn(dateColumn);
         GridColumn priceColumn = new GridColumn();
         priceColumn.Width = 70;
         m_gridTransaction.AddColumn(priceColumn);
         GridColumn volumeColumn = new GridColumn();
         volumeColumn.Width = 100;
         m_gridTransaction.AddColumn(volumeColumn);
         m_gridTransaction.Update();
     }
 }
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();
     }
 }