Graphics.SetClip Metoda
Definicja
Ważne
Niektóre informacje odnoszą się do produktu w wersji wstępnej, który może zostać znacząco zmodyfikowany przed wydaniem. Firma Microsoft nie udziela żadnych gwarancji, jawnych lub domniemanych, w odniesieniu do informacji podanych w tym miejscu.
Przeciążenia
| SetClip(Region, CombineMode) |
Ustawia region przycinania tego Graphics obiektu na wynik określonej operacji łączącej bieżący region klipu i określony Regionelement . |
| SetClip(RectangleF, CombineMode) |
Ustawia obszar przycinania tego Graphics obiektu na wynik określonej operacji łączącej bieżący region klipu i prostokąt określony przez RectangleF strukturę. |
| SetClip(Rectangle, CombineMode) |
Ustawia obszar przycinania tego Graphics obiektu na wynik określonej operacji łączącej bieżący region klipu i prostokąt określony przez Rectangle strukturę. |
| SetClip(GraphicsPath, CombineMode) |
Ustawia region przycinania tego Graphics obiektu na wynik określonej operacji łączącej bieżący region klipu i określony GraphicsPathelement . |
| SetClip(Graphics, CombineMode) |
Ustawia region przycinania tego Graphics obiektu na wynik określonej operacji łączenia bieżącego regionu klipu i Clip właściwości określonego Graphicsobiektu . |
| SetClip(Rectangle) |
Ustawia obszar przycinania tego Graphics obiektu na prostokąt określony przez Rectangle strukturę. |
| SetClip(Graphics) |
Ustawia obszar przycinania tego Graphics obiektu na |
| SetClip(GraphicsPath) |
Ustawia obszar przycinania tego Graphics obiektu na określony GraphicsPathelement . |
| SetClip(RectangleF) |
Ustawia obszar przycinania tego Graphics obiektu na prostokąt określony przez RectangleF strukturę. |
SetClip(Region, CombineMode)
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)
Parametry
- combineMode
- CombineMode
Element członkowski z CombineMode wyliczenia, który określa operację łączenia do użycia.
Przykłady
Poniższy przykład kodu jest przeznaczony do użycia z Windows Forms i wymaga PaintEventArgs eparametru Paint programu obsługi zdarzeń. Kod wykonuje następujące akcje:
Tworzy mały prostokąt dla regionu przycinania.
Ustawia obszar przycinania na prostokąt z elementem Replace członkowskim.
Wypełnia duży prostokąt solidnym czarnym pędzlem.
Wynikiem jest mały, wypełniony, czarny prostokąt.
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
Dotyczy
SetClip(RectangleF, CombineMode)
Ustawia obszar przycinania tego Graphics obiektu na wynik określonej operacji łączącej bieżący region klipu i prostokąt określony przez RectangleF strukturę.
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)
Parametry
- rect
- RectangleF
RectangleF struktura do połączenia.
- combineMode
- CombineMode
Element członkowski CombineMode wyliczenia, który określa operację łączenia do użycia.
Przykłady
Poniższy przykład kodu jest przeznaczony do użycia z Windows Forms i wymaga PaintEventArgs eparametru Paint programu obsługi zdarzeń. Kod wykonuje następujące akcje:
Tworzy mały prostokąt dla regionu przycinania.
Ustawia obszar przycinania na prostokąt z elementem Replace członkowskim.
Wypełnia duży prostokąt solidnym czarnym pędzlem.
Wynikiem jest mały, wypełniony, czarny prostokąt.
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
Dotyczy
SetClip(Rectangle, CombineMode)
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)
Parametry
- combineMode
- CombineMode
Element członkowski CombineMode wyliczenia, który określa operację łączenia do użycia.
Przykłady
Poniższy przykład kodu jest przeznaczony do użycia z Windows Forms i wymaga PaintEventArgs eparametru Paint programu obsługi zdarzeń. Kod wykonuje następujące akcje:
Tworzy mały prostokąt dla regionu przycinania.
Ustawia obszar przycinania na prostokąt z elementem Replace członkowskim.
Wypełnia duży prostokąt solidnym czarnym pędzlem.
Wynikiem jest mały, wypełniony, czarny prostokąt.
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
Dotyczy
SetClip(GraphicsPath, CombineMode)
Ustawia region przycinania tego Graphics obiektu na wynik określonej operacji łączącej bieżący region klipu i określony GraphicsPathelement .
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)
Parametry
- path
- GraphicsPath
GraphicsPath aby połączyć.
- combineMode
- CombineMode
Element członkowski CombineMode wyliczenia, który określa operację łączenia do użycia.
Przykłady
Poniższy przykład kodu jest przeznaczony do użycia z Windows Forms i wymaga PaintEventArgs eparametru Paint programu obsługi zdarzeń. Kod wykonuje następujące akcje:
Tworzy ścieżkę grafiki i dodaje wielokropek do ścieżki.
Ustawia obszar przycinania na ścieżkę wielokropka z elementem Replace członkowskim.
Wypełnia duży prostokąt solidnym czarnym pędzlem.
Wynik jest wypełnionym, czarnym wielokropkiem.
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
Uwagi
Jeśli ścieżka graficzna reprezentowana przez path parametr nie jest zamknięta, dodatkowy segment jest dodawany od ostatniego punktu do pierwszego punktu, aby zamknąć ścieżkę.
Dotyczy
SetClip(Graphics, CombineMode)
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)
Parametry
- combineMode
- CombineMode
Element członkowski CombineMode wyliczenia, który określa operację łączenia do użycia.
Przykłady
Poniższy przykład kodu jest przeznaczony do użycia z Windows Forms i wymaga PaintEventArgs eparametru Paint , który jest parametrem programu obsługi zdarzeń, a także thisForm, Form na przykład. Kod wykonuje następujące akcje:
Tworzy tymczasowy Graphics element z
thisFormForm przykładu.Ustawia obszar przycinania tymczasowego Graphics na mały kwadrat.
Aktualizuje obszar przycinania obiektu graficznego formularza do tego nowego Graphics obiektu z elementem Replace członkowskim.
Wypełnia duży prostokąt solidnym czarnym pędzlem.
Wynik jest mały, wypełniony, czarny kwadrat.
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
Dotyczy
SetClip(Rectangle)
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)
Parametry
Przykłady
Poniższy przykład kodu jest przeznaczony do użycia z Windows Forms i wymaga PaintEventArgs eparametru Paint programu obsługi zdarzeń. Kod wykonuje następujące akcje:
Tworzy mały prostokąt dla regionu przycinania.
Ustawia obszar przycinania na prostokąt.
Wypełnia duży prostokąt solidnym czarnym pędzlem.
Wynikiem jest mały, wypełniony, czarny prostokąt.
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
Dotyczy
SetClip(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)
Parametry
Przykłady
Poniższy przykład kodu jest przeznaczony do użycia z Windows Forms i wymaga PaintEventArgs eparametru Paint , który jest parametrem programu obsługi zdarzeń, a także thisForm, Form na przykład. Kod wykonuje następujące akcje:
Tworzy tymczasowy Graphics element z
thisFormForm przykładu.Ustawia obszar przycinania tymczasowego Graphics na mały kwadrat.
Aktualizuje obszar przycinania obiektu graficznego formularza do tymczasowego Graphicsobiektu .
Wypełnia duży prostokąt solidnym czarnym pędzlem.
Wynik jest mały, wypełniony, czarny kwadrat.
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
Dotyczy
SetClip(GraphicsPath)
Ustawia obszar przycinania tego Graphics obiektu na określony GraphicsPathelement .
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)
Parametry
- path
- GraphicsPath
GraphicsPath reprezentuje nowy region klipu.
Przykłady
Poniższy przykład kodu jest przeznaczony do użycia z Windows Forms i wymaga PaintEventArgs eparametru Paint programu obsługi zdarzeń. Kod wykonuje następujące akcje:
Tworzy ścieżkę grafiki i dodaje wielokropek do ścieżki.
Ustawia obszar przycinania na ścieżkę wielokropka.
Wypełnia duży prostokąt solidnym czarnym pędzlem.
Wynik jest wypełnionym, czarnym wielokropkiem.
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
Uwagi
Jeśli ścieżka graficzna reprezentowana przez path parametr nie jest zamknięta, dodatkowy segment jest dodawany od ostatniego punktu do pierwszego punktu, aby zamknąć ścieżkę.
Dotyczy
SetClip(RectangleF)
Ustawia obszar przycinania tego Graphics obiektu na prostokąt określony przez RectangleF strukturę.
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)
Parametry
- rect
- RectangleF
RectangleF struktura reprezentująca nowy region klipu.
Przykłady
Poniższy przykład kodu jest przeznaczony do użycia z Windows Forms i wymaga PaintEventArgs eparametru Paint programu obsługi zdarzeń. Kod wykonuje następujące akcje:
Tworzy mały prostokąt dla regionu przycinania.
Ustawia obszar przycinania na prostokąt.
Wypełnia duży prostokąt solidnym czarnym pędzlem.
Wynikiem jest mały, wypełniony, czarny prostokąt.
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