コード例 #1
0
        /// <summary>
        /// Рисует блок состоящий из нескольких свечей
        /// </summary>
        /// <param name="prepHorV"></param>
        /// <param name="max"></param>
        /// <param name="countInBlock"></param>
        private void PaintOneBlock(PrepareHorVol prepHorV, Chart max, int countInBlock)
        {
            var canvas        = Panel.GetGraphics;
            var canvasOnlyVol = PanelVolume.GetGraphics;

            if (prepHorV.RectBlock.Width >= MIN_WIDTH_FOR_LAYBORDER)
            {
                //рисует прямоугольник выделяющий период
                var rectVol = new RectDraw();
                rectVol.ColorFill   = ColorLayVol;
                rectVol.ColorBorder = ColorLayBorder;
                rectVol.Paint(canvas, prepHorV.RectBlock.X, prepHorV.RectBlock.Y,
                              prepHorV.RectBlock.Width, prepHorV.RectBlock.Height);

                var textMax = new TextDraw();
                textMax.Color = Color.Black;
                var text = "max:" + prepHorV.MaxVol.ToString();
                var size = textMax.GetSizeText(canvas, text);
                textMax.Paint(canvas, text, prepHorV.RectBlock.X, prepHorV.RectBlock.Y - size.Height);
            }

            prepHorV.HorVolumes.ToArray().ForEach <ChartFull>((hv) =>
            {
                this.PaintLineHVol(canvas, prepHorV.RectBlock, max, new Chart(), hv);
                if (PaintOnlyFirstBlock)
                {
                    this.PaintLineHVol(canvasOnlyVol, PanelVolume.Rect.Rectangle, max, new Chart(), hv, Color.Blue);
                }
            });
        }
コード例 #2
0
ファイル: ActiveTrades.cs プロジェクト: Joni1010/market
        public override void FastUpdate()
        {
            Panel.Clear();
            if (!IsEnable())
            {
                return;
            }
            if (ListTrades.NotIsNull() && ListTrades.Count() > 0)
            {
                var canvas = Panel.GetGraphics;
                //Устанавливаем первую уоординату + смещение
                float XlastTrade = Panel.Rect.Width - 40;
                var   textVol    = new TextDraw();
                textVol.SetFontSize(6);
                textVol.Color = Color.Black;

                foreach (var trade in ListTrades)
                {
                    int   width  = 4;
                    int   Height = 4;
                    SizeF sizeText;
                    float xPlusText = 0;
                    float yPlusText = 0;
                    if (MinVolumeShow <= trade.Volume)
                    {
                        sizeText  = textVol.GetSizeText(canvas, trade.Volume.ToString());
                        width     = Height = (int)(sizeText.Width * 2);
                        xPlusText = (width - sizeText.Width) / 2;
                        yPlusText = (Height - sizeText.Height) / 2;
                    }
                    XlastTrade = XlastTrade - width;

                    float yPrice      = (float)GetYByPrice(trade.Price);
                    var   rect        = new RectDraw();
                    var   colorCandle = trade.Direction == OrderDirection.Buy ? Color.LightGreen : Color.LightCoral;
                    var   colorBorder = Color.Black;
                    rect.Paint(canvas, XlastTrade, yPrice - Height / 2, width, Height, colorBorder, colorCandle);

                    if (MinVolumeShow <= trade.Volume)
                    {
                        textVol.Paint(canvas, trade.Volume.ToString(),
                                      XlastTrade + xPlusText, (yPrice - Height / 2) + yPlusText);
                    }
                }
            }
        }
コード例 #3
0
        /// <summary>
        /// Рисует уровень ввиде свободного прямоугольника
        /// </summary>
        /// <param name="g"></param>
        /// <param name="rect"></param>
        /// <param name="lev"></param>
        /// <param name="widthLine"></param>
        private void PaintRectangleLevel(Graphics g, Rectangle rect, DoubleLevel lev, float widthLine = 1)
        {
            int yTop = GMath.GetCoordinate(rect.Height, Panel.Params.MaxPrice, Panel.Params.MinPrice, lev.Top);
            int yBot = GMath.GetCoordinate(rect.Height, Panel.Params.MaxPrice, Panel.Params.MinPrice, lev.Bottom);

            if (yBot < 0 && yTop > 0)
            {
                yBot = rect.Y + rect.Height;
            }
            if (yTop < 0 && yBot > 0)
            {
                yTop = rect.Y;
            }

            var height = yBot - yTop;

            if (height <= 0)
            {
                return;
            }
            var rectLev = new RectDraw();

            rectLev.ColorBorder = Color.FromArgb(100, Color.Black);
            rectLev.ColorFill   = Color.FromArgb(40, Color.Blue);
            rectLev.WidthBorder = widthLine;
            rectLev.Paint(g, rect.X, yTop, rect.Width, height);

            var middleLine = new Line();

            middleLine.Width = 1;
            middleLine.Style = System.Drawing.Drawing2D.DashStyle.Dot;
            middleLine.Paint(g, new PointF(rect.X, yTop + height / 2), new PointF(rect.X + rect.Width, yTop + height / 2),
                             Color.FromArgb(100, Color.Black));

            var topText    = new TextDraw();
            var dataText   = topText.GetSizeText(g, lev.Top.ToString());
            int HeightText = (int)dataText.Height;

            if (height > HeightText * 3 && rect.Width > dataText.Width)
            {
                topText.Paint(g, lev.Top.ToString(), rect.X, yTop);
                topText.Paint(g, lev.Bottom.ToString(), rect.X, yBot - HeightText);
            }
        }