Graphics.Clip Eigenschaft

Definition

Ruft einen Region ab, der den Zeichnungsbereich dieses Graphics einschränkt, oder legt diesen fest.

public:
 property System::Drawing::Region ^ Clip { System::Drawing::Region ^ get(); void set(System::Drawing::Region ^ value); };
public System.Drawing.Region Clip { get; set; }
member this.Clip : System.Drawing.Region with get, set
Public Property Clip As Region

Eigenschaftswert

Ein Region, der den Teil dieses Graphics einschränkt, der gerade für das Zeichnen verfügbar ist.

Beispiele

Im folgenden Codebeispiel wird die Verwendung des Clip-Attributs veranschaulicht. Dieses Beispiel ist für die Verwendung mit Windows Forms konzipiert. Fügen Sie den Code in ein Formular ein, und rufen Sie die SetAndFillClip -Methode auf, wenn Sie das Ereignis des Formulars Paint behandeln, und übergeben Sie e als PaintEventArgs.

private:
   void SetAndFillClip( PaintEventArgs^ e )
   {
      // Set the Clip property to a new region.
      e->Graphics->Clip = gcnew System::Drawing::Region( Rectangle(10,10,100,200) );

      // Fill the region.
      e->Graphics->FillRegion( Brushes::LightSalmon, e->Graphics->Clip );

      // Demonstrate the clip region by drawing a string
      // at the outer edge of the region.
      e->Graphics->DrawString( "Outside of Clip", gcnew System::Drawing::Font( "Arial",12.0F,FontStyle::Regular ), Brushes::Black, 0.0F, 0.0F );
   }
private void SetAndFillClip(PaintEventArgs e)
{

    // Set the Clip property to a new region.
    e.Graphics.Clip = new Region(new Rectangle(10, 10, 100, 200));

    // Fill the region.
    e.Graphics.FillRegion(Brushes.LightSalmon, e.Graphics.Clip);

    // Demonstrate the clip region by drawing a string
    // at the outer edge of the region.
    e.Graphics.DrawString("Outside of Clip", new Font("Arial", 
        12.0F, FontStyle.Regular), Brushes.Black, 0.0F, 0.0F);
}
Private Sub SetAndFillClip(ByVal e As PaintEventArgs)

    ' Set the Clip property to a new region.
    e.Graphics.Clip = New Region(New Rectangle(10, 10, 100, 200))

    ' Fill the region.
    e.Graphics.FillRegion(Brushes.LightSalmon, e.Graphics.Clip)

    ' Demonstrate the clip region by drawing a string
    ' at the outer edge of the region.
    e.Graphics.DrawString("Outside of Clip", _
        New Font("Arial", 12.0F, FontStyle.Regular), _
        Brushes.Black, 0.0F, 0.0F)

End Sub

Hinweise

Das Ändern des Region von der Clip -Eigenschaft zurückgegebenen Objekts wirkt sich nicht auf das nachfolgende Zeichnen mit dem Graphics -Objekt aus. Um den Clipbereich zu ändern, ersetzen Sie den Clip Eigenschaftswert durch ein neues Region -Objekt. Um zu bestimmen, ob der Beschneidungsbereich unendlich ist, rufen Sie die -Eigenschaft ab, und rufen Sie ihre Clip -Methode auf IsInfinite .

Gilt für: