Region.Exclude メソッド

定義

この Region を、指定の Rectangle 構造体と交差しない内部の部分に更新します。

オーバーロード

Exclude(Region)

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

Exclude(GraphicsPath)

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

Exclude(Rectangle)

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

Exclude(RectangleF)

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

Exclude(Region)

ソース:
Region.cs
ソース:
Region.cs
ソース:
Region.cs

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

public:
 void Exclude(System::Drawing::Region ^ region);
public void Exclude (System.Drawing.Region region);
member this.Exclude : System.Drawing.Region -> unit
Public Sub Exclude (region As Region)

パラメーター

region
Region

この Region から除外する Region

例外

regionnullです。

コード例については、 メソッドと Complement(Region) メソッドをExclude(RectangleF)参照してください。

適用対象

Exclude(GraphicsPath)

ソース:
Region.cs
ソース:
Region.cs
ソース:
Region.cs

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

public:
 void Exclude(System::Drawing::Drawing2D::GraphicsPath ^ path);
public void Exclude (System.Drawing.Drawing2D.GraphicsPath path);
member this.Exclude : System.Drawing.Drawing2D.GraphicsPath -> unit
Public Sub Exclude (path As GraphicsPath)

パラメーター

path
GraphicsPath

この GraphicsPath から除外する Region

例外

pathnullです。

次のコード例では、Regionコンストラクターと メソッドと Dispose メソッドをExclude示します。

この例は、Windows フォームで使用するように設計されています。 フォームにコードを貼り付け、フォームのイベントをFillRegionExcludingPath処理するときに メソッドをPaint呼び出し、 を としてPaintEventArgs渡しますe

private:
   void FillRegionExcludingPath( PaintEventArgs^ e )
   {
      // Create the region using a rectangle.
      System::Drawing::Region^ myRegion = gcnew System::Drawing::Region( Rectangle(20,20,100,100) );

      // Create the GraphicsPath.
      System::Drawing::Drawing2D::GraphicsPath^ path = gcnew System::Drawing::Drawing2D::GraphicsPath;

      // Add a circle to the graphics path.
      path->AddEllipse( 50, 50, 25, 25 );

      // Exclude the circle from the region.
      myRegion->Exclude( path );

      // Retrieve a Graphics object from the form.
      Graphics^ formGraphics = e->Graphics;

      // Fill the region in blue.
      formGraphics->FillRegion( Brushes::Blue, myRegion );

      // Dispose of the path and region objects.
      delete path;
      delete myRegion;
   }
private void FillRegionExcludingPath(PaintEventArgs e)
{

    // Create the region using a rectangle.
    Region myRegion = new Region(new Rectangle(20, 20, 100, 100));

    // Create the GraphicsPath.
    System.Drawing.Drawing2D.GraphicsPath path = 
        new System.Drawing.Drawing2D.GraphicsPath();

    // Add a circle to the graphics path.
    path.AddEllipse(50, 50, 25, 25);

    // Exclude the circle from the region.
    myRegion.Exclude(path);

    // Retrieve a Graphics object from the form.
    Graphics formGraphics = e.Graphics;

    // Fill the region in blue.
    formGraphics.FillRegion(Brushes.Blue, myRegion);

    // Dispose of the path and region objects.
    path.Dispose();
    myRegion.Dispose();
}
Private Sub FillRegionExcludingPath(ByVal e As PaintEventArgs)

    ' Create the region using a rectangle.
    Dim myRegion As New Region(New Rectangle(20, 20, 100, 100))

    ' Create the GraphicsPath.
    Dim path As New System.Drawing.Drawing2D.GraphicsPath

    ' Add a circle to the graphics path.
    path.AddEllipse(50, 50, 25, 25)

    ' Exclude the circle from the region.
    myRegion.Exclude(path)

    ' Retrieve a Graphics object from the form.
    Dim formGraphics As Graphics = e.Graphics

    ' Fill the region in blue.
    formGraphics.FillRegion(Brushes.Blue, myRegion)

    ' Dispose of the path and region objects.
    path.Dispose()
    myRegion.Dispose()

End Sub

適用対象

Exclude(Rectangle)

