Graphics.SetClip Methode

Definitie

Hiermee stelt u het knipgebied van dit Graphics in op de Clip eigenschap van de opgegeven Graphics.

Overloads

Name Description
SetClip(Region, CombineMode)

Hiermee stelt u het knipgebied hiervan Graphics in op het resultaat van de opgegeven bewerking waarbij het huidige clipgebied en de opgegeven clip worden gecombineerd Region.

SetClip(RectangleF, CombineMode)

Hiermee stelt u het knipgebied van dit Graphics in op het resultaat van de opgegeven bewerking, waarbij het huidige clipgebied en de rechthoek worden gecombineerd die is opgegeven door een RectangleF structuur.

SetClip(Rectangle, CombineMode)

Hiermee stelt u het knipgebied van dit Graphics in op het resultaat van de opgegeven bewerking, waarbij het huidige clipgebied en de rechthoek worden gecombineerd die is opgegeven door een Rectangle structuur.

SetClip(Graphics, CombineMode)

Hiermee stelt u de knipregio hiervan Graphics in op het resultaat van de opgegeven combinatiebewerking van het huidige clipgebied en de Clip eigenschap van de opgegeven Graphics.

SetClip(GraphicsPath, CombineMode)

Hiermee stelt u het knipgebied hiervan Graphics in op het resultaat van de opgegeven bewerking waarbij het huidige clipgebied en de opgegeven clip worden gecombineerd GraphicsPath.

SetClip(RectangleF)

Hiermee stelt u het knipgebied hiervan Graphics in op de rechthoek die is opgegeven door een RectangleF structuur.

SetClip(Rectangle)

Hiermee stelt u het knipgebied hiervan Graphics in op de rechthoek die is opgegeven door een Rectangle structuur.

SetClip(Graphics)

Hiermee stelt u het knipgebied van dit Graphics in op de Clip eigenschap van de opgegeven Graphics.

SetClip(GraphicsPath)

Hiermee stelt u het knipgebied van dit Graphics in op de opgegeven GraphicsPath.

SetClip(Region, CombineMode)

Bron:
Graphics.cs
Bron:
Graphics.cs
Bron:
Graphics.cs
Bron:
Graphics.cs
Bron:
Graphics.cs
Bron:
Graphics.cs
Bron:
Graphics.cs
Bron:
Graphics.cs

Hiermee stelt u het knipgebied hiervan Graphics in op het resultaat van de opgegeven bewerking waarbij het huidige clipgebied en de opgegeven clip worden gecombineerd Region.

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)

Parameters

region
Region

Region om te combineren.

combineMode
CombineMode

Lid van de CombineMode opsomming die de combinatiebewerking aangeeft die moet worden gebruikt.

Voorbeelden

Het volgende codevoorbeeld is ontworpen voor gebruik met Windows Forms en vereist PaintEventArgse, een parameter van de Paint gebeurtenis-handler. De code voert de volgende acties uit:

  • Hiermee maakt u een kleine rechthoek voor het knipgebied.

  • Hiermee stelt u het knipgebied in op de rechthoek met het Replace lid.

  • Vult een grote rechthoek met een effen zwarte borstel.

Het resultaat is een kleine, gevulde, zwarte rechthoek.

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

Van toepassing op

SetClip(RectangleF, CombineMode)

Bron:
Graphics.cs
Bron:
Graphics.cs
Bron:
Graphics.cs
Bron:
Graphics.cs
Bron:
Graphics.cs
Bron:
Graphics.cs
Bron:
Graphics.cs
Bron:
Graphics.cs

Hiermee stelt u het knipgebied van dit Graphics in op het resultaat van de opgegeven bewerking, waarbij het huidige clipgebied en de rechthoek worden gecombineerd die is opgegeven door een RectangleF structuur.

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)

Parameters

rect
RectangleF

RectangleF te combineren structuur.

combineMode
CombineMode

Lid van de CombineMode opsomming die de combinatiebewerking aangeeft die moet worden gebruikt.

Voorbeelden

Het volgende codevoorbeeld is ontworpen voor gebruik met Windows Forms en vereist PaintEventArgse, een parameter van de Paint gebeurtenis-handler. De code voert de volgende acties uit:

  • Hiermee maakt u een kleine rechthoek voor het knipgebied.

  • Hiermee stelt u het knipgebied in op de rechthoek met het Replace lid.

  • Vult een grote rechthoek met een effen zwarte borstel.

Het resultaat is een kleine, gevulde, zwarte rechthoek.

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

