Region.IsVisible 方法

定义

测试指定的矩形是否包含在此 Region中。

重载

IsVisible(Single, Single, Single, Single, Graphics)

使用指定的 Graphics绘制时,测试指定矩形的任何部分是否包含在此 Region 中。

IsVisible(Int32, Int32, Int32, Int32, Graphics)

使用指定的 Graphics绘制时,测试指定矩形的任何部分是否包含在此 Region 中。

IsVisible(Single, Single, Single, Single)

测试指定矩形的任何部分是否包含在此 Region中。

IsVisible(Int32, Int32, Int32, Int32)

测试指定矩形的任何部分是否包含在此 Region中。

IsVisible(Single, Single, Graphics)

使用指定的 Graphics绘制时,测试指定点是否包含在此 Region 中。

IsVisible(Int32, Int32, Graphics)

使用指定的 Graphics 对象绘制时,测试指定点是否包含在此 Region 对象中。

IsVisible(Single, Single)

测试指定点是否包含在此 Region中。

IsVisible(Point)

测试指定的 Point 结构是否包含在此 Region中。

IsVisible(Rectangle, Graphics)

使用指定的 Graphics绘制时,测试指定 Rectangle 结构的任何部分是否包含在此 Region 中。

IsVisible(PointF, Graphics)

使用指定的 Graphics绘制时,测试指定的 PointF 结构是否包含在此 Region 中。

IsVisible(Point, Graphics)

使用指定的 Graphics绘制时,测试指定的 Point 结构是否包含在此 Region 中。

IsVisible(RectangleF)

测试指定 RectangleF 结构的任何部分是否包含在此 Region中。

IsVisible(Rectangle)

测试指定 Rectangle 结构的任何部分是否包含在此 Region中。

IsVisible(PointF)

测试指定的 PointF 结构是否包含在此 Region中。

IsVisible(RectangleF, Graphics)

使用指定的 Graphics绘制时,测试指定 RectangleF 结构的任何部分是否包含在此 Region 中。

IsVisible(Single, Single, Single, Single, Graphics)

Source:
Region.cs
Source:
Region.cs
Source:
Region.cs
Source:
Region.cs
Source:
Region.cs

使用指定的 Graphics绘制时,测试指定矩形的任何部分是否包含在此 Region 中。

public bool IsVisible (float x, float y, float width, float height, System.Drawing.Graphics? g);
public bool IsVisible (float x, float y, float width, float height, System.Drawing.Graphics g);

参数

x
Single

要测试的矩形左上角的 x 坐标。

y
Single

要测试的矩形左上角的 y 坐标。

width
Single

要测试的矩形的宽度。

height
Single

要测试的矩形的高度。

g
Graphics

表示图形上下文的 Graphics

返回

在此 Region中包含指定矩形的任何部分时,true;否则,false

示例

有关代码示例,请参阅 IsVisible(RectangleF) 方法。

注解

图形上下文的当前转换用于计算绘图图面上的区域内部坐标和矩形坐标。

适用于

.NET 9 和其他版本
产品 版本
.NET 6, 7, 8, 9
.NET Framework 1.1, 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
.NET Standard 2.0
Windows Desktop 3.0, 3.1, 5, 6, 7, 8, 9

IsVisible(Int32, Int32, Int32, Int32, Graphics)

Source:
Region.cs
Source:
Region.cs
Source:
Region.cs
Source:
Region.cs
Source:
Region.cs

使用指定的 Graphics绘制时,测试指定矩形的任何部分是否包含在此 Region 中。

public bool IsVisible (int x, int y, int width, int height, System.Drawing.Graphics? g);
public bool IsVisible (int x, int y, int width, int height, System.Drawing.Graphics g);

参数

x
Int32

要测试的矩形左上角的 x 坐标。

y
Int32

要测试的矩形左上角的 y 坐标。

width
Int32

要测试的矩形的宽度。

height
Int32

要测试的矩形的高度。

g
Graphics

表示图形上下文的 Graphics

返回

在此 Region中包含指定矩形的任何部分时,true;否则,false

示例

有关代码示例,请参阅 IsVisible(RectangleF) 方法。

注解

