Region.GetBounds メソッド
アセンブリ: System.Drawing (system.drawing.dll 内)

Dim instance As Region Dim g As Graphics Dim returnValue As RectangleF returnValue = instance.GetBounds(g)
戻り値
指定の描画サーフェイスのこの Region に外接する四角形を表す RectangleF 構造体。



次の例は、Windows フォームでの使用を意図してデザインされており、Paint イベント ハンドラのパラメータである PaintEventArgse が必要です。このコードは次のアクションを実行します。
Public Sub GetBoundsExample(ByVal e As PaintEventArgs) ' Create a GraphicsPath and add an ellipse to it. Dim myPath As New GraphicsPath Dim ellipseRect As New Rectangle(20, 20, 100, 100) myPath.AddEllipse(ellipseRect) ' Fill the path with blue and draw it to the screen. Dim myBrush As New SolidBrush(Color.Blue) e.Graphics.FillPath(myBrush, myPath) ' Create a region using the GraphicsPath. Dim myRegion As New [Region](myPath) ' Get the bounding rectangle for myRegion and draw it to the ' screen in Red. Dim boundsRect As RectangleF = myRegion.GetBounds(e.Graphics) e.Graphics.DrawRectangle(Pens.Red, Rectangle.Round(boundsRect)) End Sub
public void GetBoundsExample(PaintEventArgs e) { // Create a GraphicsPath and add an ellipse to it. GraphicsPath myPath = new GraphicsPath(); Rectangle ellipseRect = new Rectangle(20, 20, 100, 100); myPath.AddEllipse(ellipseRect); // Fill the path with blue and draw it to the screen. SolidBrush myBrush = new SolidBrush(Color.Blue); e.Graphics.FillPath(myBrush, myPath); // Create a region using the GraphicsPath. Region myRegion = new Region(myPath); // Get the bounding rectangle for myRegion and draw it to the // screen in Red. RectangleF boundsRect = myRegion.GetBounds(e.Graphics); e.Graphics.DrawRectangle(Pens.Red, Rectangle.Round(boundsRect)); }
public: void GetBoundsExample( PaintEventArgs^ e ) { // Create a GraphicsPath and add an ellipse to it. GraphicsPath^ myPath = gcnew GraphicsPath; Rectangle ellipseRect = Rectangle(20,20,100,100); myPath->AddEllipse( ellipseRect ); // Fill the path with blue and draw it to the screen. SolidBrush^ myBrush = gcnew SolidBrush( Color::Blue ); e->Graphics->FillPath( myBrush, myPath ); // Create a region using the GraphicsPath. System::Drawing::Region^ myRegion = gcnew System::Drawing::Region( myPath ); // Get the bounding rectangle for myRegion and draw it to the // screen in Red. RectangleF boundsRect = myRegion->GetBounds( e->Graphics ); e->Graphics->DrawRectangle( Pens::Red, Rectangle::Round( boundsRect ) ); }
public void GetBoundsExample(PaintEventArgs e) { // Create a GraphicsPath and add an ellipse to it. GraphicsPath myPath = new GraphicsPath(); Rectangle ellipseRect = new Rectangle(20, 20, 100, 100); myPath.AddEllipse(ellipseRect); // Fill the path with blue and draw it to the screen. SolidBrush myBrush = new SolidBrush(Color.get_Blue()); e.get_Graphics().FillPath(myBrush, myPath); // Create a region using the GraphicsPath. Region myRegion = new Region(myPath); // Get the bounding rectangle for myRegion and draw it to the // screen in Red. RectangleF boundsRect = myRegion.GetBounds(e.get_Graphics()); e.get_Graphics().DrawRectangle(Pens.get_Red(), Rectangle.Round(boundsRect)); } //GetBoundsExample

Windows 98, Windows 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
開発プラットフォームの中には、.NET Framework によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。


- Region.GetBounds メソッドのページへのリンク