コード例 #1
0
    /// <summary>
    /// Paints the control (using the Buffered Paint API).
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    void _bufferedPainter_PaintVisualState(object sender, BufferedPaintEventArgs <ComboBoxState> e)
    {
        VisualStyleRenderer r = new VisualStyleRenderer(VisualStyleElement.Button.PushButton.Normal);

        r.DrawParentBackground(e.Graphics, ClientRectangle, this);

        DrawComboBox(e.Graphics, ClientRectangle, e.State);

        Rectangle itemBounds = new Rectangle(0, 0, Width - 21, Height);

        itemBounds.Inflate(-1, -3);
        itemBounds.Offset(2, 0);

        // draw the item in the editable portion
        DrawItemState state = DrawItemState.ComboBoxEdit;

        if (Focused && ShowFocusCues && !DroppedDown)
        {
            state |= DrawItemState.Focus;
        }
        if (!Enabled)
        {
            state |= DrawItemState.Disabled;
        }
        OnDrawItem(new DrawItemEventArgs(e.Graphics, Font, itemBounds, SelectedIndex, state));
    }
コード例 #2
0
    /// <summary>
    /// Paints the control using the Buffered Paint API.
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    void bufferedPainter_PaintVisualState(object sender, BufferedPaintEventArgs <ComboBoxState> e)
    {
        if (_drawWithVisualStyles && _bufferedPainter.BufferedPaintSupported && _bufferedPainter.Enabled)
        {
            // draw in the vista/win7 style
            VisualStyleRenderer r = new VisualStyleRenderer(VisualStyleElement.Button.PushButton.Normal);
            r.DrawParentBackground(e.Graphics, ClientRectangle, this);

            Rectangle buttonBounds = ClientRectangle;
            buttonBounds.Inflate(1, 1);
            ButtonRenderer.DrawButton(e.Graphics, buttonBounds, GetPushButtonState(e.State));

            Rectangle clipBounds = _dropDownButtonBounds;
            clipBounds.Inflate(-2, -2);
            e.Graphics.SetClip(clipBounds);
            ComboBoxRenderer.DrawDropDownButton(e.Graphics, _dropDownButtonBounds, e.State);
            e.Graphics.SetClip(ClientRectangle);
        }
        else if (_drawWithVisualStyles && ComboBoxRenderer.IsSupported)
        {
            // draw using the visual style renderer
            ComboBoxRenderer.DrawTextBox(e.Graphics, ClientRectangle, GetTextBoxState());
            ComboBoxRenderer.DrawDropDownButton(e.Graphics, _dropDownButtonBounds, e.State);
        }
        else
        {
            // draw using the legacy technique
            DrawLegacyComboBox(e.Graphics, ClientRectangle, _dropDownButtonBounds, BackColor, GetPlainButtonState());
        }

        OnPaintContent(new DropDownPaintEventArgs(e.Graphics, ClientRectangle, GetTextBoxBounds()));
    }
コード例 #3
0
    /// <summary>
    /// Paints the control using the Buffered Paint API.
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    void bufferedPainter_PaintVisualState(object sender, BufferedPaintEventArgs <ComboBoxState> e)
    {
        if (_drawWithVisualStyles && _bufferedPainter.BufferedPaintSupported && _bufferedPainter.Enabled && (_style == DropDownControlStyles.Discrete))
        {
            // draw in the vista/win7 style
            VisualStyleRenderer r = new VisualStyleRenderer(VisualStyleElement.Button.PushButton.Normal);
            r.DrawParentBackground(e.Graphics, ClientRectangle, this);

            Rectangle buttonBounds = ClientRectangle;
            buttonBounds.Inflate(1, 1);
            ButtonRenderer.DrawButton(e.Graphics, buttonBounds, GetPushButtonState(e.State));

            Rectangle clipBounds = _dropDownButtonBounds;
            clipBounds.Inflate(-2, -2);
            e.Graphics.SetClip(clipBounds);
            ComboBoxRenderer.DrawDropDownButton(e.Graphics, _dropDownButtonBounds, e.State);
            e.Graphics.SetClip(ClientRectangle);
        }
        else if (_drawWithVisualStyles && ComboBoxRenderer.IsSupported)
        {
            // draw using the visual style renderer
            if (Enabled)
            {
                ComboBoxRenderer.DrawTextBox(e.Graphics, ClientRectangle, GetTextBoxState());
            }
            else
            {
                Rectangle outline = ClientRectangle;
                outline.Width--;
                outline.Height--;
                e.Graphics.FillRectangle(SystemBrushes.Control, ClientRectangle);
                e.Graphics.DrawRectangle(Pens.LightGray, outline);
            }

            DrawDropDownGlyph(e.Graphics, _dropDownButtonBounds, e.State);
        }
        else
        {
            // draw using the legacy technique
            DrawLegacyComboBox(e.Graphics, ClientRectangle, _dropDownButtonBounds, BackColor, GetPlainButtonState());
        }

        OnPaintContent(new DropDownPaintEventArgs(e.Graphics, ClientRectangle, GetTextBoxBounds()));
    }
