Ejemplo n.º 1
0
        /// <summary>
        /// Set a seed for this list. Subsequent <see cref="SmartRect{T}"/> created with <see cref="GetWorkingSmartRect(Func{T, bool}, float, float)"/>
        /// will use <paramref name="seed"/> as a template.
        /// </summary>
        /// <param name="seed"> Template for subsequent <see cref="SmartRect{T}"/>. </param>
        public void Init(SmartRect <T> seed)
        {
            ValidateArg.NotNull(seed, nameof(seed));

            _seed      = seed;
            _seed.List = this;
            this.SmartRects.Add(seed);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Return a new <see cref="SmartRect{T}"/> that shares the same template with the <see cref="SmartRect{T}"/> that seeds this list.
        /// </summary>
        /// <param name="selector"> Defines on which level this smart rect is on. </param>
        /// <param name="xLeftCurPosition"> The left most coordinate of allocated rects. </param>
        /// <param name="xRightCurPosition"> The right most coordinate of allocated rects. </param>
        /// <returns> A <see cref="SmartRect{T}"/>. </returns>
        public SmartRect <T> GetWorkingSmartRect(Func <T, bool> selector, float xLeftCurPosition, float xRightCurPosition)
        {
            SmartRect <T> tail    = this.SmartRects.Last();
            Rect          newRect = new Rect(tail.RectTemplate);

            newRect.y += tail.HeightGap + tail.Height;
            SmartRect <T> smartRect = new SmartRect <T>(
                newRect, selector, xLeftCurPosition, xRightCurPosition, this, _seed.XLeftEdge, _seed.XRightEdge);

            this.SmartRects.Add(smartRect);
            return(smartRect);
        }