public static void OnInserted(IDistanceCounterCollection distances, ILineSizeHost linesHost, int insertAt, int count)
        {
            distances.Insert(insertAt, count);
            int to = insertAt + count - 1;
            int repeatSizeCount;

            // Set line sizes
            for (int index = insertAt; index <= to; index++)
            {
                double size = linesHost.GetSize(index, out repeatSizeCount);
                if (size != distances.DefaultDistance)
                {
                    int rangeTo = GetRangeToHelper(index, to, repeatSizeCount);
                    distances.SetRange(index, rangeTo, size);
                    index = rangeTo;
                }
            }

            // Also check for hidden rows and reset line sizes for them.
            for (int index = insertAt; index <= to; index++)
            {
                bool hide = linesHost.GetHidden(index, out repeatSizeCount);
                if (hide)
                {
                    int rangeTo = GetRangeToHelper(index, to, repeatSizeCount);
                    distances.SetRange(index, rangeTo, 0.0);
                    index = rangeTo;
                }
            }
        }
示例#2
0
        /// <summary>
        /// Initializes a new instance of the <see cref="LineScrollAxis"/> class.
        /// </summary>
        /// <param name="sb">The state of the scrollbar.</param>
        /// <param name="scrollLinesHost">The scroll lines host.</param>
        public LineScrollAxis(IScrollBar sb, ILineSizeHost scrollLinesHost)
            : base(sb, scrollLinesHost)
        {
            var distancesHost = scrollLinesHost as IDistancesHost;

            distances = distancesHost != null ? distancesHost.Distances : new DistanceRangeCounterCollection();
            if (scrollLinesHost != null)
            {
                scrollLinesHost.InitializeScrollAxis(this);
            }
            distances.DefaultDistance = 1.0;
        }
 /// <summary>
 /// Initializes a new instance of the <see cref="PixelScrollAxis"/> class which
 /// is nested as a single line in a parent scroll axis.
 /// </summary>
 /// <param name="parentScrollAxis">The parent scroll axis.</param>
 /// <param name="sb">The scrollbar state.</param>
 /// <param name="scrollLinesHost">The scroll lines host.</param>
 /// <param name="distancesHost">The distances host.</param>
 public PixelScrollAxis(ScrollAxisBase parentScrollAxis, IScrollBar sb, ILineSizeHost scrollLinesHost, IDistancesHost distancesHost)
     : base(sb, scrollLinesHost)
 {
     // GridCellGridRenderer passes in Distances. LineSizeCollection holds them.
     // This allows faster construction of grids when they were scrolled out of view
     // and unloaded.
     this.parentScrollAxis = parentScrollAxis;
     this.distancesHost    = distancesHost;
     if (Distances == null)
     {
         throw new ArgumentNullException("Distances");
     }
 }
        public static double GetTotal(ILineSizeHost lines, int from, int to)
        {
            int    repeatCount;
            int    index = from;
            double total = 0;

            while (index <= to)
            {
                double w = lines.GetSize(index, out repeatCount);
                repeatCount = Math.Min(to - index + 1, repeatCount);
                total      += w * repeatCount;
                index      += repeatCount;
            }

            return(total);
        }
 /// <summary>
 /// Initializes a new instance of the <see cref="PixelScrollAxis"/> class.
 /// </summary>
 /// <param name="sb">The scrollbar state.</param>
 /// <param name="scrollLinesHost">The scroll lines host.</param>
 /// <param name="distancesHost">The distances host.</param>
 public PixelScrollAxis(IScrollBar sb, ILineSizeHost scrollLinesHost, IDistancesHost distancesHost)
     : base(sb, scrollLinesHost)
 {
     if (distancesHost != null)
     {
         this.distancesHost = distancesHost;
     }
     else if (scrollLinesHost != null)
     {
         this.distances = new DistanceRangeCounterCollection
         {
             DefaultDistance = scrollLinesHost.GetDefaultLineSize()
         };
         scrollLinesHost.InitializeScrollAxis(this);
     }
     if (Distances == null)
     {
         throw new ArgumentNullException("Distances");
     }
 }
        public static double[] GetRange(ILineSizeHost lines, int from, int to)
        {
            int count  = to - from + 1;
            var values = new double[count];

            int repeatCount;
            int index = from;
            int n     = 0;

            while (index <= to)
            {
                double w = lines.GetSize(index, out repeatCount);
                repeatCount = Math.Min(to - index + 1, repeatCount);
                for (int i = 0; i < repeatCount; i++)
                {
                    values[n++] = w;
                }
                index += repeatCount;
            }

            return(values);
        }
        public static void DistancesLineSizeChanged(IDistanceCounterCollection distances, ILineSizeHost linesHost, int from, int to)
        {
            var ndh = linesHost as INestedDistancesHost;

            for (int n = from; n <= to; n++)
            {
                if (ndh == null || ndh.GetDistances(n) == null)
                {
                    int    repeatSizeCount;
                    double size    = linesHost.GetSize(n, out repeatSizeCount);
                    int    rangeTo = GetRangeToHelper(n, to, repeatSizeCount);
                    distances.SetRange(n, rangeTo, size);
                    n = rangeTo;
                }
                else
                {
                    distances.SetNestedDistances(n, ndh.GetDistances(n));
                }
            }
        }
        public static void DistancesLineHiddenChanged(IDistanceCounterCollection distances, ILineSizeHost linesHost, int from, int to)
        {
            var ndh = linesHost as INestedDistancesHost;

            for (int n = from; n <= to; n++)
            {
                int  repeatSizeCount;
                bool hide = linesHost.GetHidden(n, out repeatSizeCount);

                if (ndh == null || ndh.GetDistances(n) == null)
                {
                    int rangeTo = GetRangeToHelper(n, to, repeatSizeCount);
                    if (hide)
                    {
                        distances.SetRange(n, rangeTo, 0.0);
                    }
                    else
                    {
                        DistancesLineSizeChanged(distances, linesHost, n, rangeTo);
                    }
                    n = rangeTo;
                }
                else
                {
                    distances.SetNestedDistances(n, hide ? null : ndh.GetDistances(n));
                }
            }
        }