Teilen über


Graphics.SetClip Methode

Definition

Legt den Beschneidungsbereich dieses Graphics auf die Clip-Eigenschaft der angegebenen Graphicsfest.

Überlädt

SetClip(Region, CombineMode)

Legt den Clippingbereich dieser Graphics auf das Ergebnis des angegebenen Vorgangs fest, der den aktuellen Clipbereich und die angegebene Regionkombiniert.

SetClip(RectangleF, CombineMode)

Legt den Beschneidungsbereich dieses Graphics auf das Ergebnis des angegebenen Vorgangs fest, der den aktuellen Clipbereich und das durch eine RectangleF Struktur angegebene Rechteck kombiniert.

SetClip(Rectangle, CombineMode)

Legt den Beschneidungsbereich dieses Graphics auf das Ergebnis des angegebenen Vorgangs fest, der den aktuellen Clipbereich und das durch eine Rectangle Struktur angegebene Rechteck kombiniert.

SetClip(Graphics, CombineMode)

Legt den Clippingbereich dieser Graphics auf das Ergebnis des angegebenen Kombinationsvorgangs des aktuellen Clipbereichs und der Clip-Eigenschaft der angegebenen Graphicsfest.

SetClip(RectangleF)

Legt den Beschneidungsbereich dieses Graphics auf das durch eine RectangleF Struktur angegebene Rechteck fest.

SetClip(Rectangle)

Legt den Beschneidungsbereich dieses Graphics auf das durch eine Rectangle Struktur angegebene Rechteck fest.

SetClip(Graphics)

Legt den Beschneidungsbereich dieses Graphics auf die Clip-Eigenschaft der angegebenen Graphicsfest.

SetClip(GraphicsPath)

Legt den Beschneidungsbereich dieses Graphics auf die angegebene GraphicsPathfest.

SetClip(GraphicsPath, CombineMode)

Legt den Clippingbereich dieser Graphics auf das Ergebnis des angegebenen Vorgangs fest, der den aktuellen Clipbereich und die angegebene GraphicsPathkombiniert.

SetClip(Region, CombineMode)

Quelle:
Graphics.cs
Quelle:
Graphics.cs
Quelle:
Graphics.cs
Quelle:
Graphics.cs
Quelle:
Graphics.cs

Legt den Clippingbereich dieser Graphics auf das Ergebnis des angegebenen Vorgangs fest, der den aktuellen Clipbereich und die angegebene Regionkombiniert.

public:
 void SetClip(System::Drawing::Region ^ region, System::Drawing::Drawing2D::CombineMode combineMode);
public void SetClip (System.Drawing.Region region, System.Drawing.Drawing2D.CombineMode combineMode);
member this.SetClip : System.Drawing.Region * System.Drawing.Drawing2D.CombineMode -> unit
Public Sub SetClip (region As Region, combineMode As CombineMode)

Parameter

region
Region

Region kombinieren.

combineMode
CombineMode

Member aus der CombineMode-Aufzählung, die den zu verwendenden Kombinationsvorgang angibt.

Beispiele

Das folgende Codebeispiel wurde für die Verwendung mit Windows Forms entwickelt und erfordert PaintEventArgse, bei dem es sich um einen Parameter des Paint-Ereignishandlers handelt. Der Code führt die folgenden Aktionen aus:

  • Erstellt ein kleines Rechteck für den Beschneidungsbereich.

  • Legt den Clippingbereich auf das Rechteck mit dem Replace-Element fest.

  • Füllt ein großes Rechteck mit einem einfarbigen schwarzen Pinsel.

Das Ergebnis ist ein kleines, gefülltes, schwarzes Rechteck.

public:
   void SetClipRegionCombine( PaintEventArgs^ e )
   {
      // Create region for clipping.
      System::Drawing::Region^ clipRegion = gcnew System::Drawing::Region( Rectangle(0,0,100,100) );

      // Set clipping region of graphics to region.
      e->Graphics->SetClip( clipRegion, CombineMode::Replace );

      // Fill rectangle to demonstrate clip region.
      e->Graphics->FillRectangle( gcnew SolidBrush( Color::Black ), 0, 0, 500, 300 );
   }
