Shape.Region プロパティ
行または形状のコントロールに関連付けられたウィンドウ領域を取得または設定します。
名前空間: Microsoft.VisualBasic.PowerPacks
アセンブリ: Microsoft.VisualBasic.PowerPacks.Vs (Microsoft.VisualBasic.PowerPacks.Vs.dll 内)
構文
'宣言
<BrowsableAttribute(False)> _
Public Property Region As Region
[BrowsableAttribute(false)]
public Region Region { get; set; }
[BrowsableAttribute(false)]
public:
property Region^ Region {
Region^ get ();
void set (Region^ value);
}
[<BrowsableAttribute(false)>]
member Region : Region with get, set
function get Region () : Region
function set Region (value : Region)
プロパティ値
型 : Region
コントロールに関連付けられたウィンドウ Region。
解説
ウィンドウ領域、オペレーティング システムの描画を有効にするウィンドウ内のピクセルのコレクションです。 オペレーティング システムでは、ウィンドウの領域外にあるウィンドウの任意の部分は表示されません。 コントロールの領域の座標はコントロールのクライアント領域ではなく、コントロールの左上隅を基準にします。
例
次の例で使用する方法、Regionプロパティを変更する、 RectangleShape 、半透明の楕円にします。 この例では、RectangleShapeフォーム上の RectangleShape1 という名前です。 半透明の効果を表示するには画像を割り当てる、 BackgroundImage 、フォームのプロパティです。
Private Sub RectangleShape1_Paint(
ByVal sender As Object,
ByVal e As System.Windows.Forms.PaintEventArgs
) Handles RectangleShape1.Paint
Dim shapePath As New System.Drawing.Drawing2D.GraphicsPath
' Set a new rectangle to the same size as the RectangleShape's
' ClientRectangle property.
Dim newRectangle As Rectangle = RectangleShape1.ClientRectangle
' Decrease the size of the rectangle.
newRectangle.Inflate(-10, -10)
' Draw the new rectangle's border.
e.Graphics.DrawEllipse(System.Drawing.Pens.Black, newRectangle)
' Create a semi-transparent brush.
Dim br As New SolidBrush(Color.FromArgb(128, 0, 0, 255))
' Fill the new rectangle.
e.Graphics.FillEllipse(br, newRectangle)
'Increase the size of the rectangle to include the border.
newRectangle.Inflate(1, 1)
' Create an oval region within the new rectangle.
shapePath.AddEllipse(newRectangle)
e.Graphics.DrawPath(Pens.Black, shapePath)
' Set the RectangleShape's Region property to the newly created
' oval region.
RectangleShape1.Region = New System.Drawing.Region(shapePath)
End Sub
private void rectangleShape1_Paint(object sender, System.Windows.Forms.PaintEventArgs e)
{
System.Drawing.Drawing2D.GraphicsPath shapePath = new System.Drawing.Drawing2D.GraphicsPath();
// Set a new rectangle to the same size as the RectangleShape's
// ClientRectangle property.
Rectangle newRectangle = rectangleShape1.ClientRectangle;
// Decrease the size of the rectangle.
newRectangle.Inflate(-10, -10);
// Draw the new rectangle's border.
e.Graphics.DrawEllipse(System.Drawing.Pens.Black, newRectangle);
// Create a semi-transparent brush.
SolidBrush br = new SolidBrush(Color.FromArgb(128, 0, 0, 255));
// Fill the new rectangle.
e.Graphics.FillEllipse(br, newRectangle);
//Increase the size of the rectangle to include the border.
newRectangle.Inflate(1, 1);
// Create an oval region within the new rectangle.
shapePath.AddEllipse(newRectangle);
e.Graphics.DrawPath(Pens.Black, shapePath);
// Set the RectangleShape's Region property to the newly created
// oval region.
rectangleShape1.Region = new System.Drawing.Region(shapePath);
}
.NET Framework セキュリティ
- 直前の呼び出し元に対する完全な信頼。このメンバーは、部分的に信頼されているコードから使用することはできません。詳細については、「部分信頼コードからのライブラリの使用」を参照してください。
参照
関連項目
Microsoft.VisualBasic.PowerPacks 名前空間
その他の技術情報
方法 : LineShape コントロールを使用して線を描画する (Visual Studio)
方法 : OvalShape コントロールおよび RectangleShape コントロールを使用して図形を描画する (Visual Studio)