System.Windows.Forms.ThemeWin32Classic.ButtonBase_DrawButton C# (CSharp) Method

ButtonBase_DrawButton() protected method

protected ButtonBase_DrawButton ( ButtonBase button, Graphics dc ) : void
button ButtonBase
dc System.Drawing.Graphics
return void
		protected virtual void ButtonBase_DrawButton (ButtonBase button, Graphics dc)
		{
			Rectangle borderRectangle;
			bool check_or_radio = false;
			bool check_or_radio_checked = false;
			
			bool is_ColorControl = button.BackColor.ToArgb () == ColorControl.ToArgb () ? true : false;
			
			CPColor cpcolor = is_ColorControl ? CPColor.Empty : ResPool.GetCPColor (button.BackColor);
			
			if (button is CheckBox) {
				check_or_radio = true;
				check_or_radio_checked = ((CheckBox)button).Checked;
			} else if (button is RadioButton) {
				check_or_radio = true;
				check_or_radio_checked = ((RadioButton)button).Checked;
			}
			
			if (button.Focused && button.Enabled && !check_or_radio) {
				// shrink the rectangle for the normal button drawing inside the focus rectangle
				borderRectangle = Rectangle.Inflate (button.ClientRectangle, -1, -1);
			} else {
				borderRectangle = button.ClientRectangle;
			}
			
			if (button.FlatStyle == FlatStyle.Popup) {
				if (!button.is_pressed && !button.is_entered && !check_or_radio_checked)
					Internal_DrawButton (dc, borderRectangle, 1, cpcolor, is_ColorControl, button.BackColor);
				else if (!button.is_pressed && button.is_entered &&!check_or_radio_checked)
					Internal_DrawButton (dc, borderRectangle, 2, cpcolor, is_ColorControl, button.BackColor);
				else if (button.is_pressed || check_or_radio_checked)
					Internal_DrawButton (dc, borderRectangle, 1, cpcolor, is_ColorControl, button.BackColor);
			} else if (button.FlatStyle == FlatStyle.Flat) {
				if (button.is_entered && !button.is_pressed && !check_or_radio_checked) {
					if ((button.image == null) && (button.image_list == null)) {
						Brush brush = is_ColorControl ? SystemBrushes.ControlDark : ResPool.GetSolidBrush (cpcolor.Dark);
						dc.FillRectangle (brush, borderRectangle);
					}
				} else if (button.is_pressed || check_or_radio_checked) {
					if ((button.image == null) && (button.image_list == null)) {
						Brush brush = is_ColorControl ? SystemBrushes.ControlLightLight : ResPool.GetSolidBrush (cpcolor.LightLight);
						dc.FillRectangle (brush, borderRectangle);
					}
					
					Pen pen = is_ColorControl ? SystemPens.ControlDark : ResPool.GetPen (cpcolor.Dark);
					dc.DrawRectangle (pen, borderRectangle.X + 4, borderRectangle.Y + 4,
							  borderRectangle.Width - 9, borderRectangle.Height - 9);
				}
				
				Internal_DrawButton (dc, borderRectangle, 3, cpcolor, is_ColorControl, button.BackColor);
			} else {
				if ((!button.is_pressed || !button.Enabled) && !check_or_radio_checked)
					Internal_DrawButton (dc, borderRectangle, 0, cpcolor, is_ColorControl, button.BackColor);
				else
					Internal_DrawButton (dc, borderRectangle, 1, cpcolor, is_ColorControl, button.BackColor);
			}
		}
		
ThemeWin32Classic