コード例 #1
0
        /// <summary>
        /// Scroll the horizontal list position if needed to ensure that the
        /// ItemEntry \a item is, if possible, fully visible witin the
        /// ScrolledItemListBase viewable area.
        /// </summary>
        /// <param name="item">
        /// const reference to an ItemEntry attached to this ScrolledItemListBase
        /// that should be made visible in the view area.
        /// </param>
        public void EnsureItemIsVisibleHorz(ItemEntry item)
        {
            var renderArea = GetItemRenderArea();
            var h          = GetHorzScrollbar();
            var currPos    = h.GetScrollPosition();

            var left  = CoordConverter.AsAbsolute(item.GetXPosition(), GetPixelSize().Width) - currPos;
            var right = left + item.GetItemPixelSize().Width;

            // if left is left of the view area, or if item too big, scroll item to left
            if ((left < renderArea.d_min.X) || ((right - left) > renderArea.Width))
            {
                h.SetScrollPosition(currPos + left);
            }
            // if right is right of the view area, scroll item to right of list
            else if (right >= renderArea.d_max.X)
            {
                h.SetScrollPosition(currPos + right - renderArea.Width);
            }
        }
コード例 #2
0
        /// <summary>
        /// Scroll the vertical list position if needed to ensure that the ItemEntry
        /// \a item is, if possible,  fully visible witin the ScrolledItemListBase
        /// viewable area.
        /// </summary>
        /// <param name="item">
        /// const reference to an ItemEntry attached to this ScrolledItemListBase
        /// that should be made visible in the view area.
        /// </param>
        public void EnsureItemIsVisibleVert(ItemEntry item)
        {
            var renderArea = GetItemRenderArea();
            var v          = GetVertScrollbar();
            var currPos    = v.GetScrollPosition();

            var top    = CoordConverter.AsAbsolute(item.GetYPosition(), GetPixelSize().Height) - currPos;
            var bottom = top + item.GetItemPixelSize().Height;

            // if top is above the view area, or if item is too big, scroll item to top
            if ((top < renderArea.d_min.Y) || ((bottom - top) > renderArea.Height))
            {
                v.SetScrollPosition(currPos + top);
            }
            // if bottom is below the view area, scroll item to bottom of list
            else if (bottom >= renderArea.d_max.Y)
            {
                v.SetScrollPosition(currPos + bottom - renderArea.Height);
            }
        }