Graphics.Clip Vlastnost

Definice

Získá nebo nastaví objekt Region , který omezuje oblast výkresu tohoto Graphicsobjektu .

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

Hodnota vlastnosti

A Region , která omezuje jeho část Graphics , která je aktuálně k dispozici pro kreslení.

Příklady

Následující příklad kódu ukazuje použití Clip vlastnosti. Tento příklad je navržený pro použití s model Windows Forms. Vložte kód do formuláře a při zpracování události formuláře Paint volejte SetAndFillClip metodu, která se předává e jako 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

Poznámky

Úprava objektu Region vráceného Clip vlastností nemá vliv na další výkres s objektem Graphics . Pokud chcete změnit oblast klipu, nahraďte Clip hodnotu vlastnosti novým Region objektem. Chcete-li zjistit, zda je oblast výřezu nekonečná, načtěte Clip vlastnost a zavolejte její IsInfinite metodu.

Platí pro