图形上下文的当前转换用于计算绘图图面上的区域内部坐标和矩形坐标。

适用于

.NET 9 和其他版本
产品 版本
.NET 6, 7, 8, 9
.NET Framework 1.1, 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
.NET Standard 2.0
Windows Desktop 3.0, 3.1, 5, 6, 7, 8, 9

IsVisible(Single, Single, Single, Single)

Source:
Region.cs
Source:
Region.cs
Source:
Region.cs
Source:
Region.cs
Source:
Region.cs

测试指定矩形的任何部分是否包含在此 Region中。

public bool IsVisible (float x, float y, float width, float height);

参数

x
Single

要测试的矩形左上角的 x 坐标。

y
Single

要测试的矩形左上角的 y 坐标。

width
Single

要测试的矩形的宽度。

height
Single

要测试的矩形的高度。

返回

在此 Region 对象中包含指定矩形的任何部分时,true;否则,false

示例

有关代码示例,请参阅 IsVisible(RectangleF) 方法。

适用于

.NET 9 和其他版本
产品 版本
.NET 6, 7, 8, 9
.NET Framework 1.1, 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
.NET Standard 2.0
Windows Desktop 3.0, 3.1, 5, 6, 7, 8, 9

IsVisible(Int32, Int32, Int32, Int32)

Source:
Region.cs
Source:
Region.cs
Source:
Region.cs
Source:
Region.cs
Source:
Region.cs

测试指定矩形的任何部分是否包含在此 Region中。

public bool IsVisible (int x, int y, int width, int height);

参数

x
Int32

要测试的矩形左上角的 x 坐标。

y
Int32

要测试的矩形左上角的 y 坐标。

width
Int32

要测试的矩形的宽度。

height
Int32

要测试的矩形的高度。

返回

在此 Region中包含指定矩形的任何部分时,true;否则,false

示例

有关代码示例,请参阅 IsVisible(RectangleF) 方法。

适用于

.NET 9 和其他版本
产品 版本
.NET 6, 7, 8, 9
.NET Framework 1.1, 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
.NET Standard 2.0
Windows Desktop 3.0, 3.1, 5, 6, 7, 8, 9

IsVisible(Single, Single, Graphics)

Source:
Region.cs
Source:
Region.cs
Source:
Region.cs
Source:
Region.cs
Source:
Region.cs

使用指定的 Graphics绘制时,测试指定点是否包含在此 Region 中。

public bool IsVisible (float x, float y, System.Drawing.Graphics? g);
public bool IsVisible (float x, float y, System.Drawing.Graphics g);

参数

x
Single

要测试的点的 x 坐标。

y
Single

要测试的点的 y 坐标。

g
Graphics

表示图形上下文的 Graphics

返回

在此 Region中包含指定点时,true ;否则,false

示例

有关代码示例,请参阅 IsVisible(RectangleF) 方法。

注解

图形上下文的当前转换用于计算绘图图面上的区域内部坐标和点坐标。

适用于

.NET 9 和其他版本
产品 版本
.NET 6, 7, 8, 9
.NET Framework 1.1, 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
.NET Standard 2.0
Windows Desktop 3.0, 3.1, 5, 6, 7, 8, 9

IsVisible(Int32, Int32, Graphics)

Source:
Region.cs
Source:
Region.cs
Source:
Region.cs
Source:
Region.cs
Source:
Region.cs

使用指定的 Graphics 对象绘制时,测试指定点是否包含在此 Region 对象中。

public bool IsVisible (int x, int y, System.Drawing.Graphics? g);
public bool IsVisible (int x, int y, System.Drawing.Graphics g);

参数

x
Int32

要测试的点的 x 坐标。

y
Int32

要测试的点的 y 坐标。

g
Graphics

表示图形上下文的 Graphics

返回

在此 Region中包含指定点时,true ;否则,false

示例

有关代码示例,请参阅 IsVisible(RectangleF) 方法。

注解

图形上下文的当前转换用于计算绘图图面上的区域内部坐标和点坐标。

适用于

.NET 9 和其他版本
产品 版本
.NET 6, 7, 8, 9
.NET Framework 1.1, 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
.NET Standard 2.0
Windows Desktop 3.0, 3.1, 5, 6, 7, 8, 9

