Ejemplo n.º 1
0
        protected override void OnPaint(PaintEventArgs e)
        {
            e.Graphics.TranslateTransform(
                AutoScrollPosition.X,
                AutoScrollPosition.Y
                );

            int y = 0;

            _textHeight = (int)e.Graphics.MeasureString("Aa", Font).Height;
            _itemHeight = _textHeight + (_textPaddingVertical * 2);

            for (int i = 0; i < Items.Count; i++)
            {
                if (Items[i] == _selectedItem)
                {
                    e.Graphics.FillRectangle(_focusColor,
                                             0, y,
                                             Width, _itemHeight);

                    e.Graphics.DrawString(Items[i].ToString(),
                                          Font,
                                          _foreColor.Negate(),
                                          _textPaddingHorizontal + _textPaddingHorizontal,
                                          y + _textPaddingVertical);
                }
                else
                {
                    e.Graphics.DrawString(Items[i].ToString(),
                                          Font,
                                          _foreColor,
                                          _textPaddingHorizontal + _textPaddingHorizontal,
                                          y + _textPaddingVertical);
                }

                y += _itemHeight;
            }
        }