.NET的GDI+绘图基础:Graphics类的绘图方法2:Graphics.DrawRectangle()方法 ....

.NET的GDI+绘图基础:Graphics类的绘图方法2:Graphics.DrawRectangle()方法 ...

Graphics.DrawRectangle()方法MSDN官网:

                                              http://msdn.microsoft.com/zh-cn/library/system.drawing.graphics.drawrectangle.aspx

PS;  Graphics.DrawRectangle()方法:  绘制由坐标对、宽度和高度指定的矩形。

重载此成员。 有关此成员的完整信息(包括语法、用法和示例),请单击重载列表中的相应名称。

Graphics.DrawRectangle()方法的重载列表:

1. DrawRectangle(Pen, Rectangle) 绘制由Rectangle结构指定的矩形.

2. DrawRectangle(Pen, Int32, Int32, Int32, Int32) 绘制由坐标对、宽度和高度指定的矩形。

3. DrawRectangle(Pen, Single, Single, Single, Single) 绘制由坐标对、宽度和高度指定的矩形。

例子:

-----------------1-DrawRectangle(Pen, Rectangle)类型方法!---------------------------------------

public void DrawRectangleRectangle(PaintEventArgs e)
{
    // Create pen.类型:System.Drawing.Pen
    Pen blackPen = new Pen(Color.Black, 3);
    // Create rectangle.类型:System.Drawing.Rectangle
    Rectangle rect = new Rectangle(0, 0, 200, 200);
    // Draw rectangle to screen.
    e.Graphics.DrawRectangle(blackPen, rect);
}

------------2--DrawRectangle(Pen, Int32, Int32, Int32, Int32)类型方法 !---------------------------------

public void DrawRectangleInt(PaintEventArgs e)
{
    // Create pen.创建黑色钢笔。
    Pen blackPen = new Pen(Color.Black, 3);
    // Create location and size of rectangle.创建矩形的位置和大小。 
    int x = 0;//要绘制的矩形的左上角的 x 坐标。 
    int y = 0;//要绘制的矩形的左上角的 y 坐标。 
    int width = 200;//要绘制的矩形的宽度。 
    int height = 200;//要绘制的矩形的高度。
    // Draw rectangle to screen.将该矩形绘制到屏幕。 
    e.Graphics.DrawRectangle(blackPen, x, y, width, height);
}

-------------3- DrawRectangle(Pen, Single, Single, Single, Single)类型方法! ---------------------------------------
public void DrawRectangleFloat(PaintEventArgs e)
{
    // Create pen.
    Pen blackPen = new Pen(Color.Black, 3);
    // Create location and size of rectangle.
    float x = 0.0F;
    float y = 0.0F;
    float width = 200.0F;
    float height = 200.0F;
    // Draw rectangle to screen.
    e.Graphics.DrawRectangle(blackPen, x, y, width, height);
}

posted @ 2011-04-28 22:11  linjianlong  阅读(680)  评论(0)    收藏  举报