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

ButtonBase_DrawImage() protected method

protected ButtonBase_DrawImage ( ButtonBase button, Graphics dc ) : void
button ButtonBase
dc System.Drawing.Graphics
return void
		protected virtual void ButtonBase_DrawImage(ButtonBase button, Graphics dc)
		{
			// Need to draw a picture
			Image	i;
			int	image_x;
			int	image_y;
			int	image_width;
			int	image_height;
			
			int width = button.ClientSize.Width;
			int height = button.ClientSize.Height;

			if (button.ImageIndex != -1) {	 // We use ImageIndex instead of image_index since it will return -1 if image_list is null
				i = button.image_list.Images[button.ImageIndex];
			} else {
				i = button.image;
			}

			image_width = i.Width;
			image_height = i.Height;
			
			switch (button.ImageAlign) {
				case ContentAlignment.TopLeft: {
					image_x = 5;
					image_y = 5;
					break;
				}
					
				case ContentAlignment.TopCenter: {
					image_x = (width - image_width) / 2;
					image_y = 5;
					break;
				}
					
				case ContentAlignment.TopRight: {
					image_x = width - image_width - 5;
					image_y = 5;
					break;
				}
					
				case ContentAlignment.MiddleLeft: {
					image_x = 5;
					image_y = (height - image_height) / 2;
					break;
				}
					
				case ContentAlignment.MiddleCenter: {
					image_x = (width - image_width) / 2;
					image_y = (height - image_height) / 2;
					break;
				}
					
				case ContentAlignment.MiddleRight: {
					image_x = width - image_width - 4;
					image_y = (height - image_height) / 2;
					break;
				}
					
				case ContentAlignment.BottomLeft: {
					image_x = 5;
					image_y = height - image_height - 4;
					break;
				}
					
				case ContentAlignment.BottomCenter: {
					image_x = (width - image_width) / 2;
					image_y = height - image_height - 4;
					break;
				}
					
				case ContentAlignment.BottomRight: {
					image_x = width - image_width - 4;
					image_y = height - image_height - 4;
					break;
				}
					
				default: {
					image_x = 5;
					image_y = 5;
					break;
				}
			}
			
			dc.SetClip (new Rectangle(3, 3, width - 5, height - 5));

			if (button.Enabled)
				dc.DrawImage (i, image_x, image_y, image_width, image_height);
			else
				CPDrawImageDisabled (dc, i, image_x, image_y, ColorControl);

			dc.ResetClip ();
		}
		
ThemeWin32Classic