Exemple #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();
     }
 }
Exemple #2
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();
     }
 }
Exemple #3
0
        /// <summary>
        /// 获取浮点型数值
        /// </summary>
        /// <returns>浮点型数值</returns>
        public override double GetDouble()
        {
            GridRow            row          = Row;
            String             securityCode = row.GetCell(0).Text;
            SecurityLatestData data         = new SecurityLatestData();

            if (m_userSecurityList.m_latestDatas.ContainsKey(securityCode))
            {
                data = m_userSecurityList.m_latestDatas[securityCode];
            }
            int        dataSize   = data != null ? data.m_securityCode.Length : 0;
            GridColumn column     = Column;
            String     columnName = column.Name;

            if (columnName == "colClose")
            {
                if (dataSize > 0)
                {
                    return(data.m_close);
                }
            }
            else if (columnName == "colDiff")
            {
                if (dataSize > 0)
                {
                    return(data.m_close - data.m_lastClose);
                }
            }
            else if (columnName == "colDiffRange")
            {
                if (dataSize > 0)
                {
                    if (data.m_lastClose != 0)
                    {
                        return(100 * (data.m_close - data.m_lastClose) / data.m_lastClose);
                    }
                }
            }
            return(0);
        }
Exemple #4
0
        /// <summary>
        /// 重绘方法
        /// </summary>
        /// <param name="paint">绘图对象</param>
        /// <param name="rect">矩形</param>
        /// <param name="clipRect">裁剪矩形</param>
        /// <param name="isAlternate">是否交替行</param>
        public override void OnPaint(CPaint paint, RECT rect, RECT clipRect, bool isAlternate)
        {
            int clipW = clipRect.right - clipRect.left;
            int clipH = clipRect.bottom - clipRect.top;

            if (clipW > 0 && clipH > 0)
            {
                GridA      grid   = Grid;
                GridRow    row    = Row;
                GridColumn column = Column;
                if (grid != null && row != null && column != null)
                {
                    //判断选中
                    String text = "-";
                    //绘制背景
                    bool           selected         = false;
                    List <GridRow> selectedRows     = grid.SelectedRows;
                    int            selectedRowsSize = selectedRows.Count;
                    for (int i = 0; i < selectedRowsSize; i++)
                    {
                        if (selectedRows[i] == row)
                        {
                            selected = true;
                            break;
                        }
                    }
                    long         backColor = COLOR.EMPTY;
                    GridRowStyle rowStyle  = grid.RowStyle;
                    if (selected)
                    {
                        backColor = rowStyle.SelectedBackColor;
                    }
                    else if (row == grid.HoveredRow)
                    {
                        backColor = rowStyle.HoveredBackColor;
                    }
                    else
                    {
                        backColor = rowStyle.BackColor;
                    }
                    paint.FillRect(backColor, clipRect);
                    //获取颜色
                    FONT          font      = null;
                    long          foreColor = COLOR.EMPTY;
                    GridCellStyle style     = Style;
                    if (style != null)
                    {
                        foreColor = style.ForeColor;
                        if (style.Font != null)
                        {
                            font = style.Font;
                        }
                    }
                    double value = GetDouble();
                    if (!double.IsNaN(value))
                    {
                        SecurityLatestData data         = new SecurityLatestData();
                        String             securityCode = row.GetCell(0).Text;
                        if (m_userSecurityList.m_latestDatas.ContainsKey(securityCode))
                        {
                            data = m_userSecurityList.m_latestDatas[securityCode];
                        }
                        String columnName = column.Name;
                        int    dataSize   = data != null ? data.m_securityCode.Length : 0;
                        if (columnName == "colNo")
                        {
                            foreColor = CDraw.PCOLORS_FORECOLOR7;
                            text      = ((int)value + 1).ToString();
                        }
                        else if (columnName == "colDiff")
                        {
                            if (dataSize > 0)
                            {
                                foreColor = GetPriceColor(value, 0);
                                text      = value.ToString("0.00");
                            }
                        }
                        else if (columnName == "colDiffRange")
                        {
                            if (dataSize > 0)
                            {
                                foreColor = GetPriceColor(data.m_close, data.m_lastClose);
                                text      = value.ToString("0.00") + "%";
                            }
                        }
                        else
                        {
                            if (dataSize > 0)
                            {
                                foreColor = GetPriceColor(value, data.m_lastClose);
                                text      = value.ToString("0.00");
                            }
                        }
                    }
                    SIZE  tSize  = paint.TextSize(text, font);
                    POINT tPoint = new POINT(rect.right - tSize.cx - 3, rect.top + clipH / 2 - tSize.cy / 2);
                    RECT  tRect  = new RECT(tPoint.x, tPoint.y, tPoint.x + tSize.cx, tPoint.y + tSize.cy);
                    paint.DrawText(text, foreColor, font, tRect);
                }
            }
        }
