Exemple #1
0
 /// <summary>
 /// 绘制有下划线的数字
 /// </summary>
 /// <param name="paint">绘图对象</param>
 /// <param name="value">值</param>
 /// <param name="digit">保留小数位数</param>
 /// <param name="font">字体</param>
 /// <param name="fontColor">文字颜色</param>
 /// <param name="zeroAsEmpty">0是否为空</param>
 /// <param name="x">横坐标</param>
 /// <param name="y">纵坐标</param>
 /// <returns>绘制的横坐标</returns>
 public static int DrawUnderLineNum(Graphics g, double value, int digit, Font font, Color fontColor, bool zeroAsEmpty, int x, int y)
 {
     if (zeroAsEmpty && value == 0)
     {
         String text = "-";
         Size   size = g.MeasureString(text, font).ToSize();
         DrawText(g, text, fontColor, font, x, y);
         return(size.Width);
     }
     else
     {
         String[] nbs = LbCommon.GetValueByDigit(value, digit, true).Split(new String[] { "." }, StringSplitOptions.RemoveEmptyEntries);
         if (nbs.Length == 1)
         {
             Size size = g.MeasureString(nbs[0], font).ToSize();
             DrawText(g, nbs[0], fontColor, font, x, y);
             return(size.Width);
         }
         else
         {
             Size decimalSize = g.MeasureString(nbs[0], font).ToSize();
             Size size        = g.MeasureString(nbs[1], font).ToSize();
             DrawText(g, nbs[0], fontColor, font, x, y);
             DrawText(g, nbs[1], fontColor, font, x
                      + decimalSize.Width - 4, y);
             Pen pen = new Pen(fontColor);
             g.DrawLine(pen, x
                        + decimalSize.Width, y + decimalSize.Height - 3,
                        x + decimalSize.Width + size.Width - 7, y + decimalSize.Height - 3);
             pen.Dispose();
             return(decimalSize.Width + size.Width - 7);
         }
     }
 }
Exemple #2
0
        /// <summary>
        /// 画线
        /// </summary>
        public override void DrawPlot(Graphics g, List <PlotBase.PlotMark> pList, Color curColor)
        {
            if (pList.Count == 0)
            {
                return;
            }
            ChartDiv div    = ChartDiv;
            float    y1     = Chart.GetY(div, pList[0].Value, AttachYScale.Left) - div.DisplayRectangle.Y - div.TitleHeight;
            Brush    pBrush = new SolidBrush(curColor);
            Pen      pPen   = new Pen(pBrush);

            pPen.Width = LineWidth;
            if (Style != null)
            {
                pPen.DashPattern = Style;
            }
            g.DrawLine(pPen, 0, y1, Chart.GetWorkSpaceX(), y1);
            String str   = bs + " " + LbCommon.GetValueByDigit(pList[0].Value, 2, true);
            SizeF  sizeF = g.MeasureString(str, wordFont);

            g.DrawString(str, wordFont, pBrush, new PointF((float)Chart.GetWorkSpaceX() - sizeF.Width, y1 - sizeF.Height));
            pPen.Dispose();
            pBrush.Dispose();
        }
