Example #1
0
        void OnDrawItem(object sender, DrawItemEventArgs e)
        {
            // If the index is invalid then simply exit.
            if (e.Index == -1 || e.Index >= Items.Count)
            {
                return;
            }

            // Draw the background of the item.
            e.DrawBackground();

            // Should we draw the focus rectangle?
            if ((e.State & DrawItemState.Focus) != 0)
            {
                e.DrawFocusRectangle();
            }

            Color textColor             = ((e.State & DrawItemState.Selected) != 0 ? SystemColors.HighlightText : ForeColor);
            int   currentImageListIndex = _propValue.ImageIndex;

            _propValue.ImageIndex = e.Index;
            _propValue.DrawValue(e.Graphics, e.Bounds, textColor, _ownerPropertyEnumerator,
                                 Items[e.Index] as string);
            _propValue.ImageIndex = currentImageListIndex;
        }
Example #2
0
        protected override void OnPaint(PaintEventArgs e)
        {
            // Draw the background

            _ownerPropertyEnum.Property.ParentGrid.DrawManager.DrawPropertyValueBackground(e.Graphics,
                                                                                           ClientRectangle, _ownerPropertyEnum);

            Rectangle     buttonRect = GetButtonRect(e.Graphics);
            PropertyValue propValue  = _ownerPropertyEnum.Property.Value;
            Rectangle     valueRect  = ClientRectangle;

            Color valueColor;

            if (_ownerPropertyEnum.Property.Enabled == false)
            {
                valueColor = SystemColors.GrayText;
            }
            else
            {
                if (Focused)
                {
                    valueColor = SystemColors.HighlightText;
                }
                else
                {
                    valueColor = propValue.ForeColor;
                }
            }

            // Draw the value
            if (_edit == null)
            {
                if (Focused)// && (propValue.Look == null))
                {
                    Rectangle fillRect = propValue.GetStringValueRect(e.Graphics, valueRect, Point.Empty);
                    int       margin   = _ownerPropertyEnum.Property.ParentGrid.GlobalTextMargin;
                    fillRect.X    -= (ShowIcon ? margin / 2 : margin);
                    fillRect.Width = buttonRect.Left - 1 - fillRect.Left;
                    fillRect.Y++;
                    fillRect.Height -= 2;
                    e.Graphics.FillRectangle(SystemBrushes.FromSystemColor(SystemColors.Highlight), fillRect);
                    ControlPaint.DrawFocusRectangle(e.Graphics, fillRect);
                }
            }

            valueRect.Width -= buttonRect.Width + 1;
            propValue.DrawValue(e.Graphics, valueRect, valueColor, _ownerPropertyEnum, Text);

            // Draw the combobox arrow
            if (!ReadOnly)
            {
                if (ThemeRenderer.Enabled)
                {
                    int state = (_pushed ?
                                 (_mouseOver ? ThemeComboBox.DropDownButtonPressed : ThemeComboBox.DropDownButtonHot) :
                                 (_mouseOver ? ThemeComboBox.DropDownButtonHot : ThemeComboBox.DropDownButtonNormal));

                    ThemeComboBox.DropDownButton.Draw(e.Graphics, state, buttonRect);
                }
                else
                {
                    ControlPaint.DrawComboButton(e.Graphics, buttonRect, (_pushed && _mouseOver) ?
                                                 ButtonState.Pushed : ButtonState.Normal);
                }

                if (Focused)
                {
                    Rectangle focusRect = buttonRect;
                    focusRect.Inflate(-3, -3);
                    ControlPaint.DrawFocusRectangle(e.Graphics, focusRect);
                }
            }

            base.OnPaint(e);
        }