RegionData Classe

Definição

Encapsula os dados que compõem um objeto Region. Essa classe não pode ser herdada.

public ref class RegionData sealed
public sealed class RegionData
type RegionData = class
Public NotInheritable Class RegionData
Herança
RegionData

Exemplos

O exemplo a seguir foi projetado para uso com Windows Forms e requer PaintEventArgse, que é um parâmetro do Paint manipulador de eventos. O código executa as seguintes ações:

  • Cria um retângulo e o desenha na tela em preto.

  • Cria uma região usando o retângulo .

  • Obtém o RegionData.

  • Desenha os dados da região (uma matriz de bytes) para a tela, usando a função auxiliar DisplayRegionData.

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

Propriedades

Data

Obtém ou define uma matriz de bytes que especifica o objeto Region.

Métodos

Equals(Object)

Determina se o objeto especificado é igual ao objeto atual.

(Herdado de Object)
GetHashCode()

Serve como a função de hash padrão.

(Herdado de Object)
GetType()

Obtém o Type da instância atual.

(Herdado de Object)
MemberwiseClone()

Cria uma cópia superficial do Object atual.

(Herdado de Object)
ToString()

Retorna uma cadeia de caracteres que representa o objeto atual.

(Herdado de Object)

Aplica-se a