Esempio n. 1
0
            public void PaintLevels(Graphics canvas, Rectangle rectPaint)
            {
                if (this.CollectionLevels.IsNull())
                {
                    return;
                }
                this.CountLevels = this.CollectionLevels.Count();
                if (this.CountLevels == 0)
                {
                    return;
                }
                if (this.CountLevels < MinCountLevels)
                {
                    this.CountLevels = MinCountLevels;
                }

                int index = 1;

                foreach (var valLevel in this.CollectionLevels)
                {
                    //*****************************
                    this.PaintOneLevel(canvas, rectPaint, valLevel.Volume, index);
                    index++;
                }

                GraphicShape.PaintLine(canvas, new Point(rectPaint.X, rectPaint.Y), new Point(rectPaint.X + rectPaint.Width, rectPaint.Y), Color.Black);

                PanelValues.CurrentValue = this.CollectionLevels.ElementAt(0).Volume;
                PanelValues.RectPaint    = rectPaint;
                PanelValues.ColorLines   = Color.DarkGray;
                PanelValues.minStepPrice = this.MinStepPrice;
                PanelValues.PaintPrices(canvas, this.Max, this.Min);
                PanelValues.PaintCurrentValue(canvas, this.Max, this.Min);
            }
Esempio n. 2
0
            private void PaintOneLevel(Graphics canvas, Rectangle rectPaint, MarketObject.Chart Value, decimal MaxPrice, decimal MinPrice)
            {
                int y  = GraphicShape.GetCoordinate(rectPaint.Height, MaxPrice, MinPrice, Value.Price);
                int x1 = rectPaint.X + GraphicShape.GetCoordinate(rectPaint.Width, this.Max, this.Min, Value.Volume > 0 ? 0 : Value.Volume);
                int x2 = rectPaint.X + GraphicShape.GetCoordinate(rectPaint.Width, this.Max, this.Min, Value.Volume < 0 ? 0 : Value.Volume);

                GraphicShape.PaintLine(canvas, new Point(x1, y), new Point(x2, y), Value.Volume < 0 ? Color.Red : Color.Green, 2);
            }
Esempio n. 3
0
        /// <summary>
        /// Рисует вертикальнцю линию с надписью
        /// </summary>
        /// <param name="g"></param>
        /// <param name="rectPaint"></param>
        /// <param name="ValText"></param>
        /// <param name="pStart"></param>
        /// <param name="pEnd"></param>
        /// <param name="color"></param>
        /// <param name="WidthLine"></param>
        /// <param name="TextVAlign"></param>
        public static void PaintVLine(Graphics g, Rectangle rectPaint, string ValText, Point pStart, Point pEnd, Color color, int WidthLine = 1, string TextVAlign = "bottom")
        {
            int WidthText  = Convert.ToInt32(ValText.Length * 6.5);
            int HeightText = 12;

            pEnd.Y -= HeightText;
            //ВЫравнивание лейбла
            switch (TextVAlign)
            {
            case "bottom":
                int fontSize = 8;
                g.DrawString(ValText,
                             new Font(new FontFamily("Helvetica"), fontSize, FontStyle.Regular, GraphicsUnit.Point),
                             new SolidBrush(color), pEnd.X - WidthText / 2, pEnd.Y);
                break;
            }

            GraphicShape.PaintLine(g, pStart, pEnd, color, WidthLine);
        }
Esempio n. 4
0
        public static void PaintHLine(Graphics g, Rectangle rectPaint, decimal valPrice, string Text, decimal maxPrice, decimal minPrice, Color color, string TextHAlign = "right")
        {
            int Y = GraphicShape.GetCoordinate(rectPaint.Height, maxPrice, minPrice, valPrice);

            //Если выходит за пределы, удаляем
            if (Y < 0 || Y > rectPaint.Y + rectPaint.Height)
            {
                return;
            }

            string ValText   = Text;
            int    WidthText = ValText.Length * 7;
            int    fontSize  = 8;
            Point  pLine1    = new Point(rectPaint.X, rectPaint.Y + Y);
            Point  pLine2    = new Point(rectPaint.X + rectPaint.Width - WidthText - 2, rectPaint.Y + Y);

            //ВЫравнивание лейбла
            switch (TextHAlign)
            {
            case "left":
                g.DrawString(ValText,
                             new Font(new FontFamily("Helvetica"), fontSize, FontStyle.Regular, GraphicsUnit.Point),
                             new SolidBrush(color), rectPaint.X, rectPaint.Y + Y - (fontSize));
                pLine1 = new Point(rectPaint.X + WidthText, rectPaint.Y + Y);
                pLine2 = new Point(rectPaint.X + rectPaint.Width, rectPaint.Y + Y);
                break;

            case "center":
                //Canvas.SetLeft(this.TextLabel, PaintPanel.X + (PaintPanel.Width / 2 - this.TextLabel.ActualWidth));
                break;

            default:
                // Canvas.SetLeft(this.TextLabel, PaintPanel.X + PaintPanel.Width - this.TextLabel.ActualWidth - this.MarginRight);
                g.DrawString(ValText,
                             new Font(new FontFamily("Helvetica"), fontSize, FontStyle.Regular, GraphicsUnit.Point),
                             new SolidBrush(color), rectPaint.X + rectPaint.Width - WidthText, rectPaint.Y + Y - (fontSize));
                break;
            }
            GraphicShape.PaintLine(g, pLine1, pLine2, color);
        }