Exemple #5
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();
     }
 }
Exemple #6
0
        /// <summary>
        /// 重绘方法
        /// </summary>
        /// <param name="paint">绘图对象</param>
        /// <param name="clipRect">裁剪区域</param>
        public override void OnPaint(CPaint paint, RECT clipRect)
        {
            int  width = Width, height = Height;
            RECT rect = new RECT(1, 1, width, height);
            int  cornerRadius = 10;
            int  cLeft = 1, cTop = 1;
            bool isDragging = IsDragging, isEditing = m_list.IsEditing;

            if (!isDragging && isEditing)
            {
                Random rd = m_list.m_rd;
                rect.left   += rd.Next(0, 15);
                rect.top    += rd.Next(0, 15);
                rect.right  -= rd.Next(0, 15);
                rect.bottom -= rd.Next(0, 15);
                cornerRadius = rd.Next(10, 20);
                cLeft       += rd.Next(0, 5);
                cTop        += rd.Next(0, 5);
            }
            paint.DrawGradientRect(COLOR.ARGB(200, 0, 0, 0), COLOR.ARGB(200, 0, 0, 0), rect, cornerRadius, 0);
            if (this == m_list.SelectedCell)
            {
                paint.DrawRoundRect(CDraw.PCOLORS_LINECOLOR, 1, 0, rect, cornerRadius);
            }
            else
            {
                paint.DrawRoundRect(CDraw.PCOLORS_LINECOLOR3, 1, 0, rect, cornerRadius);
            }
            SecurityServiceEx securityService = DataCenter.SecurityService;
            Security          security        = new Security();

            if (securityService.GetSecurityByCode(m_securityCode, ref security))
            {
                String securityName = security.m_name;
                FONT   font         = new FONT("微软雅黑", 20, false, false, false);
                FONT   font2        = new FONT("Arial", 18, false, false, false);
                if (m_index >= 2 && m_index <= 5)
                {
                    font.m_fontSize  = 18;
                    font2.m_fontSize = 16;
                }
                else if (m_index >= 6)
                {
                    font.m_fontSize  = 16;
                    font2.m_fontSize = 14;
                }
                String drawCode = m_securityCode.Substring(0, m_securityCode.IndexOf("."));
                int    left     = rect.left + 10;
                SIZE   tSize    = paint.TextSize(securityName, font);
                SIZE   tSize2   = paint.TextSize(drawCode, font2);
                int    top      = (height - tSize.cy - tSize2.cy) / 2;
                int    mid      = left + Math.Max(tSize.cx, tSize2.cx) / 2;
                CDraw.DrawText(paint, drawCode, CDraw.PCOLORS_FORECOLOR, font2, mid - tSize2.cx / 2, top);
                CDraw.DrawText(paint, securityName, CDraw.PCOLORS_FORECOLOR, font, mid - tSize.cx / 2, top + tSize2.cy);
                left += Math.Max(tSize.cx, tSize2.cx) + 20;
                if (m_list.m_latestDatas.ContainsKey(m_securityCode))
                {
                    SecurityLatestData latestData = m_list.m_latestDatas[m_securityCode];
                    double             close = latestData.m_close, lastClose = latestData.m_lastClose;
                    if (lastClose == 0)
                    {
                        lastClose = latestData.m_close;
                    }
                    //升跌
                    double diff = 0;
                    double rate = 0;
                    if (close == 0)
                    {
                        diff = latestData.m_buyPrice1 - lastClose;
                        rate = 100 * (latestData.m_buyPrice1 - lastClose) / lastClose;
                    }
                    else
                    {
                        diff = close - latestData.m_lastClose;
                        rate = 100 * (close - lastClose) / lastClose;
                    }
                    long   color = CDraw.GetPriceColor(close, lastClose);
                    String strRate = rate.ToString("0.00") + "%", strClose = close.ToString("0.00");
                    if (rate > 0)
                    {
                        strRate = "+" + strRate;
                    }
                    tSize  = paint.TextSize(strRate, font2);
                    tSize2 = paint.TextSize(strClose, font2);
                    if (m_index > 1)
                    {
                        mid = left + Math.Max(tSize.cx, tSize2.cx) / 2;
                        CDraw.DrawText(paint, strClose, color, font2, mid - tSize2.cx / 2, top);
                        CDraw.DrawText(paint, strRate, color, font2, mid - tSize.cx / 2, top + tSize2.cy + 5);
                    }
                    else
                    {
                        CDraw.DrawText(paint, strClose, color, font2, left, top);
                        CDraw.DrawText(paint, strRate, color, font2, left + tSize.cx, top);
                    }
                }
            }
            //绘制图标
            if (m_index <= 1)
            {
                int iLeft = 100, iTop = 45, iSize = 30;
                if (!isDragging && isEditing)
                {
                    Random rd = m_list.m_rd;
                    iLeft += rd.Next(0, 10);
                    iTop  += rd.Next(0, 10);
                }
                List <String> images = new List <String>();
                images.Add("attention.png");
                images.Add("search.png");
                images.Add("note.png");
                images.Add("news.png");
                for (int i = 0; i < 4; i++)
                {
                    paint.DrawImage(images[i], new RECT(iLeft, iTop, iLeft + iSize, iTop + iSize));
                    iLeft += iSize + 20;
                }
                images.Clear();
            }
            //是否正在关闭
            if (!isDragging && isEditing)
            {
                FONT font        = new FONT("微软雅黑", 16, false, false, false);
                SIZE cSize       = new SIZE(30, 30);
                long lineColor   = CDraw.PCOLORS_LINECOLOR;
                RECT ellipseRect = new RECT(cLeft, cTop, cLeft + cSize.cx, cTop + cSize.cy);
                paint.FillEllipse(CDraw.PCOLORS_UPCOLOR, ellipseRect);
                SIZE tSize = paint.TextSize("删", font);
                CDraw.DrawText(paint, "删", COLOR.CONTROLTEXT, font, ellipseRect.left + (cSize.cx - tSize.cx) / 2, ellipseRect.top + (cSize.cy - tSize.cy) / 2);
                paint.DrawEllipse(lineColor, 1, 0, ellipseRect);
            }
        }
