Region.GetRegionData 方法
定义
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
返回一个 RegionData,表示描述此 Region的信息。
public:
System::Drawing::Drawing2D::RegionData ^ GetRegionData();
public System.Drawing.Drawing2D.RegionData? GetRegionData ();
public System.Drawing.Drawing2D.RegionData GetRegionData ();
member this.GetRegionData : unit -> System.Drawing.Drawing2D.RegionData
Public Function GetRegionData () As RegionData
返回
表示描述此 Region的信息的 RegionData。
示例
下面的代码示例设计用于 Windows 窗体,它需要 PaintEventArgse
,这是 Paint 事件处理程序的参数。 该代码示例演示如何使用一个 RegionData 对象的 Data 为另一个 RegionData设置 Data。
private:
void DemonstrateRegionData2( PaintEventArgs^ e )
{
//Create a simple region.
System::Drawing::Region^ region1 = gcnew System::Drawing::Region( Rectangle(10,10,100,100) );
// Extract the region data.
System::Drawing::Drawing2D::RegionData^ region1Data = region1->GetRegionData();
array<Byte>^data1;
data1 = region1Data->Data;
// Create a second region.
System::Drawing::Region^ region2 = gcnew System::Drawing::Region;
// Get the region data for the second region.
System::Drawing::Drawing2D::RegionData^ region2Data = region2->GetRegionData();
// Set the Data property for the second region to the Data from the first region.
region2Data->Data = data1;
// Construct a third region using the modified RegionData of the second region.
System::Drawing::Region^ region3 = gcnew System::Drawing::Region( region2Data );
// Dispose of the first and second regions.
delete region1;
delete region2;
// Call ExcludeClip passing in the third region.
e->Graphics->ExcludeClip( region3 );
// Fill in the client rectangle.
e->Graphics->FillRectangle( Brushes::Red, this->ClientRectangle );
delete region3;
}
private void DemonstrateRegionData2(PaintEventArgs e)
{
//Create a simple region.
Region region1 = new Region(new Rectangle(10, 10, 100, 100));
// Extract the region data.
System.Drawing.Drawing2D.RegionData region1Data = region1.GetRegionData();
byte[] data1;
data1 = region1Data.Data;
// Create a second region.
Region region2 = new Region();
// Get the region data for the second region.
System.Drawing.Drawing2D.RegionData region2Data = region2.GetRegionData();
// Set the Data property for the second region to the Data from the first region.
region2Data.Data = data1;
// Construct a third region using the modified RegionData of the second region.
Region region3 = new Region(region2Data);
// Dispose of the first and second regions.
region1.Dispose();
region2.Dispose();
// Call ExcludeClip passing in the third region.
e.Graphics.ExcludeClip(region3);
// Fill in the client rectangle.
e.Graphics.FillRectangle(Brushes.Red, this.ClientRectangle);
region3.Dispose();
}
Private Sub DemonstrateRegionData2(ByVal e As PaintEventArgs)
'Create a simple region.
Dim region1 As New Region(New Rectangle(10, 10, 100, 100))
' Extract the region data.
Dim region1Data As System.Drawing.Drawing2D.RegionData = region1.GetRegionData
Dim data1() As Byte
data1 = region1Data.Data
' Create a second region.
Dim region2 As New Region
' Get the region data for the second region.
Dim region2Data As System.Drawing.Drawing2D.RegionData = region2.GetRegionData()
' Set the Data property for the second region to the Data from the first region.
region2Data.Data = data1
' Construct a third region using the modified RegionData of the second region.
Dim region3 As New Region(region2Data)
' Dispose of the first and second regions.
region1.Dispose()
region2.Dispose()
' Call ExcludeClip passing in the third region.
e.Graphics.ExcludeClip(region3)
' Fill in the client rectangle.
e.Graphics.FillRectangle(Brushes.Red, Me.ClientRectangle)
region3.Dispose()
End Sub
注解
使用 Region 类可以定义自定义形状。 形状可以由线条、多边形和曲线组成。 GetRegionData 描述此 Region中包含的形状。