private void SetClipRegionCombine(PaintEventArgs e)
{

    // Create region for clipping.
    Region clipRegion = new Region(new Rectangle(0, 0, 100, 100));

    // Set clipping region of graphics to region.
    e.Graphics.SetClip(clipRegion, CombineMode.Replace);

    // Fill rectangle to demonstrate clip region.
    e.Graphics.FillRectangle(new SolidBrush(Color.Black), 0, 0, 500, 300);
}
Private Sub SetClipRegionCombine(ByVal e As PaintEventArgs)

    ' Create region for clipping.
    Dim clipRegion As New [Region](New Rectangle(0, 0, 100, 100))

    ' Set clipping region of graphics to region.
    e.Graphics.SetClip(clipRegion, CombineMode.Replace)

    ' Fill rectangle to demonstrate clip region.
    e.Graphics.FillRectangle(New SolidBrush(Color.Black), 0, 0, _
    500, 300)
End Sub

Gilt für:

SetClip(RectangleF, CombineMode)

Quelle:
Graphics.cs
Quelle:
Graphics.cs
Quelle:
Graphics.cs
Quelle:
Graphics.cs
Quelle:
Graphics.cs

Legt den Beschneidungsbereich dieses Graphics auf das Ergebnis des angegebenen Vorgangs fest, der den aktuellen Clipbereich und das durch eine RectangleF Struktur angegebene Rechteck kombiniert.

public:
 void SetClip(System::Drawing::RectangleF rect, System::Drawing::Drawing2D::CombineMode combineMode);
public void SetClip (System.Drawing.RectangleF rect, System.Drawing.Drawing2D.CombineMode combineMode);
member this.SetClip : System.Drawing.RectangleF * System.Drawing.Drawing2D.CombineMode -> unit
Public Sub SetClip (rect As RectangleF, combineMode As CombineMode)

Parameter

rect
RectangleF

RectangleF Zu kombinierende Struktur.

combineMode
CombineMode

Member der CombineMode-Aufzählung, die den zu verwendenden Kombinationsvorgang angibt.

Beispiele

Das folgende Codebeispiel wurde für die Verwendung mit Windows Forms entwickelt und erfordert PaintEventArgse, bei dem es sich um einen Parameter des Paint-Ereignishandlers handelt. Der Code führt die folgenden Aktionen aus:

  • Erstellt ein kleines Rechteck für den Beschneidungsbereich.

  • Legt den Clippingbereich auf das Rechteck mit dem Replace-Element fest.

  • Füllt ein großes Rechteck mit einem einfarbigen schwarzen Pinsel.

Das Ergebnis ist ein kleines, gefülltes, schwarzes Rechteck.

public:
   void SetClipRectangleFCombine( PaintEventArgs^ e )
   {
      // Create rectangle for clipping region.
      RectangleF clipRect = RectangleF(0.0F,0.0F,100.0F,100.0F);

      // Set clipping region of graphics to rectangle.
      e->Graphics->SetClip( clipRect, CombineMode::Replace );

      // Fill rectangle to demonstrate clip region.
      e->Graphics->FillRectangle( gcnew SolidBrush( Color::Black ), 0, 0, 500, 300 );
   }
private void SetClipRectangleFCombine(PaintEventArgs e)
{

    // Create rectangle for clipping region.
    RectangleF clipRect = new RectangleF(0.0F, 0.0F, 100.0F, 100.0F);

    // Set clipping region of graphics to rectangle.
    e.Graphics.SetClip(clipRect, CombineMode.Replace);

    // Fill rectangle to demonstrate clip region.
    e.Graphics.FillRectangle(new SolidBrush(Color.Black), 0, 0, 500, 300);
}
Private Sub SetClipRectangleFCombine(ByVal e As PaintEventArgs)

    ' Create rectangle for clipping region.
    Dim clipRect As New RectangleF(0.0F, 0.0F, 100.0F, 100.0F)

    ' Set clipping region of graphics to rectangle.
    e.Graphics.SetClip(clipRect, CombineMode.Replace)

    ' Fill rectangle to demonstrate clip region.
    e.Graphics.FillRectangle(New SolidBrush(Color.Black), 0, 0, _
    500, 300)
End Sub

Gilt für:

SetClip(Rectangle, CombineMode)

