Example #1
0
        public bool PaintLast(CandleInfo candle)
        {
            PanelLast.Clear();
            if (CollectionLevels.IsNull() || this.CollectionLevels.Count == 0)
            {
                return(false);
            }
            var canvas = PanelLast.GetGraphics;
            var level  = this.CollectionLevels.ElementAt(0);

            if (level.NotIsNull())
            {
                if (level.Volume > this.Max || level.Volume < this.Min)
                {
                    if (this.OnReachLimitValues.NotIsNull())
                    {
                        this.OnReachLimitValues(level.Volume, this.Max, this.Min);
                    }
                    return(false);
                }
                else
                {
                    PaintOneLevel(canvas, level, candle, true);
                    Values.PaintCurrentValue(level.Volume, this.Max, this.Min);
                    Values.PanelCurValue.Paint(canvas);
                }
            }
            return(true);
        }
Example #2
0
        public void Paint()
        {
            Panel.Clear();
            var canvas = Panel.GetGraphics;

            if (this.CollectionOrders.IsNull())
            {
                return;
            }
            int count = this.CollectionOrders.Count();

            if (count == 0)
            {
                return;
            }

            foreach (var ord in this.CollectionOrders.ToArray())
            {
                var vol     = ord.Volume < 0 ? ord.Volume * -1 : ord.Volume;
                var horLine = new HorLine();
                horLine.ColorLine  = horLine.ColorText = ord.Volume > 0 ? Color.DarkGreen : Color.DarkRed;
                horLine.TextHAlign = HorLine.DirectionLine.Left;
                horLine.FillText   = true;
                horLine.Paint(canvas, Panel.Rect.Rectangle, ord.Price, ord.Price.ToString(), Panel.Params.MaxPrice, Panel.Params.MinPrice);
            }
        }
Example #3
0
        /// <summary> Отрисовывет свечи</summary>
        /// <param name="canvas"></param>
        /// <param name="rectPaint"></param>
        public void PaintCandles()
        {
            if (CountPaintCandle == 0)
            {
                return;
            }
            Panel.Params.WidthCandle = GetWidthOne();

            Panel.Clear();
            var canvas = Panel.GetGraphics;

            AllDataPaintedCandle.Clear();

            MaxValues = new MaxData();

            //Событие перед отрисовкой
            if (!OnBeforePaintCandle.IsNull())
            {
                OnBeforePaintCandle();
            }

            List <Chart> HVolume = new List <Chart>();
            int          index   = 1;

            Count = CollectionCandle.Count();
            CollectionCandle.ForEach <CandleData>((candleData) =>
            {
                if (OnEachCandle.NotIsNull())
                {
                    OnEachCandle(index - 1, candleData, Count);
                }
                if (index <= CountPaintCandle)
                {
                    var lastPCan = PaintOneCandle(canvas, Panel, candleData, index, index > 1 ? true : false);
                    if (OnEachPaintedCandle.NotIsNull())
                    {
                        if (index == 1)
                        {
                            lastPCan.First = true;
                        }
                        if (index == CountPaintCandle)
                        {
                            lastPCan.Last = true;
                        }
                        OnEachPaintedCandle(lastPCan);
                    }
                }
                index++;
            });

            if (!OnPaintedCandles.IsNull())
            {
                OnPaintedCandles();
            }
        }
Example #4
0
        /// <summary>  Рисует контрольную линию текущего значения </summary>
        public void PaintCurrentValue(decimal curValue, decimal max, decimal min)
        {
            CurrentValue = curValue;
            PanelCurValue.Clear();
            var canvas = PanelCurValue.GetGraphics;

            var horLine = new HorLine();

            horLine.ColorLine = horLine.ColorText = this.ColorCurrentLine;
            horLine.FillText  = true;
            horLine.Paint(canvas, Panel.Rect.Rectangle, this.CurrentValue, max, min);
        }
Example #5
0
 public GHorVol(BaseParams param)
 {
     Panel           = new ViewPanel(param);
     PanelVolume     = new ViewPanel(param);
     Panel.OnResize += (rect) =>
     {
         Panel.Clear();
     };
     PanelVolume.OnResize += (rect) =>
     {
         PanelVolume.Clear();
     };
 }
