Beispiel #1
0
 /// <summary>
 /// 点击单元格
 /// </summary>
 /// <param name="cell">单元格</param>
 /// <param name="mp">坐标</param>
 /// <param name="button">按钮</param>
 /// <param name="clicks">点击次数</param>
 /// <param name="delta">鼠标滚轮值</param>
 public void OnClickCell(UserSecurityCellT2 cell, POINT mp, MouseButtonsA button, int clicks, int delta)
 {
     if (m_cellState > 0)
     {
         if (m_isEditing)
         {
             if (mp.x <= 30 && mp.y <= 30)
             {
                 UserSecurityCategory category = new UserSecurityCategory();
                 category.m_categoryID = "primary";
                 category.m_userID     = DataCenter.UserID;
                 category.m_codes      = cell.SecurityCode;
                 m_userSecurityService.DeleteSecurities(m_userSecurityService.OperatorRequestID, category);
             }
             Invalidate();
         }
         else
         {
             Security security = new Security();
             m_securityService.GetSecurityByCode(cell.SecurityCode, ref security);
             m_userSecurityService.AddVisitsCount(security.m_code);
             m_chart.SearchSecurity(security);
             cell.Clicks++;
             m_cells.Sort(new UserSecurityCellT2Compare());
             Update();
         }
     }
     m_cellState = 0;
 }
Beispiel #2
0
        /// <summary>
        /// 绑定自选股类别中的证券到表格
        /// </summary>
        /// <param name="category">类别</param>
        public void BindSecuritiesToSecuritiesGrid(UserSecurityCategory category)
        {
            m_gridSecurities.ClearRows();
            List <Security> securities = new List <Security>();

            if (category.m_codes != null && category.m_codes.Length > 0)
            {
                String[] codes     = category.m_codes.Split(new String[] { "," }, StringSplitOptions.RemoveEmptyEntries);
                int      codesSize = codes.Length;
                for (int i = 0; i < codesSize; i++)
                {
                    Security security = new Security();
                    bool     state    = m_securityService.GetSecurityByCode(codes[i], ref security);
                    if (state)
                    {
                        securities.Add(security);
                    }
                }
            }
            AddSecuritiesToSecuritiesGrid(securities);
        }
Beispiel #3
0
        /// <summary>
        /// 获取选中的股票
        /// </summary>
        /// <param name="securities">股票列表</param>
        public void GetSelectedSecurities(List <Security> securities)
        {
            List <GridRow> rows     = m_gridSecurities.GetRows();
            int            rowsSize = rows.Count;

            for (int i = 0; i < rowsSize; i++)
            {
                GridRow  row      = rows[i];
                Security security = new Security();
                if (m_securityService.GetSecurityByCode(row.GetCell(0).GetString(), ref security))
                {
                    securities.Add(security);
                }
            }
        }
Beispiel #4
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);
            paint.DrawRoundRect(COLOR.ARGB(200, 0, 0, 0), 1, 0, rect, cornerRadius);
            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);
            }
        }