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

DrawToolBarButtonContents() protected method

protected DrawToolBarButtonContents ( Graphics dc, System.Windows.Forms.ToolBar control, System.Windows.Forms.ToolBarItem item, StringFormat format ) : void
dc System.Drawing.Graphics
control System.Windows.Forms.ToolBar
item System.Windows.Forms.ToolBarItem
format System.Drawing.StringFormat
return void
		protected virtual void DrawToolBarButtonContents (Graphics dc, ToolBar control, ToolBarItem item, StringFormat format)
		{
			if (item.Button.Image != null) {
				int x = item.ImageRectangle.X + ToolBarImageGripWidth;
				int y = item.ImageRectangle.Y + ToolBarImageGripWidth;
				
				// Increase vertical and horizontal position by 1 when button is pressed
				if (item.Pressed || item.Button.Pushed) {
				    x += 1;
				    y += 1;
				}
				
				if (item.Button.Enabled)
					dc.DrawImage (item.Button.Image, x, y);
				else 
					CPDrawImageDisabled (dc, item.Button.Image, x, y, ColorControl);
			}

			Rectangle text_rect = item.TextRectangle;
			if (text_rect.Width <= 0 || text_rect.Height <= 0)
				return;

			if (item.Pressed || item.Button.Pushed) {
				text_rect.X += 1;
				text_rect.Y += 1;
			}
			
			if (item.Button.Enabled)
				dc.DrawString (item.Button.Text, control.Font, SystemBrushes.ControlText, text_rect, format);
			else
				CPDrawStringDisabled (dc, item.Button.Text, control.Font, control.BackColor, text_rect, format);
		}
ThemeWin32Classic