Example #6
0
        /// <summary> Отрисовка </summary>
        /// <param name="canvas">Полотно</param>
        /// <param name="MaxValue">MAX значение</param>
        /// <param name="MinValue">MIN значение</param>
        public void Paint(decimal MaxValue, decimal MinValue)
        {
            Panel.Clear();
            var canvas = this.Panel.GetGraphics;

            decimal Interval  = MaxValue - MinValue;
            decimal stepValue = 0;

            if (Panel.Params.MinStepPrice >= 1)
            {
                stepValue = Convert.ToInt32(Interval / this.CountLineValue);
            }
            else
            {
                stepValue = decimal.Round(Interval / this.CountLineValue, this.Panel.Params.CountFloat);
            }
            var strStep = stepValue.ToString();

            strStep   = strStep.Substring(0, strStep.Length - 1) + '0';
            stepValue = strStep.ToDecimal();

            //Рисуем линию границы
            Point pBorder1 = new Point(this.Panel.Rect.X + this.Panel.Rect.Width - WidthBorder, this.Panel.Rect.Y);
            Point pBorder2 = new Point(this.Panel.Rect.X + this.Panel.Rect.Width - WidthBorder, this.Panel.Rect.Y + this.Panel.RectScreen.Height);

            var line = new Line();

            line.Paint(canvas, pBorder1, pBorder2, Color.Black);

            var horLine = new HorLine();

            horLine.ColorLine     = this.ColorLines;
            horLine.ColorText     = this.ColorText;
            horLine.FillText      = true;
            horLine.ColorFillText = Color.White;
            decimal Value = MinValue;

            //Значение сетки
            while (Value < MaxValue && stepValue > 0)
            {
                horLine.Paint(canvas, Panel.Rect.Rectangle, Value, MaxValue, MinValue);
                Value += stepValue;
            }
            horLine.Paint(canvas, Panel.Rect.Rectangle, 0, MaxValue, MinValue);
        }
Example #7
0
        /// <summary>  Отрисовка текущей свечи (самой правой) </summary>
        public bool PaintLastCandle(CandleInfo candle)
        {
            PanelLastCandle.Clear();
            if (CollectionCandle.IsNull())
            {
                return(false);
            }
            var canvas = PanelLastCandle.GetGraphics;

            if (candle.NotIsNull())
            {
                if (PanelLastCandle.Params.AutoSize)
                {
                    //контроль максимальной цены
                    if (candle.Candle.High > PanelLastCandle.Params.MaxPrice)
                    {
                        if (OnReachMinMax.NotIsNull())
                        {
                            OnReachMinMax(candle.Candle.High, PanelLastCandle.Params.MaxPrice, PanelLastCandle.Params.MinPrice);
                        }
                        return(false);
                    }
                    //контроль минимальной цены
                    if (candle.Candle.Low < PanelLastCandle.Params.MinPrice)
                    {
                        if (OnReachMinMax.NotIsNull())
                        {
                            OnReachMinMax(candle.Candle.Low, PanelLastCandle.Params.MaxPrice, PanelLastCandle.Params.MinPrice);
                        }
                        return(false);
                    }
                }
                PaintOneCandle(canvas, PanelLastCandle, candle.Candle, 1);
            }
            return(true);
        }
Example #8
0
        /// <summary>Отрисовка перекрестья</summary>
        /// <param name="coord"></param>
        public void PaintCrossLines(Point coord, GCandles.CandleInfo candle)
        {
            Panel.Clear();
            var    canvas = Panel.GetGraphics;
            string time   = "";

            Data = new DataCross();
            if (candle.NotIsNull())
            {
                Data.Candle = candle;
                Data.Time   = Data.Candle.Candle.Time;
                string d    = Data.Time.Day.ToString();
                string m    = Data.Time.Month.ToString();
                string y    = Data.Time.Year.ToString();
                string min  = Data.Time.Minute.ToString();
                string hour = Data.Time.Hour.ToString();
                time = (d.Length < 2 ? '0' + d : d) + "." + (m.Length < 2 ? '0' + m : m) + "." + y + " " +
                       (hour.Length < 2 ? '0' + hour : hour) + ":" + (min.Length < 2 ? '0' + min : min);
            }
            Data.Price = GMath.GetValueFromCoordinate(this.HeightForPrice, Panel.Params.MaxPrice, Panel.Params.MinPrice, coord.Y, Panel.Params.CountFloat);

            var lineVer = new VerLine();

            lineVer.ColorLine = lineVer.ColorText = Color.Black;
            lineVer.WidthLine = 1;
            lineVer.FillText  = true;
            lineVer.Paint(canvas, time, new Point(coord.X, 0), new Point(coord.X, Panel.Rect.Height));
            Data.Point.X = coord.X;

            var horLine = new HorLine();

            horLine.ColorLine = horLine.ColorText = Color.Black;
            horLine.FillText  = true;
            horLine.Paint(canvas, Panel.Rect.Rectangle, coord.Y, Data.Price.ToString(), Panel.Params.MaxPrice, Panel.Params.MinPrice);
            Data.Point.Y = coord.Y;

            var priceText          = new TextDraw();
            var TextAppendByCandle = "";

            //Данные по свечи в углу
            if (Data.Candle.NotIsNull())
            {
                priceText.Color = Color.Black;
                priceText.SetFontSize(8);
                priceText.Paint(canvas, "T: " + time + "\r\n" +
                                "O: " + Data.Candle.Candle.Open.ToString() + "\r\n" +
                                "H: " + Data.Candle.Candle.High.ToString() + "\r\n" +
                                "L: " + Data.Candle.Candle.Low.ToString() + "\r\n" +
                                "C: " + Data.Candle.Candle.Close.ToString() + "\r\n" +
                                "V: " + Data.Candle.Candle.Volume.ToString() + "\r\n"
                                , 0, 0);
                TextAppendByCandle = "Vol:" + Data.Candle.Candle.Volume;
            }

            //Текщие данные по цене и времени
            priceText.Color = Color.Black;
            priceText.SetFontSize(8);
            priceText.Paint(canvas, Data.Price.ToString() + "\r\n"
                            + time + "\r\n"
                            + TextAppendByCandle
                            , coord.X + 10, coord.Y + 20);
        }
