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

GetWidgetBounds() private method

Returns the bounds of a widget. Used to calculate the bounds of checkboxes and icons.
private GetWidgetBounds ( Rectangle bounds, Size size, Size padding, ContentAlignment alignment ) : Rectangle
bounds System.Drawing.Rectangle
size System.Drawing.Size
padding System.Drawing.Size
alignment ContentAlignment
return System.Drawing.Rectangle
        private Rectangle GetWidgetBounds(Rectangle bounds, Size size, Size padding, ContentAlignment alignment)
        {
            // Apply padding
            if (mImageListView.View == View.Details)
                bounds.Inflate(-2, -2);
            else
                bounds.Inflate(-padding.Width, -padding.Height);

            int x = 0;
            if (mImageListView.View == View.Details)
                x = bounds.Left;
            else if (alignment == ContentAlignment.BottomLeft || alignment == ContentAlignment.MiddleLeft || alignment == ContentAlignment.TopLeft)
                x = bounds.Left;
            else if (alignment == ContentAlignment.BottomCenter || alignment == ContentAlignment.MiddleCenter || alignment == ContentAlignment.TopCenter)
                x = bounds.Left + bounds.Width / 2 - size.Width / 2;
            else // if (alignment == ContentAlignment.BottomRight || alignment == ContentAlignment.MiddleRight || alignment == ContentAlignment.TopRight)
                x = bounds.Right - size.Width;

            int y = 0;
            if (mImageListView.View == View.Details)
                y = bounds.Top + bounds.Height / 2 - size.Height / 2;
            else if (alignment == ContentAlignment.BottomLeft || alignment == ContentAlignment.BottomCenter || alignment == ContentAlignment.BottomRight)
                y = bounds.Bottom - size.Height;
            else if (alignment == ContentAlignment.MiddleLeft || alignment == ContentAlignment.MiddleCenter || alignment == ContentAlignment.MiddleRight)
                y = bounds.Top + bounds.Height / 2 - size.Height / 2;
            else // if (alignment == ContentAlignment.TopLeft || alignment == ContentAlignment.TopCenter || alignment == ContentAlignment.TopRight)
                y = bounds.Top;

            return new Rectangle(x, y, size.Width, size.Height);
        }