ソース:
Region.cs
ソース:
Region.cs
ソース:
Region.cs

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

public:
 void Exclude(System::Drawing::Rectangle rect);
public void Exclude (System.Drawing.Rectangle rect);
member this.Exclude : System.Drawing.Rectangle -> unit
Public Sub Exclude (rect As Rectangle)

パラメーター

rect
Rectangle

この Rectangle から除外する Region 構造体。

コード例については、 メソッドを Exclude(RectangleF) 参照してください。

適用対象

Exclude(RectangleF)

ソース:
Region.cs
ソース:
Region.cs
ソース:
Region.cs

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

public:
 void Exclude(System::Drawing::RectangleF rect);
public void Exclude (System.Drawing.RectangleF rect);
member this.Exclude : System.Drawing.RectangleF -> unit
Public Sub Exclude (rect As RectangleF)

パラメーター

rect
RectangleF

この RectangleF から除外する Region 構造体。

次の例は、Windows フォームで使用するように設計されており、イベント ハンドラーのPaintパラメーターである が必要PaintEventArgseです。 コードは、次のアクションを実行します。

  • 四角形を作成し、黒で画面に描画します

  • 1 つ目と交差する 2 番目の四角形を作成し、それを赤で画面に描画します。

  • 最初の四角形を使用して領域を作成します。

  • 2 番目の四角形と組み合わせた場合に、領域の存在しない領域を取得します。

  • 存在しない領域を青で塗りつぶし、画面に描画します。

四角形と交差しない領域の領域は青に色付けされていることに注意してください。

public:
   void Exclude_RectF_Example( PaintEventArgs^ e )
   {
      // Create the first rectangle and draw it to the screen in black.
      Rectangle regionRect = Rectangle(20,20,100,100);
      e->Graphics->DrawRectangle( Pens::Black, regionRect );

      // Create the second rectangle and draw it to the screen in red.
      RectangleF complementRect = RectangleF(90,30,100,100);
      e->Graphics->DrawRectangle( Pens::Red, Rectangle::Round( complementRect ) );

      // Create a region using the first rectangle.
      System::Drawing::Region^ myRegion = gcnew System::Drawing::Region( regionRect );

      // Get the nonexcluded area of myRegion when combined with
      // complementRect.
      myRegion->Exclude( complementRect );
      
      // Fill the nonexcluded area of myRegion with blue.
      SolidBrush^ myBrush = gcnew SolidBrush( Color::Blue );
      e->Graphics->FillRegion( myBrush, myRegion );
   }
public void Exclude_RectF_Example(PaintEventArgs e)
{
             
    // Create the first rectangle and draw it to the screen in black.
    Rectangle regionRect = new Rectangle(20, 20, 100, 100);
    e.Graphics.DrawRectangle(Pens.Black, regionRect);
             
    // Create the second rectangle and draw it to the screen in red.
    RectangleF complementRect = new RectangleF(90, 30, 100, 100);
    e.Graphics.DrawRectangle(Pens.Red,
        Rectangle.Round(complementRect));
             
    // Create a region using the first rectangle.
    Region myRegion = new Region(regionRect);
             
    // Get the nonexcluded area of myRegion when combined with
             
    // complementRect.
    myRegion.Exclude(complementRect);
             
    // Fill the nonexcluded area of myRegion with blue.
    SolidBrush myBrush = new SolidBrush(Color.Blue);
    e.Graphics.FillRegion(myBrush, myRegion);
}
Public Sub Exclude_RectF_Example(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 the second rectangle and draw it to the screen in red.
    Dim complementRect As New RectangleF(90, 30, 100, 100)
    e.Graphics.DrawRectangle(Pens.Red, _
    Rectangle.Round(complementRect))

    ' Create a region using the first rectangle.
    Dim myRegion As New [Region](regionRect)

    ' Get the nonexcluded area of myRegion when combined with
    ' complementRect.
    myRegion.Exclude(complementRect)

    ' Fill the nonexcluded area of myRegion with blue.
    Dim myBrush As New SolidBrush(Color.Blue)
    e.Graphics.FillRegion(myBrush, myRegion)
End Sub

適用対象