Region クラス

定義

四角形とパスで構成されるグラフィックス形状の内部を示します。 このクラスは継承できません。

public ref class Region sealed : MarshalByRefObject, IDisposable
public sealed class Region : MarshalByRefObject, IDisposable
[System.Runtime.InteropServices.ComVisible(false)]
public sealed class Region : MarshalByRefObject, IDisposable
type Region = class
    inherit MarshalByRefObject
    interface IDisposable
[<System.Runtime.InteropServices.ComVisible(false)>]
type Region = class
    inherit MarshalByRefObject
    interface IDisposable
Public NotInheritable Class Region
Inherits MarshalByRefObject
Implements IDisposable
継承
属性
実装

次のコード例は、Windows フォームで使用するように設計されており、イベント ハンドラーのPaintパラメーターである が必要PaintEventArgseです。 コード例では、あるRegionDataオブジェクトの をData使用して、 を別RegionDataData に設定する方法を示します。

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

注釈

リージョンの座標はワールド座標で指定されるため、スケーラブルです。 ただし、描画サーフェイスでは、その内部は、それを表すピクセルのサイズと形状に依存します。 アプリケーションでは、領域を使用して描画操作の出力をクリップできます。 これらの領域はクリッピング領域と呼ばれます。 領域をクリッピングに使用する方法の詳細については、「 方法: 領域でクリッピングを使用する」を参照してください。

アプリケーションでは、ポイントまたは四角形が領域と交差するかどうかを確認するなど、ヒット テスト操作で領域を使用することもできます。 ヒット テストにリージョンを使用する方法の詳細については、「 方法: リージョンでヒット テストを使用する」を参照してください。

アプリケーションは、 メソッドと オブジェクトを使用 Graphics.FillRegion して領域を Brush 塗りつぶすことができます。

Note

.NET 6 以降のバージョンでは、この種類を含む System.Drawing.Common パッケージは Windows オペレーティング システムでのみサポートされています。 クロスプラットフォーム アプリでこの型を使用すると、コンパイル時の警告と実行時例外が発生します。 詳細については、「 Windows でのみサポートされる System.Drawing.Common」を参照してください。

コンストラクター

Region()

新しい Region を初期化します。

Region(GraphicsPath)

指定した GraphicsPath で新しい Region を初期化します。

Region(Rectangle)

指定の Region 構造体から新しい Rectangle を初期化します。

Region(RectangleF)

指定の Region 構造体から新しい RectangleF を初期化します。

Region(RegionData)

指定したデータから新しい Region を初期化します。

メソッド

Clone()

この Region の同一コピーを作成します。

Complement(GraphicsPath)

この Region と交差しない指定の GraphicsPath の部分が含まれるように、この Region を更新します。

Complement(Rectangle)

この Region と交差しない指定の Rectangle 構造体の部分が含まれるように、この Region を更新します。

Complement(RectangleF)

この Region と交差しない指定の RectangleF 構造体の部分が含まれるように、この Region を更新します。

Complement(Region)

この Region と交差しない指定の Region の部分が含まれるように、この Region を更新します。

CreateObjRef(Type)

リモート オブジェクトとの通信に使用するプロキシの生成に必要な情報をすべて格納しているオブジェクトを作成します。

(継承元 MarshalByRefObject)
Dispose()

この Region によって使用されているすべてのリソースを解放します。

Equals(Object)

指定されたオブジェクトが現在のオブジェクトと等しいかどうかを判断します。

(継承元 Object)
Equals(Region, Graphics)

指定の Region が、指定の描画サーフェイス上のこの Region と同一かどうかをテストします。

Exclude(GraphicsPath)

指定の Region と交差しない内部の部分だけが含まれるよう、この GraphicsPath を更新します。

Exclude(Rectangle)

指定の Region 構造体と交差しない内部の部分だけが含まれるよう、この Rectangle を更新します。

Exclude(RectangleF)

指定の Region 構造体と交差しない内部の部分だけが含まれるよう、この RectangleF を更新します。

Exclude(Region)

指定の Region と交差しない内部の部分だけが含まれるよう、この Region を更新します。

Finalize()

オブジェクトが、ガベージ コレクションによって収集される前に、リソースの解放とその他のクリーンアップ操作の実行を試みることができるようにします。

FromHrgn(IntPtr)

ハンドルから指定した既存の GDI 領域に新しい Region を初期化します。

GetBounds(Graphics)

RectangleF オブジェクトの描画サーフェイスのこの Region に外接する四角形を表す Graphics 構造体を取得します。

GetHashCode()

既定のハッシュ関数として機能します。

(継承元 Object)
GetHrgn(Graphics)

この Region を識別する Windows ハンドルを、指定のグラフィックス コンテキストで返します。

GetLifetimeService()
古い.

対象のインスタンスの有効期間ポリシーを制御する、現在の有効期間サービス オブジェクトを取得します。

(継承元 MarshalByRefObject)
GetRegionData()

この RegionData を説明する情報を表す Region を返します。

