次の方法で共有


Graphics.IsVisible メソッド (Single, Single, Single, Single)

この Graphics オブジェクトの表示クリップ領域内に、座標ペア、幅、および高さで指定された四角形が含まれるかどうかを示します。

Overloads Public Function IsVisible( _
   ByVal x As Single, _   ByVal y As Single, _   ByVal width As Single, _   ByVal height As Single _) As Boolean
[C#]
public bool IsVisible(floatx,floaty,floatwidth,floatheight);
[C++]
public: bool IsVisible(floatx,floaty,floatwidth,floatheight);
[JScript]
public function IsVisible(
   x : float,y : float,width : float,height : float) : Boolean;

パラメータ

  • x
    表示可能範囲をテストする四角形の左上隅の x 座標。
  • y
    表示可能範囲をテストする四角形の左上隅の y 座標。
  • width
    表示可能範囲をテストする四角形の幅。
  • height
    表示可能範囲をテストする四角形の高さ。

戻り値

xywidthheight の各パラメータで定義された四角形がこの Graphics オブジェクトの表示クリップ領域内に含まれる場合、このメソッドは true を返します。それ以外の場合は false を返します。

使用例

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

  • 四角形のクリッピング領域を作成し、 CombineMode.Replace を使用して、その領域をフォームのグラフィックス オブジェクトのクリッピング領域に設定します。
  • クリッピング領域の内側と外側に 1 つずつ配置される 2 つの四角形の位置とサイズを作成します。
  • 各四角形が表示されるかどうかをテストし、表示される四角形だけを描画します。

[Visual Basic, C#] クリップ領域の内側に小さな赤い四角形が 1 つ生成されます。

 
Public Sub IsVisible4Float(e As PaintEventArgs)
' Set clip region.
Dim clipRegion As New [Region](New Rectangle(50, 50, 100, 100))
e.Graphics.SetClip(clipRegion, CombineMode.Replace)
' Set up coordinates of rectangles.
Dim x1 As Single = 100F
Dim y1 As Single = 100F
Dim width1 As Single = 20F
Dim height1 As Single = 20F
Dim x2 As Single = 200F
Dim y2 As Single = 200F
Dim width2 As Single = 20F
Dim height2 As Single = 20F
' If rectangle is visible, fill it.
If e.Graphics.IsVisible(x1, y1, width1, height1) Then
e.Graphics.FillRectangle(New SolidBrush(Color.Red), x1, y1, _
width1, height1)
End If
If e.Graphics.IsVisible(x2, y2, width2, height2) Then
e.Graphics.FillRectangle(New SolidBrush(Color.Blue), x2, y2, _
width2, height2)
End If
End Sub
        
[C#] 
public void IsVisible4Float(PaintEventArgs e)
{
// Set clip region.
Region clipRegion = new Region(new Rectangle(50, 50, 100, 100));
e.Graphics.SetClip(clipRegion, CombineMode.Replace);
// Set up coordinates of rectangles.
float x1 =  100.0F;
float y1 =  100.0F;
float width1 = 20.0F;
float height1 = 20.0F;
float x2 = 200.0F;
float y2 = 200.0F;
float width2 = 20.0F;
float height2 = 20.0F;
// If rectangle is visible, fill it.
if (e.Graphics.IsVisible(x1, y1, width1, height1))
e.Graphics.FillRectangle(new SolidBrush(Color.Red), x1, y1, width1, height1);
if (e.Graphics.IsVisible(x2, y2, width2, height2))
e.Graphics.FillRectangle(new SolidBrush(Color.Blue), x2, y2, width2, height2);
}
        

[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 ファミリ

参照

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