Graphics.IsVisible Method
Indicates whether the point specified by a pair of coordinates is contained within the visible clip region of this Graphics object.
Overload List
Indicates whether the specified Point structure is contained within the visible clip region of this Graphics object.
[Visual Basic] Overloads Public Function IsVisible(Point) As Boolean
[C#] public bool IsVisible(Point);
[C++] public: bool IsVisible(Point);
[JScript] public function IsVisible(Point) : Boolean;
Indicates whether the specified PointF structure is contained within the visible clip region of this Graphics object.
[Visual Basic] Overloads Public Function IsVisible(PointF) As Boolean
[C#] public bool IsVisible(PointF);
[C++] public: bool IsVisible(PointF);
[JScript] public function IsVisible(PointF) : Boolean;
Indicates whether the rectangle specified by a Rectangle structure is contained within the visible clip region of this Graphics object.
[Visual Basic] Overloads Public Function IsVisible(Rectangle) As Boolean
[C#] public bool IsVisible(Rectangle);
[C++] public: bool IsVisible(Rectangle);
[JScript] public function IsVisible(Rectangle) : Boolean;
Indicates whether the rectangle specified by a RectangleF structure is contained within the visible clip region of this Graphics object.
[Visual Basic] Overloads Public Function IsVisible(RectangleF) As Boolean
[C#] public bool IsVisible(RectangleF);
[C++] public: bool IsVisible(RectangleF);
[JScript] public function IsVisible(RectangleF) : Boolean;
Indicates whether the point specified by a pair of coordinates is contained within the visible clip region of this Graphics object.
[Visual Basic] Overloads Public Function IsVisible(Integer, Integer) As Boolean
[C#] public bool IsVisible(int, int);
[C++] public: bool IsVisible(int, int);
[JScript] public function IsVisible(int, int) : Boolean;
Indicates whether the point specified by a pair of coordinates is contained within the visible clip region of this Graphics object.
[Visual Basic] Overloads Public Function IsVisible(Single, Single) As Boolean
[C#] public bool IsVisible(float, float);
[C++] public: bool IsVisible(float, float);
[JScript] public function IsVisible(float, float) : Boolean;
Indicates whether the rectangle specified by a pair of coordinates, a width, and a height is contained within the visible clip region of this Graphics object.
[Visual Basic] Overloads Public Function IsVisible(Integer, Integer, Integer, Integer) As Boolean
[C#] public bool IsVisible(int, int, int, int);
[C++] public: bool IsVisible(int, int, int, int);
[JScript] public function IsVisible(int, int, int, int) : Boolean;
Indicates whether the rectangle specified by a pair of coordinates, a width, and a height is contained within the visible clip region of this Graphics object.
[Visual Basic] Overloads Public Function IsVisible(Single, Single, Single, Single) As Boolean
[C#] public bool IsVisible(float, float, float, float);
[C++] public: bool IsVisible(float, float, float, float);
[JScript] public function IsVisible(float, float, float, float) : Boolean;
Example
[Visual Basic, C#] The following example is designed for use with Windows Forms, and it requires PaintEventArgs e, which is a parameter of the Paint event handler. The code performs the following actions:
- Creates a rectangular clipping region and sets it as the clipping region for the graphics object of the form using CombineMode.Replace.
- Creates the location and size of two rectangles, one inside the clipping region and one outside.
- Tests each of the rectangles for visibility and draws only the visible one.
[Visual Basic, C#] The result is one small red rectangle, which is within the clip region.
[Visual Basic, C#] Note This example shows how to use one of the overloaded versions of IsVisible. For other examples that might be available, see the individual overload topics.
[Visual Basic] 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] No example is available for C++ or JScript. To view a Visual Basic or C# example, click the Language Filter button
in the upper-left corner of the page.
See Also
Graphics Class | Graphics Members | System.Drawing Namespace