コード例 #1
0
        protected override void DrawItem(ListItemPaintArgs args)
        {
            Graphics g = args.Graphics;
            Rectangle rcItem = args.ItemRectangle;
            RoundRectPath path = new RoundRectPath(rcItem, mRounding, mRounding);

            ListItem item = args.Item as ListItem;
            if (item.Selected) {
                using (LinearGradientBrush b = new LinearGradientBrush(new Rectangle(rcItem.X, rcItem.Y - (rcItem.Height / 2), rcItem.Width, rcItem.Height + (rcItem.Height / 2)), Color.White, SelectedBackColor, LinearGradientMode.Vertical)) {
                    b.WrapMode = WrapMode.TileFlipX;
                    g.FillPath(b, path);
                }
                using (Pen p = new Pen(mBorderColor, 2)) {
                    g.DrawPath(p, path);
                }
                using (Brush b = new SolidBrush(SelectedForeColor)) {
                    g.DrawString(args.Item.Text, Font, b, args.TextRectangle, mFormat);
                }
            } else {
                using (LinearGradientBrush b = new LinearGradientBrush(new Rectangle(rcItem.X, rcItem.Y - (rcItem.Height / 2), rcItem.Width, rcItem.Height + (rcItem.Height / 2)), Color.White, ItemBackColor, LinearGradientMode.Vertical)) {
                    b.WrapMode = WrapMode.TileFlipX;
                    g.FillPath(b, path);
                }
                using (Pen p = new Pen(mBorderColor, 1)) {
                    g.DrawPath(p, path);
                }
                using (Brush b = new SolidBrush(ItemForeColor)) {
                    g.DrawString(args.Item.Text, Font, b, args.TextRectangle, mFormat);
                }
            }
            if (item.Icon != null) {
                g.DrawIcon(item.Icon, args.IconRectangle);
            }
            path.Dispose();
        }
コード例 #2
0
 protected virtual void DrawItem(ListItemPaintArgs args)
 {
     Graphics g = args.Graphics;
     Rectangle rcItem = args.ItemRectangle;
     RoundRectPath path = new RoundRectPath(rcItem, mRounding, mRounding);
     using (LinearGradientBrush b = new LinearGradientBrush(new Rectangle(rcItem.X, rcItem.Y - (rcItem.Height / 2), rcItem.Width, rcItem.Height + (rcItem.Height / 2)), Color.White, Color.LightGray, LinearGradientMode.Vertical)) {
         b.WrapMode = WrapMode.TileFlipX;
         g.FillPath(b, path);
     }
     using (Pen p = new Pen(mBorderColor, 1)) {
         g.DrawPath(p, path);
     }
     using (Brush b = new SolidBrush(Color.Black)) {
         g.DrawString(args.Item.Text, Font, b, args.TextRectangle, mFormat);
     }
     if (args.Item.Icon != null) {
         g.DrawIcon(args.Item.Icon, args.IconRectangle);
     }
     path.Dispose();
 }