Quelle:
Graphics.cs
Quelle:
Graphics.cs
Quelle:
Graphics.cs
Quelle:
Graphics.cs
Quelle:
Graphics.cs

Legt den Beschneidungsbereich dieses Graphics auf das Ergebnis des angegebenen Vorgangs fest, der den aktuellen Clipbereich und das durch eine Rectangle Struktur angegebene Rechteck kombiniert.

public:
 void SetClip(System::Drawing::Rectangle rect, System::Drawing::Drawing2D::CombineMode combineMode);
public void SetClip (System.Drawing.Rectangle rect, System.Drawing.Drawing2D.CombineMode combineMode);
member this.SetClip : System.Drawing.Rectangle * System.Drawing.Drawing2D.CombineMode -> unit
Public Sub SetClip (rect As Rectangle, combineMode As CombineMode)

Parameter

rect
Rectangle

Rectangle Zu kombinierende Struktur.

combineMode
CombineMode

Member der CombineMode-Aufzählung, die den zu verwendenden Kombinationsvorgang angibt.

Beispiele

Das folgende Codebeispiel wurde für die Verwendung mit Windows Forms entwickelt und erfordert PaintEventArgse, bei dem es sich um einen Parameter des Paint-Ereignishandlers handelt. Der Code führt die folgenden Aktionen aus:

  • Erstellt ein kleines Rechteck für den Beschneidungsbereich.

  • Legt den Clippingbereich auf das Rechteck mit dem Replace-Element fest.

  • Füllt ein großes Rechteck mit einem einfarbigen schwarzen Pinsel.

Das Ergebnis ist ein kleines, gefülltes, schwarzes Rechteck.

public:
   void SetClipRectangleCombine( PaintEventArgs^ e )
   {
      // Create rectangle for clipping region.
      Rectangle clipRect = Rectangle(0,0,100,100);

      // Set clipping region of graphics to rectangle.
      e->Graphics->SetClip( clipRect, CombineMode::Replace );

      // Fill rectangle to demonstrate clip region.
      e->Graphics->FillRectangle( gcnew SolidBrush( Color::Black ), 0, 0, 500, 300 );
   }
private void SetClipRectangleCombine(PaintEventArgs e)
{

    // Create rectangle for clipping region.
    Rectangle clipRect = new Rectangle(0, 0, 100, 100);

    // Set clipping region of graphics to rectangle.
    e.Graphics.SetClip(clipRect, CombineMode.Replace);

    // Fill rectangle to demonstrate clip region.
    e.Graphics.FillRectangle(new SolidBrush(Color.Black), 0, 0, 500, 300);
}
Private Sub SetClipRectangleCombine(ByVal e As PaintEventArgs)

    ' Create rectangle for clipping region.
    Dim clipRect As New Rectangle(0, 0, 100, 100)

    ' Set clipping region of graphics to rectangle.
    e.Graphics.SetClip(clipRect, CombineMode.Replace)

    ' Fill rectangle to demonstrate clip region.
    e.Graphics.FillRectangle(New SolidBrush(Color.Black), 0, 0, _
    500, 300)
End Sub

Gilt für:

SetClip(Graphics, CombineMode)

Quelle:
Graphics.cs
Quelle:
Graphics.cs
Quelle:
Graphics.cs
Quelle:
Graphics.cs
Quelle:
Graphics.cs

Legt den Clippingbereich dieser Graphics auf das Ergebnis des angegebenen Kombinationsvorgangs des aktuellen Clipbereichs und der Clip-Eigenschaft der angegebenen Graphicsfest.

public:
 void SetClip(System::Drawing::Graphics ^ g, System::Drawing::Drawing2D::CombineMode combineMode);
public void SetClip (System.Drawing.Graphics g, System.Drawing.Drawing2D.CombineMode combineMode);
member this.SetClip : System.Drawing.Graphics * System.Drawing.Drawing2D.CombineMode -> unit
Public Sub SetClip (g As Graphics, combineMode As CombineMode)

Parameter

g
Graphics

Graphics, die den zu kombinierenden Clipbereich angibt.

combineMode
CombineMode

Member der CombineMode-Aufzählung, die den zu verwendenden Kombinationsvorgang angibt.

Beispiele