GetRegionScans(Matrix)

指定の行列変換が適用された後にこの RectangleF を近似する Region 構造体の配列を返します。

GetType()

現在のインスタンスの Type を取得します。

(継承元 Object)
InitializeLifetimeService()
古い.

このインスタンスの有効期間ポリシーを制御する有効期間サービス オブジェクトを取得します。

(継承元 MarshalByRefObject)
Intersect(GraphicsPath)

この Region をそれ自体と指定の GraphicsPath の交差部分に更新します。

Intersect(Rectangle)

この Region をそれ自体と指定の Rectangle 構造体の交差部分に更新します。

Intersect(RectangleF)

この Region をそれ自体と指定の RectangleF 構造体の交差部分に更新します。

Intersect(Region)

この Region をそれ自体と指定の Region の交差部分に更新します。

IsEmpty(Graphics)

この Region の内部が指定の描画サーフェイスで空になるかどうかをテストします。

IsInfinite(Graphics)

この Region の内部が指定の描画サーフェイスで無限になるかどうかをテストします。

IsVisible(Int32, Int32, Graphics)

指定の Region オブジェクトを使用して描画した場合に、指定の点がこの Graphics オブジェクト内に含まれるかどうかをテストします。

IsVisible(Int32, Int32, Int32, Int32)

指定の四角形の一部が、この Region に含まれているかどうかをテストします。

IsVisible(Int32, Int32, Int32, Int32, Graphics)

指定の Region オブジェクトを使用して描画した場合に、指定の四角形の一部がこの Graphics に含まれるかどうかをテストします。

IsVisible(Point)

指定の Point 構造体がこの Region に含まれているかどうかをテストします。

IsVisible(Point, Graphics)

指定の Point を使用して描画した場合に、指定の Region 構造体がこの Graphics に含まれるかどうかをテストします。

IsVisible(PointF)

指定の PointF 構造体がこの Region に含まれているかどうかをテストします。

IsVisible(PointF, Graphics)

指定の PointF を使用して描画した場合に、指定の Region 構造体がこの Graphics に含まれるかどうかをテストします。

IsVisible(Rectangle)

指定の Rectangle 構造体の一部が、この Region に含まれているかどうかをテストします。

IsVisible(Rectangle, Graphics)

指定の Rectangle を使用して描画した場合に、指定の Region 構造体の一部がこの Graphics に含まれるかどうかをテストします。

IsVisible(RectangleF)

指定の RectangleF 構造体の一部が、この Region に含まれているかどうかをテストします。

IsVisible(RectangleF, Graphics)

指定の RectangleF を使用して描画した場合に、指定の Region 構造体の一部がこの Graphics に含まれるかどうかをテストします。

IsVisible(Single, Single)

指定の点がこの Region に含まれているかどうかをテストします。

IsVisible(Single, Single, Graphics)

指定の Region を使用して描画した場合に、指定の点がこの Graphics に含まれるかどうかをテストします。

IsVisible(Single, Single, Single, Single)

指定の四角形の一部が、この Region に含まれているかどうかをテストします。

IsVisible(Single, Single, Single, Single, Graphics)

指定の Region オブジェクトを使用して描画した場合に、指定の四角形の一部がこの Graphics に含まれるかどうかをテストします。

MakeEmpty()

この Region を初期化して内部を空にします。

MakeInfinite()

この Region オブジェクトを初期化して内部を無限にします。

MemberwiseClone()

現在の Object の簡易コピーを作成します。

(継承元 Object)
MemberwiseClone(Boolean)

現在の MarshalByRefObject オブジェクトの簡易コピーを作成します。

(継承元 MarshalByRefObject)
ReleaseHrgn(IntPtr)

Region のハンドルを解放します。

ToString()

現在のオブジェクトを表す文字列を返します。

(継承元 Object)
Transform(Matrix)

この Region を指定の Matrix で変換します。

Translate(Int32, Int32)

指定した量でこの Region の座標をオフセットします。

Translate(Single, Single)

指定した量でこの Region の座標をオフセットします。

Union(GraphicsPath)

この Region を、それ自体と指定の GraphicsPath の和集合に更新します。

Union(Rectangle)

この Region を、それ自体と指定の Rectangle 構造体の和集合に更新します。

Union(RectangleF)

この Region を、それ自体と指定の RectangleF 構造体の和集合に更新します。

Union(Region)

この Region を、それ自体と指定の Region の和集合に更新します。

Xor(GraphicsPath)

この Region を、それ自体と指定の GraphicsPath の交差部分を差し引いた和集合に更新します。

Xor(Rectangle)

この Region を、それ自体と指定の Rectangle 構造体の交差部分を差し引いた和集合に更新します。

Xor(RectangleF)

この Region を、それ自体と指定の RectangleF 構造体の交差部分を差し引いた和集合に更新します。

Xor(Region)

この Region を、それ自体と指定の Region の交差部分を差し引いた和集合に更新します。

適用対象

こちらもご覧ください