IsVisible(Single, Single)

Source:
Region.cs
Source:
Region.cs
Source:
Region.cs
Source:
Region.cs
Source:
Region.cs

测试指定点是否包含在此 Region中。

public bool IsVisible (float x, float y);

参数

x
Single

要测试的点的 x 坐标。

y
Single

要测试的点的 y 坐标。

返回

在此 Region中包含指定点时,true ;否则,false

示例

有关代码示例,请参阅 IsVisible(RectangleF) 方法。

适用于

.NET 9 和其他版本
产品 版本
.NET 6, 7, 8, 9
.NET Framework 1.1, 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
.NET Standard 2.0
Windows Desktop 3.0, 3.1, 5, 6, 7, 8, 9

IsVisible(Point)

Source:
Region.cs
Source:
Region.cs
Source:
Region.cs
Source:
Region.cs
Source:
Region.cs

测试指定的 Point 结构是否包含在此 Region中。

public bool IsVisible (System.Drawing.Point point);

参数

point
Point

要测试的 Point 结构。

返回

在此 Region中包含 point 时,true;否则,false

示例

有关代码示例,请参阅 IsVisible(RectangleF) 方法。

适用于

.NET 9 和其他版本
产品 版本
.NET 6, 7, 8, 9
.NET Framework 1.1, 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
.NET Standard 2.0
Windows Desktop 3.0, 3.1, 5, 6, 7, 8, 9

IsVisible(Rectangle, Graphics)

Source:
Region.cs
Source:
Region.cs
Source:
Region.cs
Source:
Region.cs
Source:
Region.cs

使用指定的 Graphics绘制时,测试指定 Rectangle 结构的任何部分是否包含在此 Region 中。

public bool IsVisible (System.Drawing.Rectangle rect, System.Drawing.Graphics? g);
public bool IsVisible (System.Drawing.Rectangle rect, System.Drawing.Graphics g);

参数

rect
Rectangle

要测试的 Rectangle 结构。

g
Graphics

表示图形上下文的 Graphics

返回

在此 Region中包含 rect 的任何部分时,true;否则,false

示例

有关代码示例,请参阅 IsVisible(RectangleF) 方法。

注解

图形上下文的当前转换用于计算绘图图面上的区域内部坐标和矩形坐标。

适用于

.NET 9 和其他版本
产品 版本
.NET 6, 7, 8, 9
.NET Framework 1.1, 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
.NET Standard 2.0
Windows Desktop 3.0, 3.1, 5, 6, 7, 8, 9

IsVisible(PointF, Graphics)

Source:
Region.cs
Source:
Region.cs
Source:
Region.cs
Source:
Region.cs
Source:
Region.cs

使用指定的 Graphics绘制时,测试指定的 PointF 结构是否包含在此 Region 中。

public bool IsVisible (System.Drawing.PointF point, System.Drawing.Graphics? g);
public bool IsVisible (System.Drawing.PointF point, System.Drawing.Graphics g);

参数

point
PointF

要测试的 PointF 结构。

g
Graphics

表示图形上下文的 Graphics

返回

在此 Region中包含 point 时,true;否则,false

示例

有关代码示例,请参阅 IsVisible(RectangleF) 方法。

注解

图形上下文的当前转换用于计算绘图图面上的区域内部坐标和点坐标。

适用于

.NET 9 和其他版本
产品 版本
.NET 6, 7, 8, 9
.NET Framework 1.1, 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
.NET Standard 2.0
Windows Desktop 3.0, 3.1, 5, 6, 7, 8, 9

IsVisible(Point, Graphics)

Source:
Region.cs
Source:
Region.cs
Source:
Region.cs
Source:
Region.cs
Source:
Region.cs

使用指定的 Graphics绘制时,测试指定的 Point 结构是否包含在此 Region 中。

public bool IsVisible (System.Drawing.Point point, System.Drawing.Graphics? g);
public bool IsVisible (System.Drawing.Point point, System.Drawing.Graphics g);

参数

point
Point

要测试的 Point 结构。

g
Graphics

表示图形上下文的 Graphics

返回

在此 Region中包含 point 时,true;否则,false

