Graphics.BeginContainer 메서드
정의
중요
일부 정보는 릴리스되기 전에 상당 부분 수정될 수 있는 시험판 제품과 관련이 있습니다. Microsoft는 여기에 제공된 정보에 대해 어떠한 명시적이거나 묵시적인 보증도 하지 않습니다.
그래픽 컨테이너를 이 Graphics의 현재 상태로 저장하고 새 그래픽 컨테이너를 열어 사용합니다.
오버로드
BeginContainer() |
그래픽 컨테이너를 이 Graphics의 현재 상태로 저장하고 새 그래픽 컨테이너를 열어 사용합니다. |
BeginContainer(Rectangle, Rectangle, GraphicsUnit) |
그래픽 컨테이너를 이 Graphics의 현재 상태로 저장하고 지정된 크기 조정 변환으로 새 그래픽 컨테이너를 열어 사용합니다. |
BeginContainer(RectangleF, RectangleF, GraphicsUnit) |
그래픽 컨테이너를 이 Graphics의 현재 상태로 저장하고 지정된 크기 조정 변환으로 새 그래픽 컨테이너를 열어 사용합니다. |
BeginContainer()
- Source:
- Graphics.cs
- Source:
- Graphics.cs
- Source:
- Graphics.cs
그래픽 컨테이너를 이 Graphics의 현재 상태로 저장하고 새 그래픽 컨테이너를 열어 사용합니다.
public:
System::Drawing::Drawing2D::GraphicsContainer ^ BeginContainer();
public System.Drawing.Drawing2D.GraphicsContainer BeginContainer ();
member this.BeginContainer : unit -> System.Drawing.Drawing2D.GraphicsContainer
Public Function BeginContainer () As GraphicsContainer
반환
이 메서드는 호출되었을 때 이 Graphics의 상태를 나타내는 GraphicsContainer를 반환합니다.
예제
다음 코드 예제는 Windows Forms 사용하도록 설계되었으며 이벤트 처리기의 Paint 매개 변수인 가 필요합니다.PaintEventArgse
코드는 다음 작업을 수행합니다.
새 그래픽 컨테이너를 열고 이전 컨테이너를 저장합니다.
컨테이너의 월드 좌표를 변환합니다.
새 컨테이너의 (번역된 좌표)에 빨간색 사각형을 채웁니다.
새 컨테이너를 닫고 저장된 컨테이너를 복원합니다.
저장된 컨테이너의 녹색 사각형(변환되지 않은 좌표)을 채웁니다.
그 결과 동일한 크기의 빨간색 사각형 위에 있는 녹색 사각형이 생성됩니다.
private:
void BeginContainerVoid( PaintEventArgs^ e )
{
// Begin graphics container.
GraphicsContainer^ containerState = e->Graphics->BeginContainer();
// Translate world transformation.
e->Graphics->TranslateTransform( 100.0F, 100.0F );
// Fill translated rectangle in container with red.
e->Graphics->FillRectangle( gcnew SolidBrush( Color::Red ), 0, 0, 200, 200 );
// End graphics container.
e->Graphics->EndContainer( containerState );
// Fill untransformed rectangle with green.
e->Graphics->FillRectangle( gcnew SolidBrush( Color::Green ), 0, 0, 200, 200 );
}
private void BeginContainerVoid(PaintEventArgs e)
{
// Begin graphics container.
GraphicsContainer containerState = e.Graphics.BeginContainer();
// Translate world transformation.
e.Graphics.TranslateTransform(100.0F, 100.0F);
// Fill translated rectangle in container with red.
e.Graphics.FillRectangle(new SolidBrush(Color.Red), 0, 0, 200, 200);
// End graphics container.
e.Graphics.EndContainer(containerState);
// Fill untransformed rectangle with green.
e.Graphics.FillRectangle(new SolidBrush(Color.Green), 0, 0, 200, 200);
}
Private Sub BeginContainerVoid(ByVal e As PaintEventArgs)
' Begin graphics container.
Dim containerState As GraphicsContainer = _
e.Graphics.BeginContainer()
' Translate world transformation.
e.Graphics.TranslateTransform(100.0F, 100.0F)
' Fill translated rectangle in container with red.
e.Graphics.FillRectangle(New SolidBrush(Color.Red), 0, 0, 200, 200)
' End graphics container.
e.Graphics.EndContainer(containerState)
' Fill untransformed rectangle with green.
e.Graphics.FillRectangle(New SolidBrush(Color.Green), 0, 0, _
200, 200)
End Sub
설명
메서드와 함께 이 메서드를 EndContainer 사용하여 중첩된 그래픽 컨테이너를 만듭니다. 그래픽 컨테이너는 변환, 클리핑 영역 및 렌더링 속성과 같은 그래픽 상태를 유지합니다.
의 메서드를 BeginContainerGraphics호출하면 의 Graphics 상태를 보유하는 정보 블록이 스택에 배치됩니다. 메서드는 BeginContainer 해당 정보 블록을 식별하는 을 반환 GraphicsContainer 합니다. 식별 개체를 메서드에 EndContainer 전달하면 정보 블록이 스택에서 제거되고 를 메서드 호출 당시의 BeginContainer 상태로 복원 Graphics 하는 데 사용됩니다.
컨테이너를 중첩할 수 있습니다. 즉, 메서드를 호출하기 전에 메서드를 BeginContainer 여러 번 호출할 EndContainer 수 있습니다. 메서드를 BeginContainer 호출할 때마다 정보 블록이 스택에 배치되고 정보 블록에 대한 을 GraphicsContainer 받습니다. 이러한 개체 중 하나를 메서드 Graphics 에 EndContainer 전달하면 는 특정 GraphicsContainer를 반환한 메서드 호출 당시의 BeginContainer 상태로 반환됩니다. 해당 BeginContainer 메서드 호출을 통해 스택에 배치된 정보 블록이 스택에서 제거되고 해당 BeginContainer 메서드 호출 후 해당 스택에 배치된 모든 정보 블록도 제거됩니다.
메서드에 대한 호출은 Save 메서드에 대한 호출과 동일한 스택에 정보 블록을 배치합니다 BeginContainer . EndContainer 메서드 호출이 메서드 호출 Restore 과 쌍을 BeginContainer 이루는 것처럼 메서드 호출은 메서드 호출과 쌍을 이릅니다Save.
메서드를 EndContainer 호출하면 메서드에 대한 해당 호출 BeginContainer 후 스택에 배치된 모든 정보 블록(Save메서드 또는 BeginContainer 메서드)이 스택에서 제거됩니다. 마찬가지로 메서드를 Restore 호출하면 메서드에 대한 해당 호출 Save 후 스택에 배치된 모든 정보 블록(Save메서드 또는 BeginContainer 메서드)이 스택에서 제거됩니다.
메서드에 의해 BeginContainer 설정된 그래픽 상태에는 기본 그래픽 상태의 렌더링 품질이 포함됩니다. 메서드를 호출할 때 렌더링 품질 상태가 기존 상태로 변경되어 기본값으로 다시 설정됩니다.
적용 대상
BeginContainer(Rectangle, Rectangle, GraphicsUnit)
- Source:
- Graphics.cs
- Source:
- Graphics.cs
- Source:
- Graphics.cs
그래픽 컨테이너를 이 Graphics의 현재 상태로 저장하고 지정된 크기 조정 변환으로 새 그래픽 컨테이너를 열어 사용합니다.
public:
System::Drawing::Drawing2D::GraphicsContainer ^ BeginContainer(System::Drawing::Rectangle dstrect, System::Drawing::Rectangle srcrect, System::Drawing::GraphicsUnit unit);
public System.Drawing.Drawing2D.GraphicsContainer BeginContainer (System.Drawing.Rectangle dstrect, System.Drawing.Rectangle srcrect, System.Drawing.GraphicsUnit unit);
member this.BeginContainer : System.Drawing.Rectangle * System.Drawing.Rectangle * System.Drawing.GraphicsUnit -> System.Drawing.Drawing2D.GraphicsContainer
Public Function BeginContainer (dstrect As Rectangle, srcrect As Rectangle, unit As GraphicsUnit) As GraphicsContainer
매개 변수
- unit
- GraphicsUnit
컨테이너의 측정 단위를 지정하는 GraphicsUnit 열거형의 멤버입니다.
반환
이 메서드는 호출되었을 때 이 Graphics의 상태를 나타내는 GraphicsContainer를 반환합니다.
예제
다음 코드 예제는 Windows Forms 사용하도록 설계되었으며 이벤트 처리기의 Paint 매개 변수인 가 필요합니다.PaintEventArgse
코드는 다음 작업을 수행합니다.
두 개의 사각형을 만들어 새 컨테이너에 대한 크기 조정 변환을 지정합니다.
새 그래픽 컨테이너를 열고 이전 컨테이너를 저장합니다.
새 컨테이너의 (크기 조정된 좌표)에 빨간색 사각형을 채웁니다.
새 컨테이너를 닫고 저장된 컨테이너를 복원합니다.
저장된 컨테이너의 녹색 사각형(크기가 조정되지 않은 좌표)을 채웁니다.
그 결과 더 작은 빨간색 사각형의 기초가 되는 녹색 사각형이 생성됩니다.
private:
void BeginContainerRectangle( PaintEventArgs^ e )
{
// Define transformation for container.
Rectangle srcRect = Rectangle(0,0,200,200);
Rectangle destRect = Rectangle(100,100,150,150);
// Begin graphics container.
GraphicsContainer^ containerState = e->Graphics->BeginContainer( destRect, srcRect, GraphicsUnit::Pixel );
// Fill red rectangle in container.
e->Graphics->FillRectangle( gcnew SolidBrush( Color::Red ), 0, 0, 200, 200 );
// End graphics container.
e->Graphics->EndContainer( containerState );
// Fill untransformed rectangle with green.
e->Graphics->FillRectangle( gcnew SolidBrush( Color::Green ), 0, 0, 200, 200 );
}
private void BeginContainerRectangle(PaintEventArgs e)
{
// Define transformation for container.
Rectangle srcRect = new Rectangle(0, 0, 200, 200);
Rectangle destRect = new Rectangle(100, 100, 150, 150);
// Begin graphics container.
GraphicsContainer containerState = e.Graphics.BeginContainer(
destRect, srcRect,
GraphicsUnit.Pixel);
// Fill red rectangle in container.
e.Graphics.FillRectangle(new SolidBrush(Color.Red), 0, 0, 200, 200);
// End graphics container.
e.Graphics.EndContainer(containerState);
// Fill untransformed rectangle with green.
e.Graphics.FillRectangle(new SolidBrush(Color.Green), 0, 0, 200, 200);
}
Private Sub BeginContainerRectangle(ByVal e As PaintEventArgs)
' Define transformation for container.
Dim srcRect As New Rectangle(0, 0, 200, 200)
Dim destRect As New Rectangle(100, 100, 150, 150)
' Begin graphics container.
Dim containerState As GraphicsContainer = _
e.Graphics.BeginContainer(destRect, srcRect, GraphicsUnit.Pixel)
' Fill red rectangle in container.
e.Graphics.FillRectangle(New SolidBrush(Color.Red), 0, 0, 200, 200)
' End graphics container.
e.Graphics.EndContainer(containerState)
' Fill untransformed rectangle with green.
e.Graphics.FillRectangle(New SolidBrush(Color.Green), 0, 0, _
200, 200)
End Sub
설명
메서드와 함께 이 메서드를 EndContainer 사용하여 중첩된 그래픽 컨테이너를 만듭니다. 그래픽 컨테이너는 변환, 클리핑 영역 및 렌더링 속성과 같은 그래픽 상태를 유지합니다.
의 메서드를 BeginContainerGraphics호출하면 의 Graphics 상태를 보유하는 정보 블록이 스택에 배치됩니다. 메서드는 BeginContainer 해당 정보 블록을 식별하는 을 반환 GraphicsContainer 합니다. 식별 개체를 메서드에 EndContainer 전달하면 정보 블록이 스택에서 제거되고 를 메서드 호출 당시의 BeginContainer 상태로 복원 Graphics 하는 데 사용됩니다.
컨테이너를 중첩할 수 있습니다. 즉, 메서드를 호출하기 전에 메서드를 BeginContainer 여러 번 호출할 EndContainer 수 있습니다. 메서드를 BeginContainer 호출할 때마다 정보 블록이 스택에 배치되고 정보 블록에 대한 을 GraphicsContainer 받습니다. 이러한 개체 중 하나를 메서드 Graphics 에 EndContainer 전달하면 는 특정 GraphicsContainer를 반환한 메서드 호출 당시의 BeginContainer 상태로 반환됩니다. 해당 BeginContainer 메서드 호출을 통해 스택에 배치된 정보 블록이 스택에서 제거되고 해당 BeginContainer 메서드 호출 후 해당 스택에 배치된 모든 정보 블록도 제거됩니다.
메서드에 대한 호출은 Save 메서드에 대한 호출과 동일한 스택에 정보 블록을 배치합니다 BeginContainer . EndContainer 메서드 호출이 메서드 호출 Restore 과 쌍을 BeginContainer 이루는 것처럼 메서드 호출은 메서드 호출과 쌍을 이릅니다Save.
메서드를 EndContainer 호출하면 메서드에 대한 해당 호출 BeginContainer 후 스택에 배치된 모든 정보 블록(Save메서드 또는 BeginContainer 메서드)이 스택에서 제거됩니다. 마찬가지로 메서드를 Restore 호출하면 메서드에 대한 해당 호출 Save 후 스택에 배치된 모든 정보 블록(Save메서드 또는 BeginContainer 메서드)이 스택에서 제거됩니다.
이 메서드는 및 srcrect
매개 변수를 사용하여 새 그래픽 컨테이너에 대한 배율 변환을 dstrect
지정합니다. 눈금은 에 적용 srcrect
할 때 가 생성되는 변환과 dstrect
같습니다.
메서드에 의해 BeginContainer 설정된 그래픽 상태에는 기본 그래픽 상태의 렌더링 품질이 포함됩니다. 메서드를 호출할 때 렌더링 품질 상태가 기존 상태로 변경되어 기본값으로 다시 설정됩니다.
적용 대상
BeginContainer(RectangleF, RectangleF, GraphicsUnit)
- Source:
- Graphics.cs
- Source:
- Graphics.cs
- Source:
- Graphics.cs
그래픽 컨테이너를 이 Graphics의 현재 상태로 저장하고 지정된 크기 조정 변환으로 새 그래픽 컨테이너를 열어 사용합니다.
public:
System::Drawing::Drawing2D::GraphicsContainer ^ BeginContainer(System::Drawing::RectangleF dstrect, System::Drawing::RectangleF srcrect, System::Drawing::GraphicsUnit unit);
public System.Drawing.Drawing2D.GraphicsContainer BeginContainer (System.Drawing.RectangleF dstrect, System.Drawing.RectangleF srcrect, System.Drawing.GraphicsUnit unit);
member this.BeginContainer : System.Drawing.RectangleF * System.Drawing.RectangleF * System.Drawing.GraphicsUnit -> System.Drawing.Drawing2D.GraphicsContainer
Public Function BeginContainer (dstrect As RectangleF, srcrect As RectangleF, unit As GraphicsUnit) As GraphicsContainer
매개 변수
- dstrect
- RectangleF
srcrect
매개 변수로 새 그래픽 컨테이너의 크기 조정 변환을 지정하는 RectangleF 구조체입니다.
- srcrect
- RectangleF
dstrect
매개 변수로 새 그래픽 컨테이너의 크기 조정 변환을 지정하는 RectangleF 구조체입니다.
- unit
- GraphicsUnit
컨테이너의 측정 단위를 지정하는 GraphicsUnit 열거형의 멤버입니다.
반환
이 메서드는 호출되었을 때 이 Graphics의 상태를 나타내는 GraphicsContainer를 반환합니다.
예제
다음 코드 예제는 Windows Forms 사용하도록 설계되었으며 이벤트 처리기의 Paint 매개 변수인 가 필요합니다.PaintEventArgse
코드는 다음 작업을 수행합니다.
두 개의 사각형을 만들어 새 컨테이너에 대한 크기 조정 변환을 지정합니다.
새 그래픽 컨테이너를 열고 이전 컨테이너를 저장합니다.
새 컨테이너의 (크기 조정된 좌표)에 빨간색 사각형을 채웁니다.
새 컨테이너를 닫고 저장된 컨테이너를 복원합니다.
저장된 컨테이너의 녹색 사각형(크기가 조정되지 않은 좌표)을 채웁니다.
그 결과 더 작은 빨간색 사각형의 기초가 되는 녹색 사각형이 생성됩니다.
private:
void BeginContainerRectangleF( PaintEventArgs^ e )
{
// Define transformation for container.
RectangleF srcRect = RectangleF(0.0F,0.0F,200.0F,200.0F);
RectangleF destRect = RectangleF(100.0F,100.0F,150.0F,150.0F);
// Begin graphics container.
GraphicsContainer^ containerState = e->Graphics->BeginContainer( destRect, srcRect, GraphicsUnit::Pixel );
// Fill red rectangle in container.
e->Graphics->FillRectangle( gcnew SolidBrush( Color::Red ), 0.0F, 0.0F, 200.0F, 200.0F );
// End graphics container.
e->Graphics->EndContainer( containerState );
// Fill untransformed rectangle with green.
e->Graphics->FillRectangle( gcnew SolidBrush( Color::Green ), 0.0F, 0.0F, 200.0F, 200.0F );
}
private void BeginContainerRectangleF(PaintEventArgs e)
{
// Define transformation for container.
RectangleF srcRect = new RectangleF(0.0F, 0.0F, 200.0F, 200.0F);
RectangleF destRect = new RectangleF(100.0F, 100.0F, 150.0F, 150.0F);
// Begin graphics container.
GraphicsContainer containerState = e.Graphics.BeginContainer(
destRect, srcRect,
GraphicsUnit.Pixel);
// Fill red rectangle in container.
e.Graphics.FillRectangle(new SolidBrush(Color.Red), 0.0F, 0.0F, 200.0F, 200.0F);
// End graphics container.
e.Graphics.EndContainer(containerState);
// Fill untransformed rectangle with green.
e.Graphics.FillRectangle(new SolidBrush(Color.Green), 0.0F, 0.0F, 200.0F, 200.0F);
}
Private Sub BeginContainerRectangleF(ByVal e As PaintEventArgs)
' Define transformation for container.
Dim srcRect As New RectangleF(0.0F, 0.0F, 200.0F, 200.0F)
Dim destRect As New RectangleF(100.0F, 100.0F, 150.0F, 150.0F)
' Begin graphics container.
Dim containerState As GraphicsContainer = _
e.Graphics.BeginContainer(destRect, srcRect, GraphicsUnit.Pixel)
' Fill red rectangle in container.
e.Graphics.FillRectangle(New SolidBrush(Color.Red), 0.0F, 0.0F, _
200.0F, 200.0F)
' End graphics container.
e.Graphics.EndContainer(containerState)
' Fill untransformed rectangle with green.
e.Graphics.FillRectangle(New SolidBrush(Color.Green), 0.0F, 0.0F, _
200.0F, 200.0F)
End Sub
설명
메서드와 함께 이 메서드를 EndContainer 사용하여 중첩된 그래픽 컨테이너를 만듭니다. 그래픽 컨테이너는 변환, 클리핑 영역 및 렌더링 속성과 같은 그래픽 상태를 유지합니다.
의 메서드를 BeginContainerGraphics호출하면 의 Graphics 상태를 보유하는 정보 블록이 스택에 배치됩니다. 메서드는 BeginContainer 해당 정보 블록을 식별하는 을 반환 GraphicsContainer 합니다. 식별 개체를 메서드에 EndContainer 전달하면 정보 블록이 스택에서 제거되고 를 메서드 호출 당시의 BeginContainer 상태로 복원 Graphics 하는 데 사용됩니다.
컨테이너를 중첩할 수 있습니다. 즉, 메서드를 호출하기 전에 메서드를 BeginContainer 여러 번 호출할 EndContainer 수 있습니다. 메서드를 BeginContainer 호출할 때마다 정보 블록이 스택에 배치되고 정보 블록에 대한 을 GraphicsContainer 받습니다. 이러한 개체 중 하나를 메서드 Graphics 에 EndContainer 전달하면 는 특정 GraphicsContainer를 반환한 메서드 호출 당시의 BeginContainer 상태로 반환됩니다. 해당 BeginContainer 메서드 호출을 통해 스택에 배치된 정보 블록이 스택에서 제거되고 해당 BeginContainer 메서드 호출 후 해당 스택에 배치된 모든 정보 블록도 제거됩니다.
메서드에 대한 호출은 Save 메서드에 대한 호출과 동일한 스택에 정보 블록을 배치합니다 BeginContainer . EndContainer 메서드 호출이 메서드 호출 Restore 과 쌍을 BeginContainer 이루는 것처럼 메서드 호출은 메서드 호출과 쌍을 이릅니다Save.
메서드를 EndContainer 호출하면 메서드에 대한 해당 호출 BeginContainer 후 스택에 배치된 모든 정보 블록(Save
메서드 또는 BeginContainer 메서드)이 스택에서 제거됩니다. 마찬가지로 메서드를 Restore 호출하면 메서드에 대한 해당 호출 Save 후 스택에 배치된 모든 정보 블록(Save메서드 또는 BeginContainer 메서드)이 스택에서 제거됩니다.
이 메서드는 및 srcrect
매개 변수를 사용하여 새 그래픽 컨테이너에 대한 배율 변환을 dstrect
지정합니다. 눈금은 에 적용 srcrect
할 때 가 생성되는 변환과 dstrect
같습니다.
메서드에 의해 BeginContainer 설정된 그래픽 상태에는 기본 그래픽 상태의 렌더링 품질이 포함됩니다. 메서드를 호출할 때 렌더링 품질 상태가 기존 상태로 변경되어 기본값으로 다시 설정됩니다.
적용 대상
.NET
피드백
https://aka.ms/ContentUserFeedback
출시 예정: 2024년 내내 콘텐츠에 대한 피드백 메커니즘으로 GitHub 문제를 단계적으로 폐지하고 이를 새로운 피드백 시스템으로 바꿀 예정입니다. 자세한 내용은 다음을 참조하세요.다음에 대한 사용자 의견 제출 및 보기