/// <summary>
 /// 绘制项的边框
 /// </summary>
 /// <param name="g"></param>
 /// <param name="bounds"></param>
 internal virtual void DrawItemBorder(Graphics g, Rectangle bounds)
 {
     using (Pen pWhite128 = new Pen(Color.FromArgb(128, Theme.ItemBorderColor)))
     {
         ImageListViewUtility.DrawRoundedRectangle(g, pWhite128, bounds.Left, bounds.Top, bounds.Width - 1, bounds.Height - 1, _radius);
     }
 }
        /// <summary>
        /// 绘制项
        /// </summary>
        /// <param name="g"></param>
        /// <param name="item"></param>
        /// <param name="state"></param>
        /// <param name="bounds"></param>
        internal virtual void DrawItem(Graphics g, ImageListViewItem item)
        {
            Rectangle bounds = LayoutManager.GetItemBounds(item);

            g.SetClip(bounds);

            DrawItemBackground(g, bounds);

            // Paint background Selected
            if ((LayoutManager.Focused && ((item.State & ImageListViewItemState.Selected) == ImageListViewItemState.Selected)) ||
                (LayoutManager.Focused == false && ((item.State & ImageListViewItemState.Selected) == ImageListViewItemState.Selected) && ((item.State & ImageListViewItemState.Hovered) == ImageListViewItemState.Hovered)))
            {
                using (Brush bSelected = new LinearGradientBrush(bounds, Theme.SelectedColorStart, Theme.SelectedColorEnd, LinearGradientMode.Vertical))
                {
                    ImageListViewUtility.FillRoundedRectangle(g, bSelected, bounds, 4);
                }
            }
            // Paint background unfocused
            else if (LayoutManager.Focused == false && ((item.State & ImageListViewItemState.Selected) == ImageListViewItemState.Selected))
            {
                using (Brush bGray64 = new LinearGradientBrush(bounds, Theme.UnFocusedColorStart, Theme.UnFocusedColorEnd, LinearGradientMode.Vertical))
                {
                    ImageListViewUtility.FillRoundedRectangle(g, bGray64, bounds, 4);
                }
            }

            // Paint background Hovered
            //如果正处于框选状态,不绘制Hover状态,减小闪烁
            if (LayoutManager.MouseSelecting == false && (item.State & ImageListViewItemState.Hovered) == ImageListViewItemState.Hovered)
            {
                using (Brush bHovered = new LinearGradientBrush(bounds, Theme.HoverColorStart, Theme.HoverColorEnd, LinearGradientMode.Vertical))
                {
                    ImageListViewUtility.FillRoundedRectangle(g, bHovered, bounds, 4);
                }
            }

            DrawItemBorder(g, bounds);

            // Focus rectangle
            if (LayoutManager.Focused && ((item.State & ImageListViewItemState.Focused) == ImageListViewItemState.Focused))
            {
                ControlPaint.DrawFocusRectangle(g, bounds);
            }

            DrawItemContent(g, bounds, item);
        }
        internal override void DrawItemContent(Graphics g, Rectangle bounds, ImageListViewItem item)
        {
            if (_thumbnailSizeInited == false)
            {
                SizeF headerSize = g.MeasureString(item.Header, Theme.ItemHeaderFont);
                _headerHeight = (int)Math.Ceiling(headerSize.Height);

                int width = LayoutManager.ItemSize.Width - _itemPadding.Width * 2;
                //_itemPadding.Height * 3 是因为去掉缩略图顶部,底部,和与文本区域之间的Padding
                int height = LayoutManager.ItemSize.Height - _itemPadding.Height * 3 - _headerHeight;
                _thumbnailSize = new Size(width, height);

                _thumbnailSizeInited = true;
            }

            #region  绘制缩略图

            Image img = null;
            if (_thumbnailsCache.Container(item))
            {
                img = _thumbnailsCache.GetThumbnail(item);
            }
            else
            {
                img = ImageListViewUtility.GetScaleImage(item.Image, _thumbnailSize);
                _thumbnailsCache.AddThumbnail(item, img);
            }

            if (img != null)
            {
                Rectangle pos = ImageListViewUtility.GetSizedImageBounds(img, new Rectangle(bounds.Location + _itemPadding, _thumbnailSize));
                g.DrawImage(img, pos);
                // Draw image border
                if (Math.Min(pos.Width, pos.Height) > 32)
                {
                    using (Pen pOuterBorder = new Pen(Theme.ImageOuterBorderColor))
                    {
                        g.DrawRectangle(pOuterBorder, pos);
                    }
                    if (System.Math.Min(_thumbnailSize.Width, _thumbnailSize.Height) > 32)
                    {
                        using (Pen pInnerBorder = new Pen(Theme.ImageInnerBorderColor))
                        {
                            //Rectangle.Inflate(pos, -1, -1) 用于取内框
                            g.DrawRectangle(pInnerBorder, Rectangle.Inflate(pos, -1, -1));
                        }
                    }
                }
            }

            #endregion

            #region 绘制文本

            _headerBounds        = new Rectangle();
            _headerBounds.X      = _itemPadding.Width;
            _headerBounds.Y      = LayoutManager.ItemSize.Height - _headerHeight - _itemPadding.Height;
            _headerBounds.Width  = _thumbnailSize.Width;
            _headerBounds.Height = _headerHeight;
            _headerBounds.Offset(bounds.Location);

            //g.DrawRectangle(Pens.Gray, _headerBounds);
            using (SolidBrush brush = new SolidBrush(Theme.ItemHeaderColor))
            {
                g.DrawString(item.Header, Theme.ItemHeaderFont, brush, _headerBounds, _itemHeaderStringFormat);
            }

            #endregion
        }