- 1). Open the VB.NET file in an editor such as Microsoft Visual Studio Express.
- 2). Create a rectangular region by adding the following code in your function:
Dim rect_region As New Region(New Rectangle(10, 10, 50, 50)) - 3). Create a "GraphicsPath" object that you can use to draw on and add shapes to by adding the code:
Dim graphics_path As New System.Drawing.Drawing2D.GraphicsPath - 4). Draw a circle onto the graphics path by adding the code:
graphics_path.AddEllipse(40, 40, 20, 20) - 5). Call the "Exclude" method to exclude the circle from the region by adding the code:
rect_region.Exclude(graphics_path)
Future actions on the region will not apply to the excluded circle. - 6). Call the "Dispose" method when you are done using the objects by adding the code:
graphics_path.Dispose()
rect_region.Dispose() - 7). Save the VB.NET file, compile and run the program to view the created region.
SHARE