Van toepassing op

SetClip(Rectangle, CombineMode)

Bron:
Graphics.cs
Bron:
Graphics.cs
Bron:
Graphics.cs
Bron:
Graphics.cs
Bron:
Graphics.cs
Bron:
Graphics.cs
Bron:
Graphics.cs
Bron:
Graphics.cs

Hiermee stelt u het knipgebied van dit Graphics in op het resultaat van de opgegeven bewerking, waarbij het huidige clipgebied en de rechthoek worden gecombineerd die is opgegeven door een Rectangle structuur.

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)

Parameters

rect
Rectangle

Rectangle te combineren structuur.

combineMode
CombineMode

Lid van de CombineMode opsomming die de combinatiebewerking aangeeft die moet worden gebruikt.

Voorbeelden

Het volgende codevoorbeeld is ontworpen voor gebruik met Windows Forms en vereist PaintEventArgse, een parameter van de Paint gebeurtenis-handler. De code voert de volgende acties uit:

  • Hiermee maakt u een kleine rechthoek voor het knipgebied.

  • Hiermee stelt u het knipgebied in op de rechthoek met het Replace lid.

  • Vult een grote rechthoek met een effen zwarte borstel.

Het resultaat is een kleine, gevulde, zwarte rechthoek.

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

Van toepassing op

SetClip(Graphics, CombineMode)

Bron:
Graphics.cs
Bron:
Graphics.cs
Bron:
Graphics.cs
Bron:
Graphics.cs
Bron:
Graphics.cs
Bron:
Graphics.cs
Bron:
Graphics.cs
Bron:
Graphics.cs

Hiermee stelt u de knipregio hiervan Graphics in op het resultaat van de opgegeven combinatiebewerking van het huidige clipgebied en de Clip eigenschap van de opgegeven Graphics.

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)

Parameters

g
Graphics

Graphics waarmee het clipgebied wordt opgegeven dat moet worden gecombineerd.

combineMode
CombineMode

Lid van de CombineMode opsomming die de combinatiebewerking aangeeft die moet worden gebruikt.

Voorbeelden

Het volgende codevoorbeeld is ontworpen voor gebruik met Windows Forms en vereist PaintEventArgse, een parameter van de Paint gebeurtenis-handler, evenals thisForm, de Form voor het voorbeeld. De code voert de volgende acties uit:

  • Hiermee maakt u een tijdelijke functie Graphics op basis van het thisFormForm voorbeeld.

  • Hiermee stelt u het knipgebied van de tijdelijke Graphics in op een klein vierkant.

  • Hiermee wordt het knipgebied van het grafische object van het formulier bijgewerkt naar die van het nieuwe Graphics met het Replace lid.

  • Vult een grote rechthoek met een effen zwarte borstel.

Het resultaat is een klein, gevuld, zwart vierkant.

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

Van toepassing op

SetClip(GraphicsPath, CombineMode)

Bron:
Graphics.cs
Bron:
Graphics.cs
Bron:
Graphics.cs
Bron:
Graphics.cs
Bron:
Graphics.cs
Bron:
Graphics.cs
Bron:
Graphics.cs
Bron:
Graphics.cs

Hiermee stelt u het knipgebied hiervan Graphics in op het resultaat van de opgegeven bewerking waarbij het huidige clipgebied en de opgegeven clip worden gecombineerd GraphicsPath.

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)

Parameters

path
GraphicsPath

GraphicsPath om te combineren.

combineMode
CombineMode

Lid van de CombineMode opsomming die de combinatiebewerking aangeeft die moet worden gebruikt.

Voorbeelden

Het volgende codevoorbeeld is ontworpen voor gebruik met Windows Forms en vereist PaintEventArgse, een parameter van de Paint gebeurtenis-handler. De code voert de volgende acties uit:

  • Hiermee maakt u een grafisch pad en voegt u een beletselteken toe aan het pad.

  • Hiermee stelt u het knipgebied in op het elliptische pad met het Replace lid.

  • Vult een grote rechthoek met een effen zwarte borstel.

Het resultaat is een gevuld, zwart beletselteken.

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

Opmerkingen

Als het grafische pad dat wordt vertegenwoordigd door de path parameter niet wordt gesloten, wordt vanaf het laatste punt aan het eerste punt een extra segment toegevoegd om het pad te sluiten.

Van toepassing op

SetClip(RectangleF)

Bron:
Graphics.cs
Bron:
Graphics.cs
Bron:
Graphics.cs
Bron:
Graphics.cs
Bron:
Graphics.cs
Bron:
Graphics.cs
Bron:
Graphics.cs
Bron:
Graphics.cs

