次の方法で共有


Region.IsVisible メソッド (RectangleF)

指定の RectangleF 構造体に、この Region オブジェクト内に含まれている部分があるかどうかをテストします。

Overloads Public Function IsVisible( _
   ByVal rect As RectangleF _) As Boolean
[C#]
public bool IsVisible(RectangleFrect);
[C++]
public: bool IsVisible(RectangleFrect);
[JScript]
public function IsVisible(
   rect : RectangleF) : Boolean;

パラメータ

戻り値

このメソッドは、 rect に、この Region オブジェクトに含まれている部分がある場合は true を返します。それ以外の場合は false を返します。

使用例

[Visual Basic, C#] 次の例は、Windows フォームでの使用を意図してデザインされており、 Paint イベント ハンドラのパラメータである PaintEventArgs e が必要です。このコードは次のアクションを実行します。

  • 最初の四角形を作成し、青で画面に描画します。
  • 2 番目の四角形を作成し、赤で画面に描画します。
  • 最初の四角形を形成する領域を作成します。
  • 四角形に、領域と交差する部分があるかどうかを確認します。
  • 画面に結果 true または false を表示します。

[Visual Basic, C#] 一方がもう一方と交差するため結果は true になります。

 
Public Sub IsVisible_RectF_Example(e As PaintEventArgs)
' Create the first rectangle and draw it to the screen in blue.
Dim regionRect As New Rectangle(20, 20, 100, 100)
e.Graphics.DrawRectangle(Pens.Blue, regionRect)
' create the second rectangle and draw it to the screen in red.
Dim myRect As New RectangleF(90, 30, 100, 100)
e.Graphics.DrawRectangle(Pens.Red, Rectangle.Round(myRect))
' Create a region using the first rectangle.
Dim myRegion As New [Region](regionRect)
' Determine if myRect is contained in the region.
Dim contained As Boolean = myRegion.IsVisible(myRect)
' Display the result.
Dim myFont As New Font("Arial", 8)
Dim myBrush As New SolidBrush(Color.Black)
e.Graphics.DrawString("contained = " & contained.ToString(), _
myFont, myBrush, New PointF(20, 140))
End Sub
        
[C#] 
public void IsVisible_RectF_Example(PaintEventArgs e)
{
// Create the first rectangle and draw it to the screen in blue.
Rectangle regionRect = new Rectangle(20, 20, 100, 100);
e.Graphics.DrawRectangle(Pens.Blue, regionRect);
// Create the second rectangle and draw it to the screen in red.
RectangleF myRect = new RectangleF(90, 30, 100, 100);
e.Graphics.DrawRectangle(Pens.Red, Rectangle.Round(myRect));
// Create a region using the first rectangle.
Region myRegion = new Region(regionRect);
// Determine if myRect is contained in the region.
bool contained = myRegion.IsVisible(myRect);
// Display the result.
Font myFont = new Font("Arial", 8);
SolidBrush myBrush = new SolidBrush(Color.Black);
e.Graphics.DrawString("contained = " + contained.ToString(),
myFont,
myBrush,
new PointF(20, 140));
}
        

[C++, JScript] C++ および JScript のサンプルはありません。Visual Basic および C# のサンプルを表示するには、このページの左上隅にある言語のフィルタ ボタン 言語のフィルタ をクリックします。

必要条件

プラットフォーム: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 ファミリ

参照

Region クラス | Region メンバ | System.Drawing 名前空間 | Region.IsVisible オーバーロードの一覧