本文整理匯總了C#中System.Drawing.Graphics.DrawRectangles方法的典型用法代碼示例。如果您正苦於以下問題:C# Graphics.DrawRectangles方法的具體用法?C# Graphics.DrawRectangles怎麽用?C# Graphics.DrawRectangles使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類System.Drawing.Graphics
的用法示例。
在下文中一共展示了Graphics.DrawRectangles方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。
示例1: DrawRectanglesRectangle
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);
}
示例2: DrawRectanglesRectangleF
public void DrawRectanglesRectangleF(PaintEventArgs e)
{
// Create pen.
Pen blackPen = new Pen(Color.Black, 3);
// Create array of rectangles.
RectangleF[] rects =
{
new RectangleF( 0.0F, 0.0F, 100.0F, 200.0F),
new RectangleF(100.0F, 200.0F, 250.0F, 50.0F),
new RectangleF(300.0F, 0.0F, 50.0F, 100.0F)
};
// Draw rectangles to screen.
e.Graphics.DrawRectangles(blackPen, rects);
}
示例3: Main
//引入命名空間
using System;
using System.Drawing;
using System.Windows.Forms;
class FourByFours: Form
{
public static void Main()
{
Application.Run(new FourByFours());
}
public FourByFours()
{
ResizeRedraw = true;
}
protected override void OnPaint(PaintEventArgs pea)
{
DoPage(pea.Graphics, ForeColor,ClientSize.Width, ClientSize.Height);
}
protected void DoPage(Graphics grfx, Color clr, int cx, int cy)
{
Pen pen = new Pen(clr);
Brush brush = new SolidBrush(clr);
grfx.DrawRectangles(pen, new Rectangle[] {new Rectangle(8, 2, 4, 4)});
}
}