次の方法で共有


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

座標ペアで指定された点が、 Graphics オブジェクトの表示クリップ領域内にあるかどうかを示します。

Overloads Public Function IsVisible( _
   ByVal x As Integer, _   ByVal y As Integer _) As Boolean
[C#]
public bool IsVisible(intx,inty);
[C++]
public: bool IsVisible(intx,inty);
[JScript]
public function IsVisible(
   x : int,y : int) : Boolean;

パラメータ

  • x
    表示可能範囲をテストする点の x 座標。
  • y
    表示可能範囲をテストする点の y 座標。

戻り値

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

使用例

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

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

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

 
Public Sub IsVisibleInt(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 points.
Dim x1 As Integer = 100
Dim y1 As Integer = 100
Dim x2 As Integer = 200
Dim y2 As Integer = 200
' If point is visible, fill ellipse that represents it.
If e.Graphics.IsVisible(x1, y1) Then
e.Graphics.FillEllipse(New SolidBrush(Color.Red), x1, y1, _
10, 10)
End If
If e.Graphics.IsVisible(x2, y2) Then
e.Graphics.FillEllipse(New SolidBrush(Color.Blue), x2, y2, _
10, 10)
End If
End Sub
        
[C#] 
public void IsVisibleInt(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 points.
int x1 = 100;
int y1 = 100;
int x2 = 200;
int y2 = 200;
// If point is visible, fill ellipse that represents it.
if (e.Graphics.IsVisible(x1, y1))
e.Graphics.FillEllipse(new SolidBrush(Color.Red), x1, y1, 10, 10);
if (e.Graphics.IsVisible(x2, y2))
e.Graphics.FillEllipse(new SolidBrush(Color.Blue), x2, y2, 10, 10);
}
        

[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 オーバーロードの一覧