System.Windows.Forms.Control.DrawBackgroundImage C# (CSharp) Method

DrawBackgroundImage() private method

private DrawBackgroundImage ( Graphics g ) : void
g System.Drawing.Graphics
return void
		void DrawBackgroundImage (Graphics g)
		{
			Rectangle drawing_rectangle = new Rectangle ();
			g.FillRectangle (new SolidBrush (BackColor), ClientRectangle);
			
			switch (backgroundimage_layout)
			{
			case ImageLayout.Tile:
				using (TextureBrush b = new TextureBrush (background_image, WrapMode.Tile))
				{
					g.FillRectangle (b, ClientRectangle);
				}

				return;
			case ImageLayout.Center:
				drawing_rectangle.Location = new Point (ClientSize.Width / 2 - background_image.Width / 2, ClientSize.Height / 2 - background_image.Height / 2);
				drawing_rectangle.Size = background_image.Size;
				break;
			case ImageLayout.None:
				drawing_rectangle.Location = Point.Empty;
				drawing_rectangle.Size = background_image.Size;
				break;
			case ImageLayout.Stretch:
				drawing_rectangle = ClientRectangle;
				break;
			case ImageLayout.Zoom:
				drawing_rectangle = ClientRectangle;
				if ((float)background_image.Width / (float)background_image.Height < (float)drawing_rectangle.Width / (float)drawing_rectangle.Height)
				{
					drawing_rectangle.Width = (int)(background_image.Width * ((float)drawing_rectangle.Height / (float)background_image.Height));
					drawing_rectangle.X = (ClientRectangle.Width - drawing_rectangle.Width) / 2;
				}

				else
				{
					drawing_rectangle.Height = (int)(background_image.Height * ((float)drawing_rectangle.Width / (float)background_image.Width));
					drawing_rectangle.Y = (ClientRectangle.Height - drawing_rectangle.Height) / 2;
				}

				break;
			default:
				return;
			}
			
			g.DrawImage (background_image, drawing_rectangle);
			
		}
Control