Das folgende Codebeispiel wurde für die Verwendung mit Windows Forms entwickelt und erfordert PaintEventArgse, bei dem es sich um einen Parameter des Paint-Ereignishandlers sowie thisForm, des Form für das Beispiel handelt. Der Code führt die folgenden Aktionen aus:

  • Erstellt eine temporäre Graphics aus dem thisFormForm des Beispiels.

  • Legt den Beschneidungsbereich des temporären Graphics auf ein kleines Quadrat fest.

  • Aktualisiert den Beschneidungsbereich des Grafikobjekts des Formulars mit dem neuen Graphics mit dem Replace-Element.

  • Füllt ein großes Rechteck mit einem einfarbigen schwarzen Pinsel.

Das Ergebnis ist ein kleines, gefülltes, schwarzes Quadrat.

public:
   void SetClipGraphicsCombine( PaintEventArgs^ e )
   {
      // Create temporary graphics object and set its clipping region.
      Graphics^ newGraphics = this->CreateGraphics();
      newGraphics->SetClip( Rectangle(0,0,100,100) );

      // Update clipping region of graphics to clipping region of new
      // graphics.
      e->Graphics->SetClip( newGraphics, CombineMode::Replace );

      // Fill rectangle to demonstrate clip region.
      e->Graphics->FillRectangle( gcnew SolidBrush( Color::Black ), 0, 0, 500, 300 );

      // Release new graphics.
      delete newGraphics;
   }
private void SetClipGraphicsCombine(PaintEventArgs e)
{

    // Create temporary graphics object and set its clipping region.
    Graphics newGraphics = this.CreateGraphics();
    newGraphics.SetClip(new Rectangle(0, 0, 100, 100));

    // Update clipping region of graphics to clipping region of new

    // graphics.
    e.Graphics.SetClip(newGraphics, CombineMode.Replace);

    // Fill rectangle to demonstrate clip region.
    e.Graphics.FillRectangle(new SolidBrush(Color.Black), 0, 0, 500, 300);

    // Release new graphics.
    newGraphics.Dispose();
}
Private Sub SetClipGraphicsCombine(ByVal e As PaintEventArgs)

    ' Create temporary graphics object and set its clipping region.
    Dim newGraphics As Graphics = Me.CreateGraphics()
    newGraphics.SetClip(New Rectangle(0, 0, 100, 100))

    ' Update clipping region of graphics to clipping region of new

    ' graphics.
    e.Graphics.SetClip(newGraphics, CombineMode.Replace)

    ' Fill rectangle to demonstrate clip region.
    e.Graphics.FillRectangle(New SolidBrush(Color.Black), 0, 0, _
    500, 300)

    ' Release new graphics.
    newGraphics.Dispose()
End Sub

Gilt für:

SetClip(RectangleF)

Quelle:
Graphics.cs
Quelle:
Graphics.cs
Quelle:
Graphics.cs
Quelle:
Graphics.cs
Quelle:
Graphics.cs

Legt den Beschneidungsbereich dieses Graphics auf das durch eine RectangleF Struktur angegebene Rechteck fest.

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

Parameter

rect
RectangleF

RectangleF Struktur, die den neuen Clipbereich darstellt.

Beispiele

Das folgende Codebeispiel wurde für die Verwendung mit Windows Forms entwickelt und erfordert PaintEventArgse, bei dem es sich um einen Parameter des Paint-Ereignishandlers handelt. Der Code führt die folgenden Aktionen aus:

  • Erstellt ein kleines Rechteck für den Beschneidungsbereich.

  • Legt den Clippingbereich auf das Rechteck fest.

  • Füllt ein großes Rechteck mit einem einfarbigen schwarzen Pinsel.

Das Ergebnis ist ein kleines, gefülltes, schwarzes Rechteck.

public:
   void SetClipRectangleF( PaintEventArgs^ e )
   {
      // Create rectangle for clipping region.
      RectangleF clipRect = RectangleF(0.0F,0.0F,100.0F,100.0F);

      // Set clipping region of graphics to rectangle.
      e->Graphics->SetClip( clipRect );

      // Fill rectangle to demonstrate clip region.
      e->Graphics->FillRectangle( gcnew SolidBrush( Color::Black ), 0, 0, 500, 300 );
   }