Example #9
0
        /// <summary>
        /// Рисование обьема по каждой свечке
        /// </summary>
        /// <param name="countInBlock"></param>
        public void PaintHorVolEachBlock(int countInBlock = 1, bool isCollection = false)
        {
            lock (_lockPaint)
            {
                Panel.Clear();
                PanelVolume.Clear();
                if (countInBlock <= 0)
                {
                    return;
                }
                List <PrepareHorVol> preDataHVol = new List <PrepareHorVol>();
                var CurrentHVol = new PrepareHorVol();
                CurrentHVol.HorVolumes = new HVolume();
                preDataHVol.Add(CurrentHVol);

                var list   = this.CollectionCandles.ToArray();
                var maxAll = new Chart();

                if (list.NotIsNull() && list.Count() > 0)
                {
                    int indexer = 0;
                    int steper  = countInBlock;
                    if (isCollection)
                    {
                        if (CollectionCandleInBlocks.Count > 0)
                        {
                            steper = CollectionCandleInBlocks.ElementAt(indexer) + 1;
                        }
                        else
                        {
                            return;
                        }
                    }

                    /* foreach (var can in list)
                     * {
                     *   if (can.NotIsNull())
                     *   {
                     *       foreach (var curVol in can.Candle.GetHorVolumes().HVolCollection.ToArray())
                     *       {
                     *           CurrentHVol.HorVolumes.AddVolume(curVol.Price, curVol.VolBuy, true);
                     *           CurrentHVol.HorVolumes.AddVolume(curVol.Price, curVol.VolSell, false);
                     *           CurrentHVol.SumBuyVol += curVol.VolBuy;
                     *           CurrentHVol.SumSellVol += curVol.VolSell;
                     *       }
                     *
                     *       CurrentHVol.RectBlock.X = CurrentHVol.RectBlock.X > can.Body.X || CurrentHVol.RectBlock.X == 0
                     *           ? can.Body.X : CurrentHVol.RectBlock.X;
                     *       CurrentHVol.RectBlock.Y = CurrentHVol.RectBlock.Y > can.TailCoord.High.Y || CurrentHVol.RectBlock.Y == 0
                     *           ? can.TailCoord.High.Y : CurrentHVol.RectBlock.Y;
                     *       CurrentHVol.RectBlock.Width = CurrentHVol.RectBlock.Width < (can.Body.X + can.Body.Width) || CurrentHVol.RectBlock.Width == 0
                     *           ? (can.Body.X + can.Body.Width) : CurrentHVol.RectBlock.Width;
                     *       CurrentHVol.RectBlock.Height = CurrentHVol.RectBlock.Height < can.TailCoord.Low.Y || CurrentHVol.RectBlock.Height == 0
                     *           ? can.TailCoord.Low.Y : CurrentHVol.RectBlock.Height;
                     *   }
                     *   steper--;
                     *   if (steper <= 0)
                     *   {
                     *       CurrentHVol.MaxElem = CurrentHVol.HorVolumes.MaxVolume;
                     *       CurrentHVol.MinElem = CurrentHVol.HorVolumes.MinVolume;
                     *
                     *       if (maxAll.Volume < CurrentHVol.MaxVol)
                     *       {
                     *           maxAll = CurrentHVol.MaxElem;
                     *       }
                     *       CurrentHVol.LastCandle = can;
                     *
                     *       indexer++;
                     *       steper = countInBlock;
                     *       if (isCollection)
                     *       {
                     *           if (indexer >= CollectionCandleInBlocks.Count)
                     *           {
                     *               break;
                     *           }
                     *           steper = CollectionCandleInBlocks.ElementAt(indexer) - CollectionCandleInBlocks.ElementAt(indexer - 1);
                     *       }
                     *       CurrentHVol = new PrepareHorVol();
                     *       CurrentHVol.HorVolumes = new HVolume();
                     *       preDataHVol.Add(CurrentHVol);
                     *   }
                     * }*/
                }
                PaintOnlyFirstBlock = true;
                foreach (var elVol in preDataHVol)
                {
                    RectangleF rectPaint = new RectangleF();
                    rectPaint.X      = elVol.RectBlock.X;
                    rectPaint.Y      = elVol.RectBlock.Y;
                    rectPaint.Width  = elVol.RectBlock.Width - elVol.RectBlock.X;
                    rectPaint.Height = elVol.RectBlock.Height - elVol.RectBlock.Y;
                    elVol.RectBlock  = rectPaint;

                    this.PaintOneBlock(elVol, maxAll, countInBlock);
                    PaintOnlyFirstBlock = false;
                }
            }
        }