Hiermee stelt u het knipgebied hiervan Graphics in op de rechthoek die is opgegeven door een RectangleF structuur.

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)

Parameters

rect
RectangleF

RectangleF structuur die het nieuwe clipgebied vertegenwoordigt.

Voorbeelden

Het volgende codevoorbeeld is ontworpen voor gebruik met Windows Forms en vereist PaintEventArgse, een parameter van de Paint gebeurtenis-handler. De code voert de volgende acties uit:

  • Hiermee maakt u een kleine rechthoek voor het knipgebied.

  • Hiermee stelt u het knipgebied in op de rechthoek.

  • Vult een grote rechthoek met een effen zwarte borstel.

Het resultaat is een kleine, gevulde, zwarte rechthoek.

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

Van toepassing op

SetClip(Rectangle)

Bron:
Graphics.cs
Bron:
Graphics.cs
Bron:
Graphics.cs
Bron:
Graphics.cs
Bron:
Graphics.cs
Bron:
Graphics.cs
Bron:
Graphics.cs
Bron:
Graphics.cs

Hiermee stelt u het knipgebied hiervan Graphics in op de rechthoek die is opgegeven door een Rectangle structuur.

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)

Parameters

rect
Rectangle

Rectangle structuur die het nieuwe clipgebied vertegenwoordigt.

Voorbeelden

Het volgende codevoorbeeld is ontworpen voor gebruik met Windows Forms en vereist PaintEventArgse, een parameter van de Paint gebeurtenis-handler. De code voert de volgende acties uit:

  • Hiermee maakt u een kleine rechthoek voor het knipgebied.

  • Hiermee stelt u het knipgebied in op de rechthoek.

  • Vult een grote rechthoek met een effen zwarte borstel.

Het resultaat is een kleine, gevulde, zwarte rechthoek.

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

Van toepassing op

SetClip(Graphics)

Bron:
Graphics.cs
Bron:
Graphics.cs
Bron:
Graphics.cs
Bron:
Graphics.cs
Bron:
Graphics.cs
Bron:
Graphics.cs
Bron:
Graphics.cs
Bron:
Graphics.cs

Hiermee stelt u het knipgebied van dit Graphics in op de Clip eigenschap van de opgegeven Graphics.

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)

Parameters

g
Graphics

Graphics van waaruit het nieuwe clipgebied moet worden opgehaald.

Voorbeelden

Het volgende codevoorbeeld is ontworpen voor gebruik met Windows Forms en vereist PaintEventArgse, een parameter van de Paint gebeurtenis-handler, evenals thisForm, de Form voor het voorbeeld. De code voert de volgende acties uit:

  • Hiermee maakt u een tijdelijke functie Graphics op basis van het thisFormForm voorbeeld.

  • Hiermee stelt u het knipgebied van de tijdelijke Graphics in op een klein vierkant.

  • Hiermee werkt u het knipgebied van het afbeeldingsobject van het formulier bij naar die van het tijdelijke Graphicsobject.

  • Vult een grote rechthoek met een effen zwarte borstel.

Het resultaat is een klein, gevuld, zwart vierkant.

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

Van toepassing op

SetClip(GraphicsPath)

Bron:
Graphics.cs
Bron:
Graphics.cs
Bron:
Graphics.cs
Bron:
Graphics.cs
Bron:
Graphics.cs
Bron:
Graphics.cs
Bron:
Graphics.cs
Bron:
Graphics.cs

Hiermee stelt u het knipgebied van dit Graphics in op de opgegeven GraphicsPath.

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)

Parameters

path
GraphicsPath

GraphicsPath dat het nieuwe clipgebied vertegenwoordigt.

Voorbeelden

Het volgende codevoorbeeld is ontworpen voor gebruik met Windows Forms en vereist PaintEventArgse, een parameter van de Paint gebeurtenis-handler. De code voert de volgende acties uit:

  • Hiermee maakt u een grafisch pad en voegt u een beletselteken toe aan het pad.

  • Hiermee stelt u het knipgebied in op het elliptische pad.

  • Vult een grote rechthoek met een effen zwarte borstel.

Het resultaat is een gevuld, zwart beletselteken.

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

Opmerkingen

Als het grafische pad dat wordt vertegenwoordigd door de path parameter niet wordt gesloten, wordt vanaf het laatste punt aan het eerste punt een extra segment toegevoegd om het pad te sluiten.

Van toepassing op