Brush を指定して、Pen クラスの新しいインスタンスを初期化します。
名前空間: System.Drawing
アセンブリ: System.Drawing (system.drawing.dll 内)
構文
'宣言
Public Sub New ( _
brush As Brush _
)
'使用
Dim brush As Brush
Dim instance As New Pen(brush)
public Pen (
Brush brush
)
public:
Pen (
Brush^ brush
)
public Pen (
Brush brush
)
public function Pen (
brush : Brush
)
パラメータ
例外
例外の種類 | 条件 |
---|---|
brush が null 参照 (Visual Basic では Nothing) です。 |
解説
Brush プロパティでは、Pen での直線の描画方法を決定します。直線は、塗りつぶした四角形であるかのように指定の Brush の特性で描画されます。
新しい Pen の Width プロパティは 1 (既定値) に設定されます。
使用例
次のコード例は、Brush を使用して Pen を作成する方法と、Pen で LineJoin プロパティを設定することの効果を示しています。
この例は、Windows フォームでの使用を意図してデザインされています。コードをフォームに貼り付け、フォームの Paint イベントを処理するときに PaintEventArgs の e を渡して ShowLineJoin
メソッドを呼び出します。
Private Sub ShowLineJoin(ByVal e As PaintEventArgs)
' Create a new pen.
Dim skyBluePen As New Pen(Brushes.DeepSkyBlue)
' Set the pen's width.
skyBluePen.Width = 8.0F
' Set the LineJoin property.
skyBluePen.LineJoin = Drawing2D.LineJoin.Bevel
' Draw a rectangle.
e.Graphics.DrawRectangle(skyBluePen, _
New Rectangle(40, 40, 150, 200))
'Dispose of the pen.
skyBluePen.Dispose()
End Sub
private void ShowLineJoin(PaintEventArgs e)
{
// Create a new pen.
Pen skyBluePen = new Pen(Brushes.DeepSkyBlue);
// Set the pen's width.
skyBluePen.Width = 8.0F;
// Set the LineJoin property.
skyBluePen.LineJoin = System.Drawing.Drawing2D.LineJoin.Bevel;
// Draw a rectangle.
e.Graphics.DrawRectangle(skyBluePen,
new Rectangle(40, 40, 150, 200));
//Dispose of the pen.
skyBluePen.Dispose();
}
private:
void ShowLineJoin( PaintEventArgs^ e )
{
// Create a new pen.
Pen^ skyBluePen = gcnew Pen( Brushes::DeepSkyBlue );
// Set the pen's width.
skyBluePen->Width = 8.0F;
// Set the LineJoin property.
skyBluePen->LineJoin = System::Drawing::Drawing2D::LineJoin::Bevel;
// Draw a rectangle.
e->Graphics->DrawRectangle( skyBluePen, Rectangle(40,40,150,200) );
//Dispose of the pen.
delete skyBluePen;
}
private void ShowLineJoin(PaintEventArgs e)
{
// Create a new pen.
Pen skyBluePen = new Pen(Brushes.get_DeepSkyBlue());
// Set the pen's width.
skyBluePen.set_Width(8);
// Set the LineJoin property.
skyBluePen.set_LineJoin(System.Drawing.Drawing2D.LineJoin.Bevel);
// Draw a rectangle.
e.get_Graphics().DrawRectangle(skyBluePen,
new Rectangle(40, 40, 150, 200));
//Dispose of the pen.
skyBluePen.Dispose();
} //ShowLineJoin
プラットフォーム
Windows 98, Windows 2000 SP4, Windows Millennium Edition, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
開発プラットフォームの中には、.NET Framework によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。
バージョン情報
.NET Framework
サポート対象 : 2.0、1.1、1.0