Exemple #7
0
        /// <summary>
        /// 重绘方法
        /// </summary>
        /// <param name="paint">绘图对象</param>
        /// <param name="rect">矩形</param>
        /// <param name="clipRect">裁剪矩形</param>
        /// <param name="isAlternate">是否交替行</param>
        public override void OnPaint(CPaint paint, RECT rect, RECT clipRect, bool isAlternate)
        {
            int clipW = clipRect.right - clipRect.left;
            int clipH = clipRect.bottom - clipRect.top;

            if (clipW > 0 && clipH > 0)
            {
                GridA      grid   = Grid;
                GridRow    row    = Row;
                GridColumn column = Column;
                if (grid != null && row != null && column != null)
                {
                    //判断选中
                    String         text             = "-";
                    bool           selected         = false;
                    List <GridRow> selectedRows     = grid.SelectedRows;
                    int            selectedRowsSize = selectedRows.Count;
                    for (int i = 0; i < selectedRowsSize; i++)
                    {
                        if (selectedRows[i] == row)
                        {
                            selected = true;
                            break;
                        }
                    }
                    //获取颜色
                    FONT          font      = null;
                    long          foreColor = COLOR.EMPTY;
                    GridCellStyle style     = Style;
                    if (style != null)
                    {
                        foreColor = style.ForeColor;
                        if (style.Font != null)
                        {
                            font = style.Font;
                        }
                    }
                    SecurityFilterInfo info  = (row as SecurityFilterResultRow).Info;
                    double             value = GetDouble();
                    if (!double.IsNaN(value))
                    {
                        if (m_fieldName != null && m_fieldName.Length > 0)
                        {
                            if (m_fieldName == "FILTER")
                            {
                                if (value == 1)
                                {
                                    foreColor = CDraw.PCOLORS_FORECOLOR9;
                                    text      = "是";
                                }
                                else
                                {
                                    foreColor = CDraw.PCOLORS_FORECOLOR7;
                                    text      = "否";
                                }
                            }
                            else
                            {
                                foreColor = CDraw.GetPriceColor(value, 0);
                                text      = value.ToString("0.0000");
                            }
                        }
                        else
                        {
                            SecurityLatestData data       = info.LatestData;
                            String             columnName = column.Name;
                            int dataSize = data != null ? data.m_securityCode.Length : 0;
                            if (columnName == "colNo")
                            {
                                foreColor = CDraw.PCOLORS_FORECOLOR7;
                                text      = ((int)value + 1).ToString();
                            }
                            else if (columnName == "colAmount" || columnName == "colVolume")
                            {
                                if (dataSize > 0)
                                {
                                    foreColor = CDraw.PCOLORS_FORECOLOR9;
                                    text      = ((long)value).ToString();
                                }
                            }
                            else if (columnName == "colDiff")
                            {
                                if (dataSize > 0)
                                {
                                    foreColor = CDraw.GetPriceColor(value, 0);
                                    text      = value.ToString("0.00");
                                }
                            }
                            else if (columnName == "colDiffRange")
                            {
                                if (dataSize > 0)
                                {
                                    foreColor = CDraw.GetPriceColor(data.m_close, data.m_lastClose);
                                    text      = value.ToString("0.00") + "%";
                                }
                            }
                            else if (columnName == "colLastClose")
                            {
                                if (dataSize > 0)
                                {
                                    foreColor = CDraw.PCOLORS_FORECOLOR9;
                                    text      = value.ToString("0.00");
                                }
                            }
                            else
                            {
                                if (dataSize > 0)
                                {
                                    foreColor = CDraw.GetPriceColor(value, data.m_lastClose);
                                    text      = value.ToString("0.00");
                                }
                            }
                        }
                    }
                    if (info.GetValue("FILTER") != 1)
                    {
                        foreColor = CDraw.PCOLORS_FORECOLOR8;
                    }
                    SIZE  tSize  = paint.TextSize(text, font);
                    POINT tPoint = new POINT(rect.right - tSize.cx, rect.top + clipH / 2 - tSize.cy / 2);
                    RECT  tRect  = new RECT(tPoint.x, tPoint.y, tPoint.x + tSize.cx, tPoint.y + tSize.cy);
                    paint.DrawText(text, foreColor, font, tRect);
                    if (selected)
                    {
                        paint.DrawLine(CDraw.PCOLORS_LINECOLOR, 2, 0, rect.left, rect.bottom - 1, rect.right, rect.bottom - 1);
                    }
                }
            }
        }
