RegionData Class
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Encapsulates the data that makes up a Region object. This class cannot be inherited.
public ref class RegionData sealed
public sealed class RegionData
type RegionData = class
Public NotInheritable Class RegionData
- Inheritance
-
RegionData
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 rectangle and draw its to the screen in black.
Creates a region using the rectangle.
Gets the RegionData.
Draws the region data (an array of bytes) to the screen, by using the DisplayRegionData helper function.
public:
void GetRegionDataExample( PaintEventArgs^ e )
{
// Create a rectangle and draw it to the screen in black.
Rectangle regionRect = Rectangle(20,20,100,100);
e->Graphics->DrawRectangle( Pens::Black, regionRect );
// Create a region using the first rectangle.
System::Drawing::Region^ myRegion = gcnew System::Drawing::Region( regionRect );
// Get the RegionData for this region.
RegionData^ myRegionData = myRegion->GetRegionData();
int myRegionDataLength = myRegionData->Data->Length;
DisplayRegionData( e, myRegionDataLength, myRegionData );
}
// THIS IS A HELPER FUNCTION FOR GetRegionData.
void DisplayRegionData( PaintEventArgs^ e, int len, RegionData^ dat )
{
// Display the result.
int i;
float x = 20,y = 140;
System::Drawing::Font^ myFont = gcnew System::Drawing::Font( "Arial",8 );
SolidBrush^ myBrush = gcnew SolidBrush( Color::Black );
e->Graphics->DrawString( "myRegionData = ", myFont, myBrush, PointF(x,y) );
y = 160;
for ( i = 0; i < len; i++ )
{
if ( x > 300 )
{
y += 20;
x = 20;
}
e->Graphics->DrawString( dat->Data[ i ].ToString(), myFont, myBrush, PointF(x,y) );
x += 30;
}
}
public void GetRegionDataExample(PaintEventArgs e)
{
// Create a rectangle and draw it to the screen in black.
Rectangle regionRect = new Rectangle(20, 20, 100, 100);
e.Graphics.DrawRectangle(Pens.Black, regionRect);
// Create a region using the first rectangle.
Region myRegion = new Region(regionRect);
// Get the RegionData for this region.
RegionData myRegionData = myRegion.GetRegionData();
int myRegionDataLength = myRegionData.Data.Length;
DisplayRegionData(e, myRegionDataLength, myRegionData);
}
// THIS IS A HELPER FUNCTION FOR GetRegionData.
public void DisplayRegionData(PaintEventArgs e,
int len,
RegionData dat)
{
// Display the result.
int i;
float x = 20, y = 140;
Font myFont = new Font("Arial", 8);
SolidBrush myBrush = new SolidBrush(Color.Black);
e.Graphics.DrawString("myRegionData = ",
myFont,
myBrush,
new PointF(x, y));
y = 160;
for(i = 0; i < len; i++)
{
if(x > 300)
{
y += 20;
x = 20;
}
e.Graphics.DrawString(dat.Data[i].ToString(),
myFont,
myBrush,
new PointF(x, y));
x += 30;
}
}
Public Sub GetRegionDataExample(ByVal e As PaintEventArgs)
' Create the first rectangle and draw it to the screen in black.
Dim regionRect As New Rectangle(20, 20, 100, 100)
e.Graphics.DrawRectangle(Pens.Black, regionRect)
' Create a region using the first rectangle.
Dim myRegion As New [Region](regionRect)
' Get the RegionData for this region.
Dim myRegionData As RegionData = myRegion.GetRegionData()
Dim myRegionDataLength As Integer = myRegionData.Data.Length
DisplayRegionData(e, myRegionDataLength, myRegionData)
End Sub
' Helper Function for GetRegionData.
Public Sub DisplayRegionData(ByVal e As PaintEventArgs, ByVal len As Integer, _
ByVal dat As RegionData)
' Display the result.
Dim i As Integer
Dim x As Single = 20
Dim y As Single = 140
Dim myFont As New Font("Arial", 8)
Dim myBrush As New SolidBrush(Color.Black)
e.Graphics.DrawString("myRegionData = ", myFont, myBrush, _
New PointF(x, y))
y = 160
For i = 0 To len - 1
If x > 300 Then
y += 20
x = 20
End If
e.Graphics.DrawString(dat.Data(i).ToString(), myFont, _
myBrush, New PointF(x, y))
x += 30
Next i
End Sub
Equals(Object) |
Determines whether the specified object is equal to the current object. (Inherited from Object) |
Get |
Serves as the default hash function. (Inherited from Object) |
Get |
Gets the Type of the current instance. (Inherited from Object) |
Memberwise |
Creates a shallow copy of the current Object. (Inherited from Object) |
To |
Returns a string that represents the current object. (Inherited from Object) |
Product | Versions |
---|---|
.NET | 8 (package-provided), 9 (package-provided) |
.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 (package-provided), 4.7, 4.7.1 (package-provided), 4.7.1, 4.7.2 (package-provided), 4.7.2, 4.8 (package-provided), 4.8, 4.8.1 |
.NET Standard | 2.0 (package-provided) |
Windows Desktop | 3.0, 3.1, 5, 6, 7, 8, 9 |
.NET feedback
.NET is an open source project. Select a link to provide feedback: