protected override void OnPaint(PaintEventArgs e) { base.OnPaint(e); //Check if VisualStyles are supported... //Thanks to codeproject member: Mathiyazhagan for catching this. :) if (ComboBoxRenderer.IsSupported && TextBoxRenderer.IsSupported) { TextFormatFlags flag = TextFormatFlags.TextBoxControl | TextFormatFlags.SingleLine; Rectangle textRect = new Rectangle(new Point(2, 2), _AnchorSize); TextBoxRenderer.DrawTextBox(e.Graphics, new Rectangle(new Point(0, 0), _AnchorSize), this.Text, this.Font, textRect, System.Windows.Forms.VisualStyles.TextBoxState.Normal); //TextBoxRenderer.DrawTextBox(e.Graphics, new Rectangle(new Point(0, 0), _AnchorSize), this.Text, this.Font, textRect, flag, getState()); ComboBoxRenderer.DrawDropDownButton(e.Graphics, new Rectangle(_AnchorSize.Width - 19, 2, 18, _AnchorSize.Height - 4), getState()); } else { ControlPaint.DrawComboButton(e.Graphics, new Rectangle( _AnchorSize.Width - 19, 2, 18, _AnchorSize.Height - 4), (this.Enabled) ? System.Windows.Forms.ButtonState.Normal : System.Windows.Forms.ButtonState.Inactive); } using (Brush b = new SolidBrush(this.BackColor)) { e.Graphics.FillRectangle(b, this.AnchorClientBounds); } Rectangle rect = new Rectangle(0, 0, this.AnchorClientBounds.Width, this.AnchorClientBounds.Height - 2); TextRenderer.DrawText(e.Graphics, this.Text, this.Font, rect, this.ForeColor, TextFormatFlags.WordEllipsis | TextFormatFlags.VerticalCenter); }
public override void Draw(Graphics g) { if (Visible) { Rectangle bounds = ClipRectangle; if (ControlState == ControlState.Normal) { g.FillRectangle(BackBrush, bounds); g.DrawString(Text, Font, ForeBrush, bounds, StringFormat); } else if (ControlState == ControlState.Edit) { g.FillRectangle(ForeBrush, bounds); ControlPaint.DrawBorder3D(g, bounds, Border3DStyle.Sunken); Rectangle rectangle = new Rectangle(bounds.X + bounds.Width - buttonOffset - buttonWidth, bounds.Y + buttonOffset, buttonWidth, bounds.Height - 2 * buttonOffset); ControlPaint.DrawComboButton(g, rectangle, ButtonState.Normal); } else if (ControlState == ControlState.WaitingFeedback) { g.FillRectangle(BackBrush, bounds); g.DrawString(Text, Font, WaitFeedbackBrush, bounds, StringFormat); } } }
protected override void OnPaint(PaintEventArgs e) { string format = ""; switch (this.Format) { case DateTimePickerFormat.Long: format = Thread.CurrentThread.CurrentCulture.DateTimeFormat.LongDatePattern; break; case DateTimePickerFormat.Short: format = Thread.CurrentThread.CurrentCulture.DateTimeFormat.ShortDatePattern; break; case DateTimePickerFormat.Time: format = Thread.CurrentThread.CurrentCulture.DateTimeFormat.LongTimePattern; break; case DateTimePickerFormat.Custom: format = this.CustomFormat; break; } using (Brush b = new SolidBrush(Color.Black)) { e.Graphics.DrawString(this.Value.ToString(format), this.Font, b, 0, 2); } ControlPaint.DrawComboButton(e.Graphics, new Rectangle(this.ClientRectangle.Left + this.ClientRectangle.Width - 20, this.ClientRectangle.Top, 20, this.ClientRectangle.Height), ButtonState.Flat); ControlPaint.DrawBorder(e.Graphics, this.DisplayRectangle, Color.Gray, ButtonBorderStyle.Solid); base.OnPaint(e); }
protected override void OnPaint(PaintEventArgs e) { Graphics g = e.Graphics; if (color.IsEmpty) { g.DrawRectangle(Pens.Black, colorRect); } else { using (Brush b = new SolidBrush(color)) { g.FillRectangle(b, colorRect); } } if (Focused) { Rectangle focusRect = colorRect; focusRect.Inflate(3, 3); ControlPaint.DrawFocusRectangle(g, focusRect); } ControlPaint.DrawComboButton(g, btnRect, pressed ? ButtonState.Pushed : ButtonState.Normal); ControlPaint.DrawBorder3D(g, ClientRectangle, Border3DStyle.Sunken); }
private void Form5_Paint(object sender, PaintEventArgs e) { ControlPaint.DrawCheckBox(e.Graphics, new Rectangle(10, 10, 20, 20), ButtonState.Normal); ControlPaint.DrawComboButton(e.Graphics, new Rectangle(10, 40, 20, 20), ButtonState.Pushed); // ControlPaint.FillReversibleRectangle(new Rectangle(10, 40, 200, 200),Color.Red); ControlPaint.DrawLockedFrame(e.Graphics, new Rectangle(30, 40, 20, 20), true); }
protected override void OnPaint(PaintEventArgs e) { base.OnPaint(e); // Check if VisualStyles are supported... // Thanks to codeproject member: Mathiyazhagan for catching this. :) if (ComboBoxRenderer.IsSupported) { ComboBoxRenderer.DrawTextBox(e.Graphics, new Rectangle(new Point(0, 0), fAnchorSize), GetState()); ComboBoxRenderer.DrawDropDownButton(e.Graphics, new Rectangle(fAnchorSize.Width - 19, 2, 18, fAnchorSize.Height - 4), GetState()); } else { ControlPaint.DrawComboButton(e.Graphics, new Rectangle(fAnchorSize.Width - 19, 2, 18, fAnchorSize.Height - 4), (Enabled) ? ButtonState.Normal : ButtonState.Inactive); } using (Brush b = new SolidBrush(BackColor)) { e.Graphics.FillRectangle(b, AnchorClientBounds); } TextRenderer.DrawText(e.Graphics, fText, Font, AnchorClientBounds, ForeColor, TextFormatFlags.WordEllipsis); }
private void DrawButton(Graphics g, ComboBoxState state) { if ((ComboBoxRenderer.IsSupported) & (Application.RenderWithVisualStyles)) { ComboBoxRenderer.DrawDropDownButton(g, buttonRect, state); } else { ButtonState btnState = ButtonState.Normal; switch (state) { case ComboBoxState.Hot: btnState = ButtonState.Normal; break; case ComboBoxState.Normal: btnState = ButtonState.Normal; break; case ComboBoxState.Disabled: btnState = ButtonState.Inactive; break; case ComboBoxState.Pressed: btnState = ButtonState.Flat; break; } ControlPaint.DrawComboButton(g, buttonRect, btnState); } }
protected override void OnPaint(PaintEventArgs e) { Graphics g = e.Graphics; if (!HasPatternStyle) { g.DrawRectangle(Pens.Black, patternRect); } else { using (HatchBrush hb = new HatchBrush(pickerWindow.PatternStyle, patternColor, Color.White)) { g.FillRectangle(hb, patternRect); } } if (Focused) { Rectangle focusRect = patternRect; focusRect.Inflate(3, 3); ControlPaint.DrawFocusRectangle(g, focusRect); } ControlPaint.DrawComboButton(g, buttonRect, pressed ? ButtonState.Pushed : ButtonState.Normal); ControlPaint.DrawBorder3D(g, ClientRectangle, Border3DStyle.Sunken); }
protected override void OnPaint(PaintEventArgs e) { e.Graphics.DrawString(Text, Font, new SolidBrush(ForeColor), ClientRectangle, new StringFormat { // Alignment = StringAlignment.Center, LineAlignment = StringAlignment.Center }); // Render the dropdown button: shrink button area by one px var rect = new Rectangle(ClientRectangle.Left + ClientRectangle.Width - 19, ClientRectangle.Top + 1, 19, ClientRectangle.Height - 2); if (ComboBoxRenderer.IsSupported) { var bstate = this.Enabled ? ComboBoxState.Normal : ComboBoxState.Disabled; ComboBoxRenderer.DrawDropDownButton(e.Graphics, rect, bstate); } else { var bstate = this.Enabled ? ButtonState.Flat : ButtonState.Inactive; ControlPaint.DrawComboButton(e.Graphics, rect, bstate); } ControlPaint.DrawBorder(e.Graphics, DisplayRectangle, Color.Gray, ButtonBorderStyle.Solid); base.OnPaint(e); }
private void OverrideDropDown(Graphics g) { if (!this.ShowUpDown) { Rectangle rect = new Rectangle(this.Width - DropDownButtonWidth, 0, DropDownButtonWidth, this.Height); ControlPaint.DrawComboButton(g, rect, ButtonState.Flat); } }
protected override void OnPaint(PaintEventArgs e) { Graphics g = e.Graphics; var color = CurrentColor; if (color is SolidColor) { var solidColor = color.CompliantSolidColor; if (solidColor.IsEmpty) { g.DrawRectangle(Pens.Black, colorRect); } else { using (Brush b = new SolidBrush(SolidColor)) { if (solidColor.A < 255) { unvell.Common.GraphicsToolkit.DrawTransparentBlock(g, colorRect); } g.FillRectangle(b, colorRect); } } } else if (color is LinearGradientColor) { var lgc = (LinearGradientColor)color; using (var lgb = lgc.CreateGradientBrush(colorRect)) { g.FillRectangle(lgb, colorRect); } } else if (color is HatchPatternColor) { var hpc = (HatchPatternColor)color; using (var hpb = hpc.CreateHatchBrush()) { g.FillRectangle(hpb, colorRect); } } if (Focused) { Rectangle focusRect = colorRect; focusRect.Inflate(3, 3); ControlPaint.DrawFocusRectangle(g, focusRect); } ControlPaint.DrawComboButton(g, btnRect, pressed ? ButtonState.Pushed : ButtonState.Normal); ControlPaint.DrawBorder3D(g, ClientRectangle, Border3DStyle.Sunken); }
public void OnPaint() { Rectangle rect = this.ClientRectangle; Graphics g = this.CreateGraphics(); //Draw border if (Application.RenderWithVisualStyles) { TextBoxRenderer.DrawTextBox(g, rect, TextBoxState.Normal); } else { ControlPaint.DrawBorder3D(g, rect, Border3DStyle.Sunken, Border3DSide.All); } // Reduce rectangle by borderSize rect.Inflate(-SystemInformation.Border3DSize.Width, -SystemInformation.Border3DSize.Height); Rectangle rectButton = getButtonRect(); if (Application.RenderWithVisualStyles) { if (m_bReadOnly || !Enabled) { //Fill background g.FillRectangle(new SolidBrush(this.BackColor), rect); ComboBoxRenderer.DrawDropDownButton(g, rectButton, ComboBoxState.Disabled); } else { //Fill background g.FillRectangle(new SolidBrush(Color.White), rect); ComboBoxRenderer.DrawDropDownButton(g, rectButton, ComboBoxState.Normal); } } else { if (m_bReadOnly || !Enabled) { //Fill background g.FillRectangle(new SolidBrush(this.BackColor), rect); ControlPaint.DrawComboButton(g, rectButton, ButtonState.Inactive); } else { //Fill background g.FillRectangle(new SolidBrush(Color.White), rect); ControlPaint.DrawComboButton(g, rectButton, ButtonState.Normal); } } g.Dispose(); }
protected override void OnPaint(PaintEventArgs e) { var r = Rectangle.Empty; e.Graphics.SmoothingMode = SmoothingMode.AntiAlias; OnDrawItem(new DrawItemEventArgs(e.Graphics, Font, e.ClipRectangle, SelectedIndex, DrawItemState.ComboBoxEdit)); var buttonRect = new Rectangle(Width - 15, 0, 15, Height); ControlPaint.DrawComboButton(e.Graphics, buttonRect, ButtonState.Normal | ButtonState.Flat); }
protected virtual void DrawArrow(PaintEventArgs pe) { ComboBoxState arrowState = this.Enabled ? this.ArrowState : ComboBoxState.Disabled; if (ComboBoxRenderer.IsSupported && Application.RenderWithVisualStyles) { ComboBoxRenderer.DrawDropDownButton(pe.Graphics, this.ArrowBounds, arrowState); } else { ControlPaint.DrawComboButton(pe.Graphics, this.ArrowBounds, ComboBoxStateToComboButtonState(arrowState)); } }
/// <summary> /// Draws a legacy style combo box control. /// </summary> /// <param name="graphics"></param> /// <param name="bounds"></param> /// <param name="buttonBounds"></param> /// <param name="backColor"></param> /// <param name="state"></param> internal static void DrawLegacyComboBox(Graphics graphics, Rectangle bounds, Rectangle buttonBounds, Color backColor, ButtonState state) { Rectangle borderRect = bounds; borderRect.Height++; graphics.FillRectangle(new SolidBrush(backColor), bounds); ControlPaint.DrawBorder3D(graphics, borderRect, Border3DStyle.Sunken); Rectangle buttonRect = buttonBounds; buttonRect.X -= 2; buttonRect.Y += 2; buttonRect.Height -= 3; ControlPaint.DrawComboButton(graphics, buttonRect, state); }
protected override void OnPaint(PaintEventArgs pevent) { base.OnPaint(pevent); Rectangle rc = new Rectangle(pevent.ClipRectangle.X, pevent.ClipRectangle.Y - 1, pevent.ClipRectangle.Width, pevent.ClipRectangle.Height + 1); if (this.Name == "btnDropDown") { ControlPaint.DrawComboButton(pevent.Graphics, rc, ButtonState.Flat); } else if (this.Name == "btnClear") { ControlPaint.DrawCaptionButton(pevent.Graphics, rc, CaptionButton.Close, ButtonState.Flat); } ControlPaint.DrawBorder(pevent.Graphics, rc, Color.White, ButtonBorderStyle.Solid); }
//<Snippet10> // Render the drop-down arrow with or without visual styles. protected override void OnPaint(PaintEventArgs e) { base.OnPaint(e); if (!ComboBoxRenderer.IsSupported) { ControlPaint.DrawComboButton(e.Graphics, this.ClientRectangle, ButtonState.Normal); } else { ComboBoxRenderer.DrawDropDownButton(e.Graphics, this.ClientRectangle, ComboBoxState.Normal); } }
/// <summary> /// Draw the drop-down button surface. /// </summary> /// <param name="dc">ReoGrid cross-platform drawing context.</param> /// <param name="buttonRect">Rectangle of drop-down button.</param> protected virtual void OnPaintDropdownButton(CellDrawingContext dc, Rectangle buttonRect) { if (this.Cell != null) { if (this.Cell.IsReadOnly) { ControlPaint.DrawComboButton(dc.Graphics.PlatformGraphics, (System.Drawing.Rectangle)(buttonRect), System.Windows.Forms.ButtonState.Inactive); } else { ControlPaint.DrawComboButton(dc.Graphics.PlatformGraphics, (System.Drawing.Rectangle)(buttonRect), this.isDropdown ? System.Windows.Forms.ButtonState.Pushed : System.Windows.Forms.ButtonState.Normal); } } }
/// <summary> /// Draws a combobox button in the specified state, on the specified graphics /// surface, and within the specified bounds /// </summary> /// <param name="g">The Graphics to draw on</param> /// <param name="buttonRect">The Rectangle that represents the dimensions /// of the button</param> /// <param name="clipRect">The Rectangle that represents the clipping area</param> /// <param name="state">A ComboBoxStates value that specifies the /// state to draw the combobox button in</param> public static void DrawComboBoxButton(Graphics g, Rectangle buttonRect, Rectangle clipRect, ComboBoxStates state) { if (g == null || buttonRect.Width <= 0 || buttonRect.Height <= 0 || clipRect.Width <= 0 || clipRect.Height <= 0) { return; } if (ThemeManager.VisualStylesEnabled) { ThemeManager.DrawThemeBackground(g, ThemeClasses.ComboBox, (int)ComboBoxParts.DropDownButton, (int)state, buttonRect, clipRect); } else { ControlPaint.DrawComboButton(g, buttonRect, ThemeManager.ConvertComboBoxStateToButtonState(state)); } }
/// <summary> /// This member overrides <see cref="Control.OnPaint">Control.OnPaint</see>. /// </summary> protected override void OnPaint(PaintEventArgs pe) { if (Application.RenderWithVisualStyles) { ComboBoxRenderer.DrawDropDownButton( pe.Graphics, ClientRectangle, !Enabled ? ComboBoxState.Disabled : (pushed ? ComboBoxState.Pressed : ((hover || Focused) ? ComboBoxState.Hot : ComboBoxState.Normal))); } else { ControlPaint.DrawComboButton( pe.Graphics, ClientRectangle, !Enabled ? ButtonState.Inactive : (pushed ? ButtonState.Pushed : ((hover || Focused) ? ButtonState.Normal : ButtonState.Normal))); } }
protected override void OnPaint(System.Windows.Forms.PaintEventArgs e) { Graphics g = this.CreateGraphics(); //Graphics g = e.Graphics; //The dropDownRectangle defines position and size of dropdownbutton block, //the width is fixed to 17 and height to 16. The dropdownbutton is aligned to right Rectangle dropDownRectangle = new Rectangle(ClientRectangle.Width - 17, 0, 17, 16); Brush bkgBrush; ComboBoxState visualState; //When the control is enabled the brush is set to Backcolor, //otherwise to color stored in _backDisabledColor if (this.Enabled) { bkgBrush = new SolidBrush(this.BackColor); visualState = ComboBoxState.Normal; } else { bkgBrush = new SolidBrush(this._backDisabledColor); visualState = ComboBoxState.Disabled; } // Painting...in action //Filling the background g.FillRectangle(bkgBrush, 0, 0, ClientRectangle.Width, ClientRectangle.Height); //Drawing the datetime text g.DrawString(this.Text, this.Font, Brushes.Black, 0, 2); //Drawing the dropdownbutton using ComboBoxRenderer if (ComboBoxRenderer.IsSupported) { ComboBoxRenderer.DrawDropDownButton(g, dropDownRectangle, visualState); } else { ControlPaint.DrawComboButton(g, dropDownRectangle, (this.Enabled) ? ButtonState.Normal : ButtonState.Inactive); } g.Dispose(); bkgBrush.Dispose(); }
protected override void OnPaint(System.Windows.Forms.PaintEventArgs pevent) { ComboBoxState state = State; base.OnPaint(pevent); const int xsize = 17; //const int ysize = 19; int ysize = this.Height - 2; if (ComboBoxRenderer.IsSupported) { ComboBoxRenderer.DrawDropDownButton(pevent.Graphics, new Rectangle(this.Width - xsize - 1, this.Height - ysize - 1, xsize, ysize), state); } else { ControlPaint.DrawComboButton(pevent.Graphics, new Rectangle(this.Width - xsize - 1, this.Height - ysize - 1, xsize, ysize), (this.Enabled) ? ButtonState.Normal : ButtonState.Inactive); } }
/// <summary> /// Renders the split button background /// </summary> /// <param name="e">The render parameters</param> protected override void OnRenderSplitButtonBackground(ToolStripItemRenderEventArgs e) { // Perform the default actions // NOTE: Is this needed? If not, do we have to clear the button background? base.OnRenderSplitButtonBackground(e); // Plus draw the button border based on the state of the button if (e.Item is ToolStripSplitButton) { ButtonState state = 0; if (!e.Item.Enabled) { state |= ButtonState.Inactive; } if (e.Item is CustomDrawingAttributesDropDownButton && ((CustomDrawingAttributesDropDownButton)e.Item).Checked) { state |= ButtonState.Checked; } if (((ToolStripSplitButton)e.Item).ButtonPressed) { state |= ButtonState.Pushed; } if (state == 0) { state = ButtonState.Normal; } // Draw the button itself ControlPaint.DrawButton(e.Graphics, new Rectangle(0, 0, ((ToolStripSplitButton)e.Item).ButtonBounds.Width, ((ToolStripSplitButton)e.Item).ButtonBounds.Width), state); // Calculate the dimensions of the drop-down button Rectangle rtemp = ((ToolStripSplitButton)e.Item).DropDownButtonBounds; rtemp.Width++; rtemp.Height++; rtemp.X--; rtemp.Y--; // Remove the "checked" state from the state state &= ~ButtonState.Checked; // Draw the drop-down button ControlPaint.DrawComboButton(e.Graphics, rtemp, state); } }
protected override void Paint(Graphics g, Rectangle bounds, CurrencyManager source, int rowNum, Brush backBrush, Brush foreBrush, bool alignToRight) { g.FillRectangle(new SolidBrush(Color.White), bounds); StringFormat format = new StringFormat(); format.Alignment = StringAlignment.Near; format.LineAlignment = StringAlignment.Center; Rectangle controlBounds = this.GetControlBounds(bounds); int num = IntegerType.FromObject(this.GetColumnValueAtRow(source, rowNum)); string text = this.m_comboBox.Items[num].ToString(); RectangleF layoutRectangle = new RectangleF((float)(controlBounds.X + 1), (float)(controlBounds.Y + 4), (float)(controlBounds.Width - 3), (float)((int)Math.Round((double)g.MeasureString(text, this.m_comboBox.Font).Height))); g.DrawString(text, this.m_comboBox.Font, foreBrush, layoutRectangle); ControlPaint.DrawBorder3D(g, controlBounds, Border3DStyle.Sunken); Rectangle rectangle = controlBounds; rectangle.Inflate(-2, -2); ControlPaint.DrawComboButton(g, rectangle.X + (controlBounds.Width - 20), rectangle.Y, 0x10, 0x11, ButtonState.Normal); }
protected override void OnPaint(PaintEventArgs pevent) { var state = State; base.OnPaint(pevent); const int xsize = 17; //const int ysize = 19; var ysize = Height - 2; if (ComboBoxRenderer.IsSupported) { ComboBoxRenderer.DrawDropDownButton(pevent.Graphics, new Rectangle(Width - xsize - 1, Height - ysize - 1, xsize, ysize), state); } else { ControlPaint.DrawComboButton(pevent.Graphics, new Rectangle(Width - xsize - 1, Height - ysize - 1, xsize, ysize), Enabled ? ButtonState.Normal : ButtonState.Inactive); } }
private void DrawComboBox(ComboBox cbo, Point p, Graphics g) { int iBorder = 2; // Draw the TextBox border ControlPaint.DrawBorder(g, new Rectangle(p.X, p.Y, cbo.Width, cbo.Height), SystemColors.Control, iBorder, ButtonBorderStyle.Inset, SystemColors.Control, iBorder, ButtonBorderStyle.Inset, SystemColors.Control, iBorder, ButtonBorderStyle.Inset, SystemColors.Control, iBorder, ButtonBorderStyle.Inset); // Control's BackColor g.FillRectangle(new SolidBrush(cbo.BackColor), p.X + iBorder, p.Y + iBorder, cbo.Width - 4, cbo.Height - 4); // ComboBox's text left justified & centered vertically g.DrawString(cbo.Text, cbo.Font, new SolidBrush(cbo.ForeColor), p.X + iBorder, p.Y + (cbo.Height / 2) - (g.MeasureString(cbo.Text, cbo.Font).Height / 2)); // ComboBox's drop down arrow button thingy ControlPaint.DrawComboButton(g, p.X + cbo.Width - 16 - iBorder, p.Y + (cbo.Height / 2) - (16 / 2), 16, 17, ButtonState.Normal); }
protected override void OnPaint(PaintEventArgs e) { base.OnPaint(e); if (!_showDropDownButton) { return; } var Rectangle = new Rectangle(ClientRectangle.Width - _buttonWidth, 0, _buttonWidth, ClientRectangle.Height); if (ComboBoxRenderer.IsSupported) { ComboBoxRenderer.DrawDropDownButton(e.Graphics, Rectangle, GetState()); } else { ControlPaint.DrawComboButton(e.Graphics, Rectangle, (this.Enabled) ? ButtonState.Normal : ButtonState.Inactive); } }
/// ------------------------------------------------------------------------------------ private void DrawPlainButton(LmButtonColumn.ButtonType type, Graphics g, Rectangle rcbtn) { ButtonState state = (_mouseDownOnButton && _mouseOverButton && _enabled ? ButtonState.Pushed : ButtonState.Normal); if (!_enabled) { state |= ButtonState.Inactive; } if (type != LmButtonColumn.ButtonType.PlainCombo) { ControlPaint.DrawButton(g, rcbtn, state); } else { rcbtn = AdjustRectToDefaultComboButtonWidth(rcbtn); ControlPaint.DrawComboButton(g, rcbtn, state); } }
/// <summary> /// Paints the control. /// </summary> /// <param name="e"></param> protected override void OnPaint(PaintEventArgs e) { base.OnPaint(e); if (drawWithVisualStyles && ComboBoxRenderer.IsSupported) { // draw using the visual style renderer ComboBoxRenderer.DrawTextBox(e.Graphics, ClientRectangle, GetTextBoxState()); ComboBoxRenderer.DrawDropDownButton(e.Graphics, dropDownButtonBounds, GetDropDownButtonState()); } else { // draw using the legacy technique Rectangle borderRect = ClientRectangle; borderRect.Height++; e.Graphics.FillRectangle(new SolidBrush(BackColor), ClientRectangle); ControlPaint.DrawBorder3D(e.Graphics, borderRect); ControlPaint.DrawComboButton(e.Graphics, dropDownButtonBounds, GetPlainButtonState()); } OnPaintContent(new DropDownPaintEventArgs(e.Graphics, e.ClipRectangle, GetTextBoxBounds())); }
/// ------------------------------------------------------------------------------------ /// <summary> /// Draws the drop down button. /// </summary> /// ------------------------------------------------------------------------------------ private void DrawDropDownButton(Graphics graphics) { VisualStyleElement element = VisualStyleElement.ComboBox.DropDownButton.Disabled; ButtonState state = ButtonState.Normal; switch (m_buttonState) { case DropDownButtonState.Pressed: element = VisualStyleElement.ComboBox.DropDownButton.Pressed; state = ButtonState.Pushed; break; case DropDownButtonState.Hot: element = VisualStyleElement.ComboBox.DropDownButton.Hot; state = ButtonState.Normal; break; case DropDownButtonState.Normal: element = VisualStyleElement.ComboBox.DropDownButton.Normal; state = ButtonState.Normal; break; } if (!Application.RenderWithVisualStyles) { // Strange, but we have to expand the rectangle a little bit to convince // Microsoft's drawing routine to draw an arrow that is the right size; // otherwise, the arrows are smaller than for regular comboboxes. Rectangle rect = new Rectangle(m_buttonRect.X - 1, m_buttonRect.Y - 1, m_buttonRect.Width + 2, m_buttonRect.Height + 2); ControlPaint.DrawComboButton(graphics, rect, state); } else { VisualStyleRenderer renderer = new VisualStyleRenderer(element); renderer.DrawBackground(graphics, m_buttonRect); } }