Example #1
0
        protected override void OnDrawItem(DrawItemEventArgs e)
        {
            Graphics  grfx      = e.Graphics;
            Rectangle rectColor = new Rectangle(e.Bounds.Left, e.Bounds.Top, 2 * e.Bounds.Height, e.Bounds.Height);

            rectColor.Inflate(-1, -1);

            Rectangle rectText = new Rectangle(e.Bounds.Left + 2 * e.Bounds.Height,
                                               e.Bounds.Top,
                                               e.Bounds.Width - 2 * e.Bounds.Height,
                                               e.Bounds.Height);

            if (this.Enabled)
            {
                e.DrawBackground();
            }

            DashCap    item           = e.Index >= 0 ? (DashCap)Items[e.Index] : DashCap.Flat;
            SolidBrush foreColorBrush = new SolidBrush(e.ForeColor);

            Pen linePen = new Pen(foreColorBrush, (float)Math.Ceiling(0.5 * e.Bounds.Height));

            linePen.DashStyle = DashStyle.Dot;
            linePen.DashCap   = item;

            grfx.DrawLine(linePen,
                          rectColor.Left, 0.5f * (rectColor.Top + rectColor.Bottom),
                          rectColor.Right, 0.5f * (rectColor.Top + rectColor.Bottom));
            grfx.DrawString(item.ToString(), Font, foreColorBrush, rectText);
        }