コード例 #4
0
        /// <summary>
        /// Paints the control (using the Buffered Paint API).
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        void _bufferedPainter_PaintVisualState(object sender, BufferedPaintEventArgs <ComboBoxState> e)
        {
            var r = new VisualStyleRenderer(VisualStyleElement.Button.PushButton.Normal);

            r.DrawParentBackground(e.Graphics, ClientRectangle, this);

            var buttonBounds = new Rectangle(Width - 17, 0, 17, Height - (e.State != ComboBoxState.Pressed ? 1 : 0));

            var bounds = ClientRectangle;

            bounds.Inflate(1, 1);

            ButtonRenderer.DrawButton(e.Graphics, bounds, GetPushButtonState(e.State));

            Rectangle buttonClip = buttonBounds;

            buttonClip.Inflate(-2, -2);

            e.Graphics.SetClip(buttonClip);
            ComboBoxRenderer.DrawDropDownButton(e.Graphics, buttonBounds, e.State);
            e.Graphics.SetClip(ClientRectangle);

            var itemBounds = new Rectangle(0, 0, Width - 21, Height);

            itemBounds.Inflate(-1, -3);
            itemBounds.Offset(2, 0);

            // draw the item in the editable portion
            var state = DrawItemState.ComboBoxEdit;

            if (Focused && ShowFocusCues && !DroppedDown)
            {
                state |= DrawItemState.Focus;
            }
            if (!Enabled)
            {
                state |= DrawItemState.Disabled;
            }
            OnDrawItem(new DrawItemEventArgs(e.Graphics, Font, itemBounds, SelectedIndex, state));
        }
コード例 #5
0
    /// <summary>
    /// Paints the control using the Buffered Paint API.
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    void bufferedPainter_PaintVisualState(object sender, BufferedPaintEventArgs<ComboBoxState> e)
    {
        if (_drawWithVisualStyles && _bufferedPainter.BufferedPaintSupported && _bufferedPainter.Enabled) {
            // draw in the vista/win7 style
            VisualStyleRenderer r = new VisualStyleRenderer(VisualStyleElement.Button.PushButton.Normal);
            r.DrawParentBackground(e.Graphics, ClientRectangle, this);

            Rectangle buttonBounds = ClientRectangle;
            buttonBounds.Inflate(1, 1);
            ButtonRenderer.DrawButton(e.Graphics, buttonBounds, GetPushButtonState(e.State));

            Rectangle clipBounds = _dropDownButtonBounds;
            clipBounds.Inflate(-2, -2);
            e.Graphics.SetClip(clipBounds);
            ComboBoxRenderer.DrawDropDownButton(e.Graphics, _dropDownButtonBounds, e.State);
            e.Graphics.SetClip(ClientRectangle);
        }
        else if (_drawWithVisualStyles && ComboBoxRenderer.IsSupported) {
            // draw using the visual style renderer
            ComboBoxRenderer.DrawTextBox(e.Graphics, ClientRectangle, GetTextBoxState());
            ComboBoxRenderer.DrawDropDownButton(e.Graphics, _dropDownButtonBounds, e.State);
        }
        else {
            // draw using the legacy technique
            DrawLegacyComboBox(e.Graphics, ClientRectangle, _dropDownButtonBounds, BackColor, GetPlainButtonState());
        }

        OnPaintContent(new DropDownPaintEventArgs(e.Graphics, ClientRectangle, GetTextBoxBounds()));
    }
コード例 #6
0
 /// <summary>
 ///     Raises the PaintVisualState event.
 /// </summary>
 /// <param name="e">BufferedPaintEventArgs instance.</param>
 protected virtual void OnPaintVisualState(BufferedPaintEventArgs <TState> e)
 {
     PaintVisualState?.Invoke(this, e);
 }
コード例 #7
0
    /// <summary>
    /// Paints the control (using the Buffered Paint API).
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    void _bufferedPainter_PaintVisualState(object sender, BufferedPaintEventArgs<ComboBoxState> e) {
		VisualStyleRenderer r = new VisualStyleRenderer(VisualStyleElement.Button.PushButton.Normal);
		r.DrawParentBackground(e.Graphics, ClientRectangle, this);
		
		DrawComboBox(e.Graphics, ClientRectangle, e.State);

		Rectangle itemBounds = new Rectangle(0, 0, Width - 21, Height);
		itemBounds.Inflate(-1, -3);
		itemBounds.Offset(2, 0);

        // draw the item in the editable portion
        DrawItemState state = DrawItemState.ComboBoxEdit;
        if (Focused && ShowFocusCues && !DroppedDown) state |= DrawItemState.Focus;
        if (!Enabled) state |= DrawItemState.Disabled;
        OnDrawItem(new DrawItemEventArgs(e.Graphics, Font, itemBounds, SelectedIndex, state));
    }