+ #region Button
+ #region Standard Button Style
+ public override void DrawButton (Graphics g, Button b, Rectangle textBounds, Rectangle imageBounds, Rectangle clipRectangle)
+ {
+ // Draw Button Background
+ DrawButtonBackground (g, b, clipRectangle);
+
+ // If we have an image, draw it
+ if (imageBounds.Size != Size.Empty)
+ DrawButtonImage (g, b, imageBounds);
+
+ // If we're focused, draw a focus rectangle
+ if (b.Focused && b.Enabled)
+ DrawButtonFocus (g, b);
+
+ // If we have text, draw it
+ if (textBounds != Rectangle.Empty)
+ DrawButtonText (g, b, textBounds);
+ }
+
+ public virtual void DrawButtonBackground (Graphics g, Button button, Rectangle clipArea)
+ {
+ if (button.Pressed)
+ ThemeElements.DrawButton (g, button.ClientRectangle, ButtonThemeState.Pressed, button.BackColor, button.ForeColor);
+ else if (button.InternalSelected)
+ ThemeElements.DrawButton (g, button.ClientRectangle, ButtonThemeState.Default, button.BackColor, button.ForeColor);
+ else if (button.Entered)
+ ThemeElements.DrawButton (g, button.ClientRectangle, ButtonThemeState.Entered, button.BackColor, button.ForeColor);
+ else if (!button.Enabled)
+ ThemeElements.DrawButton (g, button.ClientRectangle, ButtonThemeState.Disabled, button.BackColor, button.ForeColor);
+ else
+ ThemeElements.DrawButton (g, button.ClientRectangle, ButtonThemeState.Normal, button.BackColor, button.ForeColor);
+ }
+
+ public virtual void DrawButtonFocus (Graphics g, Button button)
+ {
+ ControlPaint.DrawFocusRectangle (g, Rectangle.Inflate (button.ClientRectangle, -4, -4));
+ }
+
+ public virtual void DrawButtonImage (Graphics g, Button button, Rectangle imageBounds)
+ {
+ if (button.Enabled)
+ g.DrawImage (button.Image, imageBounds);
+ else
+ CPDrawImageDisabled (g, button.Image, imageBounds.Left, imageBounds.Top, ColorControl);
+ }
+
+ public virtual void DrawButtonText (Graphics g, Button button, Rectangle textBounds)
+ {
+ if (button.Enabled)
+ TextRenderer.DrawTextInternal (g, button.Text, button.Font, textBounds, button.ForeColor, button.TextFormatFlags, button.UseCompatibleTextRendering);
+ else
+ DrawStringDisabled20 (g, button.Text, button.Font, textBounds, button.BackColor, button.TextFormatFlags, button.UseCompatibleTextRendering);
+ }
+ #endregion
+
+ #region FlatStyle Button Style
+ public override void DrawFlatButton (Graphics g, Button b, Rectangle textBounds, Rectangle imageBounds, Rectangle clipRectangle)
+ {
+ // Draw Button Background
+ DrawFlatButtonBackground (g, b, clipRectangle);
+
+ // If we have an image, draw it
+ if (imageBounds.Size != Size.Empty)
+ DrawFlatButtonImage (g, b, imageBounds);
+
+ // If we're focused, draw a focus rectangle
+ if (b.Focused && b.Enabled)
+ DrawFlatButtonFocus (g, b);
+
+ // If we have text, draw it
+ if (textBounds != Rectangle.Empty)
+ DrawFlatButtonText (g, b, textBounds);
+ }
+
+ public virtual void DrawFlatButtonBackground (Graphics g, Button button, Rectangle clipArea)
+ {
+ if (button.Pressed)
+ ThemeElements.DrawFlatButton (g, button.ClientRectangle, ButtonThemeState.Pressed, button.BackColor, button.ForeColor, button.FlatAppearance);
+ else if (button.InternalSelected) {
+ if (button.Entered)
+ ThemeElements.DrawFlatButton (g, button.ClientRectangle, ButtonThemeState.Default | ButtonThemeState.Entered, button.BackColor, button.ForeColor, button.FlatAppearance);
+ else
+ ThemeElements.DrawFlatButton (g, button.ClientRectangle, ButtonThemeState.Default, button.BackColor, button.ForeColor, button.FlatAppearance);
+ }
+ else if (button.Entered)
+ ThemeElements.DrawFlatButton (g, button.ClientRectangle, ButtonThemeState.Entered, button.BackColor, button.ForeColor, button.FlatAppearance);
+ else if (!button.Enabled)
+ ThemeElements.DrawFlatButton (g, button.ClientRectangle, ButtonThemeState.Disabled, button.BackColor, button.ForeColor, button.FlatAppearance);
+ else
+ ThemeElements.DrawFlatButton (g, button.ClientRectangle, ButtonThemeState.Normal, button.BackColor, button.ForeColor, button.FlatAppearance);
+ }
+
+ public virtual void DrawFlatButtonFocus (Graphics g, Button button)
+ {
+ if (!button.Pressed) {
+ Color focus_color = ControlPaint.Dark (button.BackColor);
+ g.DrawRectangle (ResPool.GetPen (focus_color), new Rectangle (button.ClientRectangle.Left + 4, button.ClientRectangle.Top + 4, button.ClientRectangle.Width - 9, button.ClientRectangle.Height - 9));
+ }
+ }
+
+ public virtual void DrawFlatButtonImage (Graphics g, Button button, Rectangle imageBounds)
+ {
+ // No changes from Standard for image for this theme
+ DrawButtonImage (g, button, imageBounds);
+ }
+
+ public virtual void DrawFlatButtonText (Graphics g, Button button, Rectangle textBounds)
+ {
+ // No changes from Standard for text for this theme
+ DrawButtonText (g, button, textBounds);
+ }
+ #endregion
+
+ #region Popup Button Style
+ public override void DrawPopupButton (Graphics g, Button b, Rectangle textBounds, Rectangle imageBounds, Rectangle clipRectangle)
+ {
+ // Draw Button Background
+ DrawPopupButtonBackground (g, b, clipRectangle);
+
+ // If we have an image, draw it
+ if (imageBounds.Size != Size.Empty)
+ DrawPopupButtonImage (g, b, imageBounds);
+
+ // If we're focused, draw a focus rectangle
+ if (b.Focused && b.Enabled)
+ DrawPopupButtonFocus (g, b);
+
+ // If we have text, draw it
+ if (textBounds != Rectangle.Empty)
+ DrawPopupButtonText (g, b, textBounds);
+ }
+
+ public virtual void DrawPopupButtonBackground (Graphics g, Button button, Rectangle clipArea)
+ {
+ if (button.Pressed)
+ ThemeElements.DrawPopupButton (g, button.ClientRectangle, ButtonThemeState.Pressed, button.BackColor, button.ForeColor);
+ else if (button.Entered)
+ ThemeElements.DrawPopupButton (g, button.ClientRectangle, ButtonThemeState.Entered, button.BackColor, button.ForeColor);
+ else if (button.InternalSelected)
+ ThemeElements.DrawPopupButton (g, button.ClientRectangle, ButtonThemeState.Default, button.BackColor, button.ForeColor);
+ else if (!button.Enabled)
+ ThemeElements.DrawPopupButton (g, button.ClientRectangle, ButtonThemeState.Disabled, button.BackColor, button.ForeColor);
+ else
+ ThemeElements.DrawPopupButton (g, button.ClientRectangle, ButtonThemeState.Normal, button.BackColor, button.ForeColor);
+ }
+
+ public virtual void DrawPopupButtonFocus (Graphics g, Button button)
+ {
+ // No changes from Standard for image for this theme
+ DrawButtonFocus (g, button);
+ }
+
+ public virtual void DrawPopupButtonImage (Graphics g, Button button, Rectangle imageBounds)
+ {
+ // No changes from Standard for image for this theme
+ DrawButtonImage (g, button, imageBounds);
+ }
+
+ public virtual void DrawPopupButtonText (Graphics g, Button button, Rectangle textBounds)
+ {
+ // No changes from Standard for image for this theme
+ DrawButtonText (g, button, textBounds);
+ }
+ #endregion
+
+ #region Button Layout Calculations
+#if NET_2_0
+ public override Size CalculateButtonAutoSize (Button button)
+ {
+ Size ret_size = Size.Empty;
+ Size text_size = TextRenderer.MeasureTextInternal (button.Text, button.Font, button.UseCompatibleTextRendering);
+ Size image_size = button.Image == null ? Size.Empty : button.Image.Size;