示例#1
0
            internal void CmCalculateScale()
            {
                _viewCountBar = this.Width / this.DeltaX;

                int dx         = 64;
                int countGLine = this.Width / dx;

                _gridLines.Clear();


                iBars ibars  = this.Owner.Owner.iBars;
                int   bcount = this.Owner.Bars.Count;

                for (int i = 0; i < countGLine; i++)
                {
                    int    x        = i * dx;
                    int    barIndex = this.Position + x;
                    string desc     = "";

                    if (barIndex < bcount)
                    {
                        Bar bar = ibars.GetBar(barIndex);
                        if (i == 0)
                        {
                            desc = bar.Time.ToString("d MMM yyyy");
                        }
                        else
                        {
                            desc = bar.Time.ToString("d MMM ") + bar.Time.ToShortTimeString();
                        }
                    }
                    _gridLines.Add(new GridLine(barIndex, x, desc));
                }
            }
示例#2
0
        protected override void OnCalculateScale()
        {
            int countTick  = this.Owner.Owner.Symbol.Ticks.Count;
            int beginIndex = this.Owner.HorizontalScale.Position;

            if (_savedCountTick == countTick && _savedPosition == beginIndex && _savedWidth == this.Owner.Width)
            {
                return;
            }
            _savedCountTick = countTick;
            _savedPosition  = beginIndex;
            _savedWidth     = this.Owner.Width;

            int       endIndex = beginIndex + this.Owner.HorizontalScale.CountBarView;
            IBarsData bars     = this.Owner.Owner.Bars;
            int       countBar = bars.Count;


            endIndex = Math.Min(endIndex, countBar);
            if (endIndex - beginIndex == 0)
            {
                return;
            }

            iBars ibars = this.Owner.Owner.iBars;

            float min = float.MaxValue;
            float max = float.MinValue;

            for (int i = beginIndex; i < endIndex; i++)
            {
                Bar bar = ibars.GetBar(i);
                min = Math.Min(bar.Low, min);
                max = Math.Max(bar.High, max);
            }
            this.Owner.VerticalScale.SetScaleValue(min, max, this.Owner.Owner.Symbol.Digits);
        }
示例#3
0
        protected override void OnPaint(ChartGraphics g)
        {
            int       beginIndex = this.Owner.HorizontalScale.Position;
            int       endIndex   = beginIndex + this.Owner.HorizontalScale.CountBarView;
            IBarsData bars       = this.Owner.Owner.Bars;
            int       countBar   = bars.Count;

            endIndex = Math.Min(endIndex, countBar);
            g.SelectPen(this.Color);
            GdiBrush brushUp   = g.SelectBrush(ColorUp);
            GdiBrush brushDown = g.SelectBrush(ColorDown);

            int barWidth = 0;

            switch (this.Owner.HorizontalScale.Zoom)
            {
            case ChartBox.ChartHorizontalScale.HorizontalZoom.Smaller:
            case ChartBox.ChartHorizontalScale.HorizontalZoom.Small:
                barWidth = 0;
                break;

            case ChartBox.ChartHorizontalScale.HorizontalZoom.Medium:
                barWidth = 2;
                break;

            case ChartBox.ChartHorizontalScale.HorizontalZoom.Larger:
                barWidth = 4;
                break;

            case ChartBox.ChartHorizontalScale.HorizontalZoom.Large:
                barWidth = 10;
                break;

            case ChartBox.ChartHorizontalScale.HorizontalZoom.BigLarge:
                barWidth = 24;
                break;
            }

            iBars ibars = this.Owner.Owner.iBars;

            for (int i = beginIndex; i < endIndex; i++)
            {
                Bar bar = ibars.GetBar(i);

                int x     = this.Owner.HorizontalScale.GetX(i);
                int yLow  = this.GetY(bar.Low);
                int yHigh = this.GetY(bar.High);

                if (_barsStyle != FigureBarsStyle.Line)
                {
                    g.DrawLine(x, yLow, x, yHigh);

                    if (barWidth == 0)
                    {
                        continue;
                    }

                    int yClose = this.GetY(bar.Close);
                    int yOpen  = this.GetY(bar.Open);

                    int barWD = barWidth / 2;

                    int x1 = x - barWD, h = 0, y = 0;

                    if (bar.Close > bar.Open)
                    {
                        h = yOpen - yClose;
                        y = yClose;
                        g.FillRectangleExt(brushUp, x1, y, barWidth, h);
                    }
                    else if (bar.Close < bar.Open)
                    {
                        h = yClose - yOpen;
                        y = yOpen;
                        g.FillRectangleExt(brushDown, x1, y, barWidth, h);
                    }

                    if (h > 0)
                    {
                        g.DrawRectangle(x1, y, barWidth, h);
                    }
                }
                else
                {
                }
            }
        }