Exemple #3
0
        /// <summary>
        /// 秒表方法
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void timer_Tick(object sender, EventArgs e)
        {
            List <String> refreshCodes = new List <string>();

            lock (newDataCodes) {
                if (newDataCodes.Count > 0)
                {
                    foreach (String key in newDataCodes.Keys)
                    {
                        refreshCodes.Add(key);
                    }
                    newDataCodes.Clear();
                }
            }
            int refreshCodesSize = refreshCodes.Count;

            if (refreshCodes.Count > 0)
            {
                if (updateCells.Count > 0)
                {
                    if (updateCells.Count > 10)
                    {
                        for (int i = 0; i < updateCells.Count; i++)
                        {
                            GridCell updateCell = updateCells[i];
                            updateCell.Style.BackColor = Color.Empty;
                        }
                    }
                    else
                    {
                        for (int i = 0; i < updateCells.Count; i++)
                        {
                            GridCell updateCell = updateCells[i];
                            updateCell.Style.BackColor = Color.Empty;
                        }
                    }
                    updateCells.Clear();
                }
                for (int i = 0; i < refreshCodesSize; i++)
                {
                    GridRow row  = null;
                    String  code = refreshCodes[i];
                    if (rowsMap.ContainsKey(code))
                    {
                        row = rowsMap[code];
                        SecurityLatestData lastestData = new SecurityLatestData();
                        SecurityService.GetLatestData(code, ref lastestData);
                        double lastClose = lastestData.m_lastClose;
                        double diff = 0, diffRange = 0;
                        diff = lastestData.m_close - lastestData.m_lastClose;
                        if (lastestData.m_lastClose != 0)
                        {
                            diffRange = diff / lastestData.m_lastClose;
                        }
                        GridCell cell3 = row.GetCell("colP3");
                        if (lastestData.m_close != cell3.GetDouble())
                        {
                            cell3.SetDouble(lastestData.m_close);
                            cell3.Style.TextColor = GetPriceColor(lastestData.m_close, lastClose);
                            updateCells.Add(cell3);
                        }

                        GridCell cell4 = row.GetCell("colP4");
                        if (diff != cell4.GetDouble())
                        {
                            cell4.SetDouble(Convert.ToDouble(LbCommon.GetValueByDigit(diff, 2, true)));
                            cell4.Style.TextColor = GetPriceColor(lastestData.m_close, lastClose);
                            updateCells.Add(cell4);
                        }

                        GridCell cell5 = row.GetCell("colP5");
                        if (diffRange != cell5.GetDouble())
                        {
                            cell5.SetDouble(diffRange);
                            cell5.Style.TextColor = GetPriceColor(lastestData.m_close, lastClose);
                            updateCells.Add(cell5);
                        }

                        GridCell cell6 = row.GetCell("colP6");
                        if (lastestData.m_high != cell6.GetDouble())
                        {
                            cell6.SetDouble(lastestData.m_high);
                            cell6.Style.TextColor = GetPriceColor(lastestData.m_high, lastClose);
                            updateCells.Add(cell6);
                        }

                        GridCell cell7 = row.GetCell("colP7");
                        if (lastestData.m_low != cell7.GetDouble())
                        {
                            cell7.SetDouble(lastestData.m_low);
                            cell7.Style.TextColor = GetPriceColor(lastestData.m_low, lastClose);
                            updateCells.Add(cell7);
                        }

                        GridCell cell8 = row.GetCell("colP8");
                        if (lastestData.m_open != cell8.GetDouble())
                        {
                            cell8.SetDouble(lastestData.m_open);
                            cell8.Style.TextColor = GetPriceColor(lastestData.m_open, lastClose);
                            updateCells.Add(cell8);
                        }

                        GridCell cell9 = row.GetCell("colP9");
                        if (lastestData.m_volume != cell9.GetDouble())
                        {
                            cell9.SetDouble(lastestData.m_volume);
                            updateCells.Add(cell9);
                        }

                        GridCell cell10 = row.GetCell("colP10");
                        if (lastestData.m_amount != cell10.GetDouble())
                        {
                            cell10.SetDouble(lastestData.m_amount);
                            updateCells.Add(cell10);
                        }

                        GridCell cell11 = row.GetCell("colP11");
                        if (lastestData.m_buyPrice1 != cell11.GetDouble())
                        {
                            cell11.SetDouble(lastestData.m_buyPrice1);
                            cell11.Style.TextColor = GetPriceColor(lastestData.m_buyPrice1, lastClose);
                            updateCells.Add(cell11);
                        }

                        GridCell cell12 = row.GetCell("colP12");
                        if (lastestData.m_buyVolume1 != cell12.GetDouble())
                        {
                            cell12.SetDouble(lastestData.m_buyVolume1);
                            updateCells.Add(cell12);
                        }

                        GridCell cell13 = row.GetCell("colP13");
                        if (lastestData.m_sellPrice1 != cell13.GetDouble())
                        {
                            cell13.SetDouble(lastestData.m_sellPrice1);
                            cell13.Style.TextColor = GetPriceColor(lastestData.m_sellPrice1, lastClose);
                            updateCells.Add(cell13);
                        }

                        GridCell cell14 = row.GetCell("colP14");
                        if (lastestData.m_sellVolume1 != cell14.GetDouble())
                        {
                            cell14.SetDouble(lastestData.m_sellVolume1);
                            updateCells.Add(cell14);
                        }
                    }
                }
                if (updateCells.Count > 0)
                {
                    for (int i = 0; i < updateCells.Count; i++)
                    {
                        updateCells[i].Style.BackColor = Color.FromArgb(50, 255, 255, 255);
                    }
                    UpdateGrid();
                    Invalidate();
                }
            }
        }