Exemple #8
0
        /// <summary>
        /// 获取浮点型数值
        /// </summary>
        /// <returns>浮点型数值</returns>
        public override double GetDouble()
        {
            GridRow            row  = Row;
            SecurityFilterInfo info = (row as SecurityFilterResultRow).Info;

            if (m_fieldName != null && m_fieldName.Length > 0)
            {
                return(info.GetValue(m_fieldName));
            }
            else
            {
                SecurityLatestData data = info.LatestData;
                int        dataSize     = data != null ? data.m_securityCode.Length : 0;
                GridColumn column       = Column;
                String     columnName   = column.Name;
                if (columnName == "colNo")
                {
                    return(row.Index);
                }
                else if (columnName == "colAmount")
                {
                    if (dataSize > 0)
                    {
                        return(data.m_amount);
                    }
                }
                else if (columnName == "colClose")
                {
                    if (dataSize > 0)
                    {
                        return(data.m_close);
                    }
                }
                else if (columnName == "colDiff")
                {
                    if (dataSize > 0)
                    {
                        return(data.m_close - data.m_lastClose);
                    }
                }
                else if (columnName == "colHigh")
                {
                    if (dataSize > 0)
                    {
                        return(data.m_high);
                    }
                }
                else if (columnName == "colLow")
                {
                    if (dataSize > 0)
                    {
                        return(data.m_low);
                    }
                }
                else if (columnName == "colBuy")
                {
                    if (dataSize > 0)
                    {
                        return(data.m_buyPrice1);
                    }
                }
                else if (columnName == "colSell")
                {
                    if (dataSize > 0)
                    {
                        return(data.m_sellPrice1);
                    }
                }
                else if (columnName == "colDiffRange")
                {
                    if (dataSize > 0)
                    {
                        if (data.m_lastClose != 0)
                        {
                            return(100 * (data.m_close - data.m_lastClose) / data.m_lastClose);
                        }
                    }
                }
                else if (columnName == "colOpen")
                {
                    if (dataSize > 0)
                    {
                        return(data.m_open);
                    }
                }
                else if (columnName == "colLastClose")
                {
                    if (dataSize > 0)
                    {
                        return(data.m_lastClose);
                    }
                }
                else if (columnName == "colVolume")
                {
                    if (dataSize > 0)
                    {
                        return(data.m_volume);
                    }
                }
            }
            return(0);
        }