private void SetClipRectangleF(PaintEventArgs e)
{

    // Create rectangle for clipping region.
    RectangleF clipRect = new RectangleF(0.0F, 0.0F, 100.0F, 100.0F);

    // Set clipping region of graphics to rectangle.
    e.Graphics.SetClip(clipRect);

    // Fill rectangle to demonstrate clip region.
    e.Graphics.FillRectangle(new SolidBrush(Color.Black), 0, 0, 500, 300);
}
Private Sub SetClipRectangleF(ByVal e As PaintEventArgs)

    ' Create rectangle for clipping region.
    Dim clipRect As New RectangleF(0.0F, 0.0F, 100.0F, 100.0F)

    ' Set clipping region of graphics to rectangle.
    e.Graphics.SetClip(clipRect)

    ' Fill rectangle to demonstrate clip region.
    e.Graphics.FillRectangle(New SolidBrush(Color.Black), 0, 0, _
    500, 300)
End Sub

Gilt für:

SetClip(Rectangle)

Quelle:
Graphics.cs
Quelle:
Graphics.cs
Quelle:
Graphics.cs
Quelle:
Graphics.cs
Quelle:
Graphics.cs

Legt den Beschneidungsbereich dieses Graphics auf das durch eine Rectangle Struktur angegebene Rechteck fest.

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

Parameter

rect
Rectangle

Rectangle Struktur, die den neuen Clipbereich darstellt.

Beispiele

Das folgende Codebeispiel wurde für die Verwendung mit Windows Forms entwickelt und erfordert PaintEventArgse, bei dem es sich um einen Parameter des Paint-Ereignishandlers handelt. Der Code führt die folgenden Aktionen aus:

  • Erstellt ein kleines Rechteck für den Beschneidungsbereich.

  • Legt den Clippingbereich auf das Rechteck fest.

  • Füllt ein großes Rechteck mit einem einfarbigen schwarzen Pinsel.

Das Ergebnis ist ein kleines, gefülltes, schwarzes Rechteck.

public:
   void SetClipRectangle( PaintEventArgs^ e )
   {
      // Create rectangle for clipping region.
      Rectangle clipRect = Rectangle(0,0,100,100);

      // Set clipping region of graphics to rectangle.
      e->Graphics->SetClip( clipRect );

      // Fill rectangle to demonstrate clip region.
      e->Graphics->FillRectangle( gcnew SolidBrush( Color::Black ), 0, 0, 500, 300 );
   }
private void SetClipRectangle(PaintEventArgs e)
{

    // Create rectangle for clipping region.
    Rectangle clipRect = new Rectangle(0, 0, 100, 100);

    // Set clipping region of graphics to rectangle.
    e.Graphics.SetClip(clipRect);

    // Fill rectangle to demonstrate clip region.
    e.Graphics.FillRectangle(new SolidBrush(Color.Black), 0, 0, 500, 300);
}
Private Sub SetClipRectangle(ByVal e As PaintEventArgs)

    ' Create rectangle for clipping region.
    Dim clipRect As New Rectangle(0, 0, 100, 100)

    ' Set clipping region of graphics to rectangle.
    e.Graphics.SetClip(clipRect)

    ' Fill rectangle to demonstrate clip region.
    e.Graphics.FillRectangle(New SolidBrush(Color.Black), 0, 0, _
    500, 300)
End Sub

Gilt für:

SetClip(Graphics)

Quelle:
Graphics.cs
Quelle:
Graphics.cs
Quelle:
Graphics.cs
Quelle:
Graphics.cs
Quelle:
Graphics.cs

Legt den Beschneidungsbereich dieses Graphics auf die Clip-Eigenschaft der angegebenen Graphicsfest.

public:
 void SetClip(System::Drawing::Graphics ^ g);
public void SetClip (System.Drawing.Graphics g);
member this.SetClip : System.Drawing.Graphics -> unit
Public Sub SetClip (g As Graphics)

Parameter

g
Graphics

Graphics, aus dem der neue Clipbereich entnommen werden soll.

Beispiele

Das folgende Codebeispiel wurde für die Verwendung mit Windows Forms entwickelt und erfordert PaintEventArgse, bei dem es sich um einen Parameter des Paint-Ereignishandlers sowie thisForm, des Form für das Beispiel handelt. Der Code führt die folgenden Aktionen aus:

  • Erstellt eine temporäre Graphics aus dem thisFormForm des Beispiels.

  • Legt den Beschneidungsbereich des temporären Graphics auf ein kleines Quadrat fest.

  • Aktualisiert den Beschneidungsbereich des Grafikobjekts des Formulars auf die des temporären Graphics.

  • Füllt ein großes Rechteck mit einem einfarbigen schwarzen Pinsel.

Das Ergebnis ist ein kleines, gefülltes, schwarzes Quadrat.

public:
   void SetClipGraphics( PaintEventArgs^ e )
   {
      // Create temporary graphics object and set its clipping region.
      Graphics^ newGraphics = this->CreateGraphics();
      newGraphics->SetClip( Rectangle(0,0,100,100) );

      // Update clipping region of graphics to clipping region of new
      // graphics.
      e->Graphics->SetClip( newGraphics );

      // Fill rectangle to demonstrate clip region.
      e->Graphics->FillRectangle( gcnew SolidBrush( Color::Black ), 0, 0, 500, 300 );

      // Release new graphics.
      delete newGraphics;
   }
private void SetClipGraphics(PaintEventArgs e)
{

    // Create temporary graphics object and set its clipping region.
    Graphics newGraphics = this.CreateGraphics();
    newGraphics.SetClip(new Rectangle(0, 0, 100, 100));

    // Update clipping region of graphics to clipping region of new

    // graphics.
    e.Graphics.SetClip(newGraphics);

    // Fill rectangle to demonstrate clip region.
    e.Graphics.FillRectangle(new SolidBrush(Color.Black), 0, 0, 500, 300);

    // Release new graphics.
    newGraphics.Dispose();
}
Private Sub SetClipGraphics(ByVal e As PaintEventArgs)

    ' Create temporary graphics object and set its clipping region.
    Dim newGraphics As Graphics = Me.CreateGraphics()
    newGraphics.SetClip(New Rectangle(0, 0, 100, 100))

    ' Update clipping region of graphics to clipping region of new

    ' graphics.
    e.Graphics.SetClip(newGraphics)

    ' Fill rectangle to demonstrate clip region.
    e.Graphics.FillRectangle(New SolidBrush(Color.Black), 0, 0, _
    500, 300)

    ' Release new graphics.
    newGraphics.Dispose()
End Sub

Gilt für:

SetClip(GraphicsPath)

Quelle:
Graphics.cs
Quelle:
Graphics.cs
Quelle:
Graphics.cs
Quelle:
Graphics.cs
Quelle:
Graphics.cs

Legt den Beschneidungsbereich dieses Graphics auf die angegebene GraphicsPathfest.

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

Parameter

path
GraphicsPath

GraphicsPath, die den neuen Clipbereich darstellt.

Beispiele

Das folgende Codebeispiel wurde für die Verwendung mit Windows Forms entwickelt und erfordert PaintEventArgse, bei dem es sich um einen Parameter des Paint-Ereignishandlers handelt. Der Code führt die folgenden Aktionen aus:

  • Erstellt einen Grafikpfad und fügt dem Pfad eine Auslassungspunkte hinzu.

  • Legt den Clippingbereich auf den elliptischen Pfad fest.

  • Füllt ein großes Rechteck mit einem einfarbigen schwarzen Pinsel.

Das Ergebnis ist eine gefüllte, schwarze Ellipse.

public:
   void SetClipPath( PaintEventArgs^ e )
   {
      // Create graphics path.
      GraphicsPath^ clipPath = gcnew GraphicsPath;
      clipPath->AddEllipse( 0, 0, 200, 100 );

      // Set clipping region to path.
      e->Graphics->SetClip( clipPath );

      // Fill rectangle to demonstrate clipping region.
      e->Graphics->FillRectangle( gcnew SolidBrush( Color::Black ), 0, 0, 500, 300 );
   }
private void SetClipPath(PaintEventArgs e)
{

    // Create graphics path.
    GraphicsPath clipPath = new GraphicsPath();
    clipPath.AddEllipse(0, 0, 200, 100);

    // Set clipping region to path.
    e.Graphics.SetClip(clipPath);

    // Fill rectangle to demonstrate clipping region.
    e.Graphics.FillRectangle(new SolidBrush(Color.Black), 0, 0, 500, 300);
}
Private Sub SetClipPath(ByVal e As PaintEventArgs)

    ' Create graphics path.
    Dim clipPath As New GraphicsPath
    clipPath.AddEllipse(0, 0, 200, 100)

    ' Set clipping region to path.
    e.Graphics.SetClip(clipPath)

    ' Fill rectangle to demonstrate clipping region.
    e.Graphics.FillRectangle(New SolidBrush(Color.Black), 0, 0, _
    500, 300)
End Sub

Hinweise

Wenn der durch den Parameter path dargestellte Grafikpfad nicht geschlossen wird, wird ein zusätzliches Segment vom letzten Punkt zum ersten Punkt hinzugefügt, um den Pfad zu schließen.

Gilt für:

SetClip(GraphicsPath, CombineMode)

Quelle:
Graphics.cs
Quelle:
Graphics.cs
Quelle:
Graphics.cs
Quelle:
Graphics.cs
Quelle:
Graphics.cs

Legt den Clippingbereich dieser Graphics auf das Ergebnis des angegebenen Vorgangs fest, der den aktuellen Clipbereich und die angegebene GraphicsPathkombiniert.

public:
 void SetClip(System::Drawing::Drawing2D::GraphicsPath ^ path, System::Drawing::Drawing2D::CombineMode combineMode);
public void SetClip (System.Drawing.Drawing2D.GraphicsPath path, System.Drawing.Drawing2D.CombineMode combineMode);
member this.SetClip : System.Drawing.Drawing2D.GraphicsPath * System.Drawing.Drawing2D.CombineMode -> unit
Public Sub SetClip (path As GraphicsPath, combineMode As CombineMode)

Parameter

path
GraphicsPath

GraphicsPath kombinieren.

combineMode
CombineMode

Member der CombineMode-Aufzählung, die den zu verwendenden Kombinationsvorgang angibt.

Beispiele

Das folgende Codebeispiel wurde für die Verwendung mit Windows Forms entwickelt und erfordert PaintEventArgse, bei dem es sich um einen Parameter des Paint-Ereignishandlers handelt. Der Code führt die folgenden Aktionen aus:

  • Erstellt einen Grafikpfad und fügt dem Pfad eine Auslassungspunkte hinzu.

  • Legt den Clippingbereich auf den elliptischen Pfad mit dem Replace-Element fest.

  • Füllt ein großes Rechteck mit einem einfarbigen schwarzen Pinsel.

Das Ergebnis ist eine gefüllte, schwarze Ellipse.

public:
   void SetClipPathCombine( PaintEventArgs^ e )
   {
      // Create graphics path.
      GraphicsPath^ clipPath = gcnew GraphicsPath;
      clipPath->AddEllipse( 0, 0, 200, 100 );

      // Set clipping region to path.
      e->Graphics->SetClip( clipPath, CombineMode::Replace );

      // Fill rectangle to demonstrate clipping region.
      e->Graphics->FillRectangle( gcnew SolidBrush( Color::Black ), 0, 0, 500, 300 );
   }
private void SetClipPathCombine(PaintEventArgs e)
{

    // Create graphics path.
    GraphicsPath clipPath = new GraphicsPath();
    clipPath.AddEllipse(0, 0, 200, 100);

    // Set clipping region to path.
    e.Graphics.SetClip(clipPath, CombineMode.Replace);

    // Fill rectangle to demonstrate clipping region.
    e.Graphics.FillRectangle(new SolidBrush(Color.Black), 0, 0, 500, 300);
}
Private Sub SetClipPathCombine(ByVal e As PaintEventArgs)

    ' Create graphics path.
    Dim clipPath As New GraphicsPath
    clipPath.AddEllipse(0, 0, 200, 100)

    ' Set clipping region to path.
    e.Graphics.SetClip(clipPath, CombineMode.Replace)

    ' Fill rectangle to demonstrate clipping region.
    e.Graphics.FillRectangle(New SolidBrush(Color.Black), 0, 0, _
    500, 300)
End Sub

Hinweise

Wenn der durch den Parameter path dargestellte Grafikpfad nicht geschlossen wird, wird ein zusätzliches Segment vom letzten Punkt zum ersten Punkt hinzugefügt, um den Pfad zu schließen.

Gilt für: