/// <summary>
        /// Returns the first and last point for the given lines in a region.
        /// </summary>
        /// <param name="region">The region.</param>
        /// <param name="first">The index of the first line.</param>
        /// <param name="last">The index of the last line.</param>
        /// <param name="allowEstimatesForOutOfViewLines">if set to <c>true</c> allow estimates for out of view lines.</param>
        /// <returns></returns>
        public override DoubleSpan RangeToPoints(ScrollAxisRegion region, int first, int last, bool allowEstimatesForOutOfViewLines)
        {
            VisibleLinesCollection lines = GetVisibleLines();

            // If line is visible use already calculated values,
            // otherwise get value from Distances
            VisibleLineInfo line1 = lines.GetVisibleLineAtLineIndex(first);
            VisibleLineInfo line2 = lines.GetVisibleLineAtLineIndex(last);

            double p1, p2;

            p1 = line1 == null?Distances.GetCumulatedDistanceAt(first) : GetCumulatedOrigin(line1);

            p2 = line2 == null?Distances.GetCumulatedDistanceAt(last + 1) : GetCumulatedCorner(line2);

            return(RangeToPointsHelper(region, p1, p2));
        }
        /// <summary>
        /// Scrolls the line into viewable area.
        /// </summary>
        /// <param name="lineIndex">Index of the line.</param>
        /// <param name="lineSize">Size of the line.</param>
        public override void ScrollInView(int lineIndex, double lineSize)
        {
            VisibleLinesCollection lines = GetVisibleLines();
            VisibleLineInfo        line  = lines.GetVisibleLineAtLineIndex(lineIndex);
            double delta = 0;

            if (line != null)
            {
                if (!line.IsClipped || line.IsFooter || line.IsHeader)
                {
                    return;
                }

                if (line.IsClippedOrigin && !line.IsClippedCorner)
                {
                    delta = -(lineSize - line.ClippedSize);
                }
                else if (!line.IsClippedOrigin && line.IsClippedCorner)
                {
                    //Following code prevent the horizontal auto scrolling when column size is bigger than viewPort size.
                    if (line.ClippedOrigin < line.ClippedSize)
                    {
                        delta = 0;
                    }
                    else
                    {
                        delta = lineSize - line.ClippedSize;
                    }
                }
                else
                {
                    delta = lineSize - line.ClippedSize;
                }
            }
            else
            {
                double d = Distances.GetCumulatedDistanceAt(lineIndex);

                if (d > ScrollBar.Value)
                {
                    d = d + lineSize - ScrollBar.LargeChange;
                }

                delta = d - ScrollBar.Value;
            }

            if (delta != 0)
            {
                ScrollBar.Value += delta;
            }
        }
        /// <summary>
        /// Scrolls the line into viewable area.
        /// </summary>
        /// <param name="lineIndex">Index of the line.</param>
        /// <param name="lineSize"></param>
        public override void ScrollInView(int lineIndex, double lineSize)
        {
            VisibleLinesCollection lines = GetVisibleLines();
            VisibleLineInfo        line  = lines.GetVisibleLineAtLineIndex(lineIndex);
            double delta = 0;

            if (line != null)
            {
                if (!line.IsClipped || line.IsFooter || line.IsHeader)
                {
                    return;
                }

                if (line.IsClippedOrigin && !line.IsClippedCorner)
                {
                    delta = -1;
                }

                else if (!line.IsClippedOrigin && line.IsClippedCorner)
                {
                    double y                  = line.Size - line.ClippedSize;
                    int    scrollIndex        = this.ScrollLineIndex;
                    double visibleScrollIndex = ScrollBar.Value;
                    while (y > 0 && visibleScrollIndex < ScrollBar.Maximum)
                    {
                        delta++;
                        visibleScrollIndex++;
                        y -= GetLineSize(ScrollBarValueToLineIndex(visibleScrollIndex));
                    }
                }
            }
            else
            {
                double visibleScrollIndex = LineIndexToScrollBarValue(lineIndex);

                if (visibleScrollIndex > ScrollBar.Value)
                {
                    int scrollIndexLinex = this.IntPreviousPageLineIndex(ScrollPageSize - GetLineSize(lineIndex), lineIndex);
                    visibleScrollIndex = LineIndexToScrollBarValue(scrollIndexLinex);
                }
                delta = visibleScrollIndex - ScrollBar.Value;
            }

            if (delta != 0)
            {
                ScrollBar.Value += delta;
            }

            base.ScrollInView(lineIndex, lineSize);
        }