Esempio n. 5
0
        /// <summary> Рисует объемы по активной свечке </summary>
        private void PaintHorVolByCandle(Graphics canvas, Candles.DataCandle activeCandle, Point crossLines)
        {
            if (activeCandle.Candle.HorVolumes.HVolCollection.Count == 0)
            {
                return;
            }
            Rectangle rectPaint = new Rectangle();

            rectPaint.X      = activeCandle.TailCoord.High.X + 1;
            rectPaint.Width  = 30 * 2;
            rectPaint.Y      = activeCandle.TailCoord.High.Y;
            rectPaint.Height = activeCandle.TailCoord.Low.Y - rectPaint.Y;

            long MaxVol = activeCandle.Candle.HorVolumes.HVolCollection.CollectionArray.Max(e => e.VolBuy + e.VolSell);
            long MinVol = 0;

            SolidBrush solidBrush = new SolidBrush(Color.LightGray);

            canvas.FillRectangle(solidBrush, rectPaint);
            activeCandle.Candle.HorVolumes.HVolCollection.CollectionArray.ForEach <MarketObject.ChartVol>((hv) =>
            {
                int y  = GraphicShape.GetCoordinate(this.RectAllTop.Height, this.MaxPrice, this.MinPrice, hv.Price);
                int x2 = (int)GraphicShape.GetCoordinate(rectPaint.Width, MaxVol, MinVol, hv.VolBuy + hv.VolSell);
                var p1 = new Point(rectPaint.X, y);
                var p2 = new Point(rectPaint.X + rectPaint.Width - x2, y);
                if (hv.VolBuy + hv.VolSell == MaxVol)
                {
                    GraphicShape.PaintText(canvas, MaxVol.ToString(), activeCandle.TailCoord.High.X, activeCandle.TailCoord.High.Y - 11, Color.Blue);
                }
                if (crossLines.Y + 5 > y && crossLines.Y - 5 < y)
                {
                    decimal priceY = GraphicShape.GetValueFromCoordinate(this.RectAllTop.Height, this.MaxPrice, this.MinPrice, crossLines.Y, this.PanelPrices.CountFloat);
                    if (hv.Price == priceY)
                    {
                        activeCandle.Description = (hv.VolBuy + hv.VolSell).ToString();
                    }
                }
                GraphicShape.PaintLine(canvas, p1, p2, Color.Blue, 2);
            });
        }
Esempio n. 6
0
            public void PaintLevels(Graphics canvas, Rectangle rectPaint, decimal MaxPrice, decimal MinPrice)
            {
                if (this.CollectionLevels == null)
                {
                    return;
                }
                this.CountLevels = this.CollectionLevels.Count();
                if (this.CountLevels == 0)
                {
                    return;
                }

                foreach (var valLevel in this.CollectionLevels)
                {
                    //*****************************
                    this.PaintOneLevel(canvas, rectPaint, valLevel, MaxPrice, MinPrice);
                }

                GraphicShape.PaintLine(canvas, new Point(rectPaint.X, rectPaint.Y), new Point(rectPaint.X, rectPaint.Y + rectPaint.Height), Color.Black);

                GraphicShape.PaintText(canvas, "min:" + this.Min.ToString(), rectPaint.X, rectPaint.Y + rectPaint.Height - 12, Color.Black);
                GraphicShape.PaintText(canvas, "max:" + this.Max.ToString(), rectPaint.X, rectPaint.Y + 1, Color.Black);
            }
Esempio n. 7
0
        /// <summary> Рисует одну свечку </summary>
        /// <param name="canvas"></param>
        /// <param name="rectPaint"></param>
        /// <param name="candleData"></param>
        /// <param name="index"></param>
        /// <param name="maxPrice"></param>
        /// <param name="minPrice"></param>
        private void PaintOneCandle(Graphics canvas, Rectangle rectPaint, CandleLib.CandleData candleData, int index, decimal maxPrice, decimal minPrice)
        {
            int tailY1 = GraphicShape.GetCoordinate(rectPaint.Height, maxPrice, minPrice, candleData.High);
            int tailY2 = GraphicShape.GetCoordinate(rectPaint.Height, maxPrice, minPrice, candleData.Low);
            int tailX1 = (int)((rectPaint.Width - this.WidthOneCandle * index) + this.WidthOneCandle / 2);

            int bodyX = (int)(rectPaint.Width - this.WidthOneCandle * index);
            int bodyY = GraphicShape.GetCoordinate(rectPaint.Height, maxPrice, minPrice, candleData.Open > candleData.Close ? candleData.Open : candleData.Close);

            int bodyWidth  = this.WidthOneCandle - MarginCandle; //- чтобы свечки не слипались
            int bodyHeight = GraphicShape.GetCoordinate(rectPaint.Height, maxPrice, minPrice, candleData.Open < candleData.Close ? candleData.Open : candleData.Close);

            bodyHeight = bodyHeight - bodyY;
            bodyHeight = bodyHeight == 0 ? bodyHeight + 1 : bodyHeight;

            GraphicShape.PaintLine(canvas, new Point(tailX1, tailY1), new Point(tailX1, tailY2), Color.Black, 2);
            GraphicShape.PaintRectangle(canvas, bodyX, bodyY, bodyWidth, bodyHeight, Color.Black, candleData.Open > candleData.Close ? Color.LightCoral : Color.LightGreen);

            if (OnPaintCandle != null)
            {
                OnPaintCandle(new DataCandle()
                {
                    PaintRect = rectPaint,
                    Candle    = candleData,
                    TailCoord = new TailCoord()
                    {
                        High = new Point(tailX1, tailY1), Low = new Point(tailX1, tailY2)
                    },
                    Body = new Rectangle()
                    {
                        X = bodyX, Y = bodyY, Width = bodyWidth, Height = bodyHeight
                    },
                    Index = index
                });
            }
        }