Manina.Windows.Forms.ImageListViewLayoutManager.GetItemBounds C# (CSharp) Method

GetItemBounds() public method

Returns the bounds of the item with the specified index.
public GetItemBounds ( int itemIndex ) : Rectangle
itemIndex int
return System.Drawing.Rectangle
        public Rectangle GetItemBounds(int itemIndex)
        {
            Point location = new Point();

            if (mImageListView.showGroups)
            {
                foreach (ImageListView.ImageListViewGroup group in mImageListView.groups)
                {
                    if (itemIndex >= group.FirstItemIndex && itemIndex <= group.LastItemIndex)
                    {
                        location = group.itemBounds.Location;
                        location.X += cachedItemMargin.Width / 2;
                        location.Y += cachedItemMargin.Height / 2;

                        if (mImageListView.View == View.Gallery)
                            location.X += (itemIndex - group.FirstItemIndex) * mItemSizeWithMargin.Width;
                        else
                        {
                            location.X += ((itemIndex - group.FirstItemIndex) % mDisplayedCols) * mItemSizeWithMargin.Width;
                            location.Y += ((itemIndex - group.FirstItemIndex) / mDisplayedCols) * mItemSizeWithMargin.Height;
                        }
                        break;
                    }
                }
            }
            else
            {
                location = mItemAreaBounds.Location;
                location.X += cachedItemMargin.Width / 2 - mImageListView.ViewOffset.X;
                location.Y += cachedItemMargin.Height / 2 - mImageListView.ViewOffset.Y;

                if (mImageListView.View == View.Gallery)
                    location.X += itemIndex * mItemSizeWithMargin.Width;
                else
                {
                    location.X += (itemIndex % mDisplayedCols) * mItemSizeWithMargin.Width;
                    location.Y += (itemIndex / mDisplayedCols) * mItemSizeWithMargin.Height;
                }
            }

            return new Rectangle(location, mItemSize);
        }