Jump to content
Xtreme .Net Talk

Recommended Posts

  • Administrators
Posted
It kind of depends on what the DrawRectanglesRectangule actually does. PaintEventArgs are normally passed to a forms Paint Event - it allows you to get to the graphics object and also identify what region needs repainting. Without knowing more about the code in question and what it does (or who wrote it) then it's very difficult to say what to pass in as a parameter.

Posting Guidelines FAQ Post Formatting

 

Intellectuals solve problems; geniuses prevent them.

-- Albert Einstein

Posted

		public void DrawRectanglesRectangle(PaintEventArgs e)
	{
		// Create pen.
		Pen blackPen = new Pen(Color.Black, 3);
		// Create array of rectangles.
		Rectangle[] rects =
		{
			new Rectangle(  0,   0, 100, 200),
			new Rectangle(100, 200, 250,  50),
			new Rectangle(300,   0,  50, 100)
		};
		// Draw rectangles to screen.
		e.Graphics.DrawRectangles(blackPen, rects);
	}

 

here is the code

Posted


Rectangle[] GetFormRectangles()
{
 return new Rectangle[]
	 { 
				new Rectangle( 0, 0, 100, 200),
				new Rectangle(100, 200, 250, 50),
				new Rectangle(300, 0, 50, 100)
	 };
}

private void DrawFormRectanglesOnGraphics(Graphics g)
{
 g.DrawRectangles(new Pen(Color.Black, 3), GetFormRectangles());
}

public void DrawRectanglesOnControl(Control ctrl)
{
 DrawRectanglesOnGraphics(ctrl.CreateGraphics()); 
}

private void Form1_Paint(object sender, System.Windows.Forms.PaintEventArgs e)
{
 DrawRectanglesOnGraphics(e.Graphics); 
}

private void button1_Click(object sender, System.EventArgs e)
{
 DrawRectanglesOnControl(this);
}

 

you could also just force the entre form to repaint

private void button1_Click(object sender, System.EventArgs e)
{
 this.Refresh();
}

Joe Mamma

Amendment 4: The right of the people to be secure in their persons, houses, papers, and effects, against unreasonable searches and seizures, shall not be violated, and no warrants shall issue, but upon probable cause, supported by oath or affirmation, and particularly describing the place to be searched, and the persons or things to be seized.

Amendment 9: The enumeration in the Constitution, of certain rights, shall not be construed to deny or disparage others retained by the people.

Posted
Here to serve.

Joe Mamma

Amendment 4: The right of the people to be secure in their persons, houses, papers, and effects, against unreasonable searches and seizures, shall not be violated, and no warrants shall issue, but upon probable cause, supported by oath or affirmation, and particularly describing the place to be searched, and the persons or things to be seized.

Amendment 9: The enumeration in the Constitution, of certain rights, shall not be construed to deny or disparage others retained by the people.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...