"Overseer" <ce****@gmail.comwrote in message
news:OD*************@TK2MSFTNGP05.phx.gbl...
What is the best way to draw graphics like Task Manager's Performance
Graphic??
Use the routines in GDI+. First you'll need a Graphics object. Depending
on where you want to draw the graphics, you'll use the CreateGraphics
function of a control, or if you are going to use a Paint event, you will
receive the Graphics as an argument. For instance, if you want to paint in
the background of a PictureBox, you implement the Paint event of the
PictureBox and receive the Graphics object in the EventArgs argument. The
example provided by MSDN is this one:
private void pictureBox1_Paint(object sender,
System.Windows.Forms.PaintEventArgs e)
{
// Create a local version of the graphics object for the PictureBox.
Graphics g = e.Graphics;
// Draw a string on the PictureBox.
g.DrawString("This is a diagonal line drawn on the control",
new Font("Arial",10), System.Drawing.Brushes.Blue, new
Point(30,30));
// Draw a line in the PictureBox.
g.DrawLine(System.Drawing.Pens.Red, pictureBox1.Left, pictureBox1.Top,
pictureBox1.Right, pictureBox1.Bottom);
}
As you can see, the Graphics object has many methods that start with
Draw..., such as DrawString, DrawLine, DrawElipse, etc., which let you paint
anything you want if you use them properly.