示例

有关代码示例,请参阅 IsVisible(RectangleF) 方法。

注解

图形上下文的当前转换用于计算绘图图面上的区域内部坐标和点坐标。

适用于

.NET 9 和其他版本
产品 版本
.NET 6, 7, 8, 9
.NET Framework 1.1, 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
.NET Standard 2.0
Windows Desktop 3.0, 3.1, 5, 6, 7, 8, 9

IsVisible(RectangleF)

Source:
Region.cs
Source:
Region.cs
Source:
Region.cs
Source:
Region.cs
Source:
Region.cs

测试指定 RectangleF 结构的任何部分是否包含在此 Region中。

public bool IsVisible (System.Drawing.RectangleF rect);

参数

rect
RectangleF

要测试的 RectangleF 结构。

返回

在此 Region中包含 rect 的任何部分时,true;否则,false

示例

下面的代码示例设计用于 Windows 窗体,它需要 PaintEventArgse,这是 Paint 事件处理程序的参数。 该代码执行以下操作:

  • 创建第一个矩形并将其绘制到蓝色屏幕。

  • 创建第二个矩形并将其绘制到红色屏幕。

  • 从第一个矩形创建区域。

  • 确定矩形的任何部分是否与该区域相交。

  • 在屏幕上显示 truefalse 结果。

请注意,矩形与区域相交,因此结果 true

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));
}

适用于

.NET 9 和其他版本
产品 版本
.NET 6, 7, 8, 9
.NET Framework 1.1, 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
.NET Standard 2.0
Windows Desktop 3.0, 3.1, 5, 6, 7, 8, 9

IsVisible(Rectangle)

Source:
Region.cs
Source:
Region.cs
Source:
Region.cs
Source:
Region.cs
Source:
Region.cs

测试指定 Rectangle 结构的任何部分是否包含在此 Region中。

public bool IsVisible (System.Drawing.Rectangle rect);

参数

rect
Rectangle

要测试的 Rectangle 结构。

返回

此方法在此 Region中包含 rect 的任何部分时返回 true;否则,false

示例

有关代码示例,请参阅 IsVisible(RectangleF) 方法。

适用于

.NET 9 和其他版本
产品 版本
.NET 6, 7, 8, 9
.NET Framework 1.1, 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
.NET Standard 2.0
Windows Desktop 3.0, 3.1, 5, 6, 7, 8, 9

IsVisible(PointF)

Source:
Region.cs
Source:
Region.cs
Source:
Region.cs
Source:
Region.cs
Source:
Region.cs

测试指定的 PointF 结构是否包含在此 Region中。

public bool IsVisible (System.Drawing.PointF point);

参数

point
PointF

要测试的 PointF 结构。

返回

在此 Region中包含 point 时,true;否则,false

示例

有关代码示例,请参阅 IsVisible(RectangleF) 方法。

适用于

.NET 9 和其他版本
产品 版本
.NET 6, 7, 8, 9
.NET Framework 1.1, 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
.NET Standard 2.0
Windows Desktop 3.0, 3.1, 5, 6, 7, 8, 9

IsVisible(RectangleF, Graphics)

Source:
Region.cs
Source:
Region.cs
Source:
Region.cs
Source:
Region.cs
Source:
Region.cs

使用指定的 Graphics绘制时,测试指定 RectangleF 结构的任何部分是否包含在此 Region 中。

public bool IsVisible (System.Drawing.RectangleF rect, System.Drawing.Graphics? g);
public bool IsVisible (System.Drawing.RectangleF rect, System.Drawing.Graphics g);

参数

rect
RectangleF

要测试的 RectangleF 结构。

g
Graphics

表示图形上下文的 Graphics

返回

在此 Region中包含 rect 时,true;否则,false

示例

有关代码示例,请参阅 IsVisible(RectangleF) 方法。

注解

图形上下文的当前转换用于计算绘图图面上的区域内部坐标和矩形坐标。

适用于

.NET 9 和其他版本
产品 版本
.NET 6, 7, 8, 9
.NET Framework 1.1, 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
.NET Standard 2.0
Windows Desktop 3.0, 3.1, 5, 6, 7, 8, 9