Exemplo n.º 1
0
 internal double GetItemHeight()
 {
     if (UseHorizontalLayout)
     {
         return(ItemAspectRatio.GetHeight(GetItemWidth()));
     }
     else
     {
         return(viewport.Height / (Rows + marginOffset));
     }
 }
Exemplo n.º 2
0
        internal void UpdateScrollInfo(Size availableSize)
        {
            if (availableSize != viewport)
            {
                viewport = availableSize;
                ScrollOwner?.InvalidateScrollInfo();
            }

            if (UseHorizontalLayout)
            {
                itemHeight = GetItemHeight();
                if (itemHeight > viewport.Height)
                {
                    itemHeight = viewport.Height;
                    itemWidth  = ItemAspectRatio.GetWidth(itemHeight);
                }
                else
                {
                    itemWidth = GetItemWidth();
                }

                computedRows = (int)Math.Floor(viewport.Height / itemHeight);
            }
            else
            {
                itemWidth = GetItemWidth();
                if (itemWidth > viewport.Width)
                {
                    itemWidth  = viewport.Width;
                    itemHeight = ItemAspectRatio.GetHeight(itemWidth);
                }
                else
                {
                    itemHeight = GetItemHeight();
                }

                computedColumns = (int)Math.Floor(viewport.Width / itemWidth);
            }

            centerMargin = GetCenterMargin();

            var newExtent = GetExtent();

            if (extent != newExtent)
            {
                extent = newExtent;
                ScrollOwner?.InvalidateScrollInfo();
            }

            if (offset.Y > extent.Height)
            {
                offset.Y = 0;
                trans.Y  = 0;
                ScrollOwner?.InvalidateScrollInfo();
            }

            if (offset.X > extent.Width)
            {
                offset.X = 0;
                trans.X  = 0;
                ScrollOwner?.InvalidateScrollInfo();
            }
        }