Region.GetBounds(Graphics) メソッド
定義
重要
一部の情報は、リリース前に大きく変更される可能性があるプレリリースされた製品に関するものです。 Microsoft は、ここに記載されている情報について、明示または黙示を問わず、一切保証しません。
RectangleF オブジェクトの描画サーフェイスのこの Region に外接する四角形を表す Graphics 構造体を取得します。
public:
System::Drawing::RectangleF GetBounds(System::Drawing::Graphics ^ g);
public System.Drawing.RectangleF GetBounds (System.Drawing.Graphics g);
member this.GetBounds : System.Drawing.Graphics -> System.Drawing.RectangleF
Public Function GetBounds (g As Graphics) As RectangleF
パラメーター
戻り値
指定の描画サーフェイスのこの RectangleF に外接する四角形を表す Region 構造体。
例外
g
が null
です。
例
次のコード例は、Windows フォームで使用するように設計されており、イベント ハンドラーのPaintパラメーターである が必要PaintEventArgse
です。 コードは、次のアクションを実行します。
を GraphicsPath 作成し、楕円を追加します。
パスを青で塗りつぶし、画面に描画します。
を使用するリージョンを作成します GraphicsPath。
2 番目の四角形と組み合わせたときに、領域の存在しない領域を取得します。
領域の外接する四角形を取得し、赤で画面に描画します。
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.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 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
注釈
グラフィックス コンテキストの現在の変換は、描画サーフェス上の領域内部を計算するために使用されます。 外接する四角形は、現在の変換に応じて、常に可能な限り最小の外接する四角形であるとは限りません。
適用対象
GitHub で Microsoft と共同作業する
このコンテンツのソースは GitHub にあります。そこで、issue や pull request を作成および確認することもできます。 詳細については、共同作成者ガイドを参照してください。
.NET
フィードバック
https://aka.ms/ContentUserFeedback」を参照してください。
以下は間もなく提供いたします。2024 年を通じて、コンテンツのフィードバック メカニズムとして GitHub の issue を段階的に廃止し、新しいフィードバック システムに置き換えます。 詳細については、「フィードバックの送信と表示