DrawingContext 클래스

정의

그리기, 푸시 및 팝 명령을 사용하여 표시 내용을 설명합니다.Describes visual content using draw, push, and pop commands.

public ref class DrawingContext abstract : System::Windows::Threading::DispatcherObject, IDisposable
public abstract class DrawingContext : System.Windows.Threading.DispatcherObject, IDisposable
type DrawingContext = class
    inherit DispatcherObject
    interface IDisposable
Public MustInherit Class DrawingContext
Inherits DispatcherObject
Implements IDisposable
상속
DrawingContext
구현

예제

다음 예제에서는 검색 된 DrawingContext 에서 DrawingVisual 사각형 그리기를 사용 하 여 합니다.The following example retrieves a DrawingContext from a DrawingVisual and uses it to draw a rectangle.

// Create a DrawingVisual that contains a rectangle.
private DrawingVisual CreateDrawingVisualRectangle()
{
    DrawingVisual drawingVisual = new DrawingVisual();

    // Retrieve the DrawingContext in order to create new drawing content.
    DrawingContext drawingContext = drawingVisual.RenderOpen();

    // Create a rectangle and draw it in the DrawingContext.
    Rect rect = new Rect(new System.Windows.Point(160, 100), new System.Windows.Size(320, 80));
    drawingContext.DrawRectangle(System.Windows.Media.Brushes.LightBlue, (System.Windows.Media.Pen)null, rect);

    // Persist the drawing content.
    drawingContext.Close();

    return drawingVisual;
}
' Create a DrawingVisual that contains a rectangle.
Private Function CreateDrawingVisualRectangle() As DrawingVisual
    Dim drawingVisual As New DrawingVisual()

    ' Retrieve the DrawingContext in order to create new drawing content.
    Dim drawingContext As DrawingContext = drawingVisual.RenderOpen()

    ' Create a rectangle and draw it in the DrawingContext.
    Dim rect As New Rect(New Point(160, 100), New Size(320, 80))
    drawingContext.DrawRectangle(Brushes.LightBlue, CType(Nothing, Pen), rect)

    ' Persist the drawing content.
    drawingContext.Close()

    Return drawingVisual
End Function

다음 예제에 PushOpacity, PushEffect, 및 Pop 명령입니다.The next example demonstrates the PushOpacity, PushEffect, and Pop commands. 합니다 DrawingContext 에서 가져온를 DrawingGroup 사용 하 여 표시 하 고는 Image 제어 합니다.The DrawingContext is obtained from a DrawingGroup and displayed using an Image control.

using System;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Navigation;
using System.Windows.Media.Effects;

namespace SDKSample
{


    public class PushEffectExample : Page
    {

        public PushEffectExample()
        {
            Pen shapeOutlinePen = new Pen(Brushes.Black, 2);
            shapeOutlinePen.Freeze();

            // Create a DrawingGroup
            DrawingGroup dGroup = new DrawingGroup();

            // Obtain a DrawingContext from 
            // the DrawingGroup.
            using (DrawingContext dc = dGroup.Open())
            {
                // Draw a rectangle at full opacity.
                dc.DrawRectangle(Brushes.Blue, shapeOutlinePen, new Rect(0, 0, 25, 25));

                // Push an opacity change of 0.5. 
                // The opacity of each subsequent drawing will
                // will be multiplied by 0.5.
                dc.PushOpacity(0.5);

                // This rectangle is drawn at 50% opacity.
                dc.DrawRectangle(Brushes.Blue, shapeOutlinePen, new Rect(25, 25, 25, 25));

                // Blurs subsquent drawings. 
                dc.PushEffect(new BlurBitmapEffect(), null);

                // This rectangle is blurred and drawn at 50% opacity (0.5 x 0.5). 
                dc.DrawRectangle(Brushes.Blue, shapeOutlinePen, new Rect(50, 50, 25, 25));

                // This rectangle is also blurred and drawn at 50% opacity.
                dc.DrawRectangle(Brushes.Blue, shapeOutlinePen, new Rect(75, 75, 25, 25));

                // Stop applying the blur to subsquent drawings.
                dc.Pop();

                // This rectangle is drawn at 50% opacity with no blur effect.
                dc.DrawRectangle(Brushes.Blue, shapeOutlinePen, new Rect(100, 100, 25, 25));
            }

            // Display the drawing using an image control.
            Image theImage = new Image();
            DrawingImage dImageSource = new DrawingImage(dGroup);
            theImage.Source = dImageSource;

            this.Content = theImage;

        }




    }

}
Imports System.Windows.Media.Animation
Imports System.Windows.Media.Effects

Namespace SDKSample


    Public Class PushEffectExample
        Inherits Page

        Public Sub New()
            Dim shapeOutlinePen As New Pen(Brushes.Black, 2)
            shapeOutlinePen.Freeze()

            ' Create a DrawingGroup
            Dim dGroup As New DrawingGroup()

            ' Obtain a DrawingContext from 
            ' the DrawingGroup.
            Using dc As DrawingContext = dGroup.Open()
                ' Draw a rectangle at full opacity.
                dc.DrawRectangle(Brushes.Blue, shapeOutlinePen, New Rect(0, 0, 25, 25))

                ' Push an opacity change of 0.5. 
                ' The opacity of each subsequent drawing will
                ' will be multiplied by 0.5.
                dc.PushOpacity(0.5)

                ' This rectangle is drawn at 50% opacity.
                dc.DrawRectangle(Brushes.Blue, shapeOutlinePen, New Rect(25, 25, 25, 25))

                ' Blurs subsquent drawings. 
                dc.PushEffect(New BlurBitmapEffect(), Nothing)

                ' This rectangle is blurred and drawn at 50% opacity (0.5 x 0.5). 
                dc.DrawRectangle(Brushes.Blue, shapeOutlinePen, New Rect(50, 50, 25, 25))

                ' This rectangle is also blurred and drawn at 50% opacity.
                dc.DrawRectangle(Brushes.Blue, shapeOutlinePen, New Rect(75, 75, 25, 25))

                ' Stop applying the blur to subsquent drawings.
                dc.Pop()

                ' This rectangle is drawn at 50% opacity with no blur effect.
                dc.DrawRectangle(Brushes.Blue, shapeOutlinePen, New Rect(100, 100, 25, 25))
            End Using

            ' Display the drawing using an image control.
            Dim theImage As New Image()
            Dim dImageSource As New DrawingImage(dGroup)
            theImage.Source = dImageSource

            Me.Content = theImage

        End Sub




    End Class

End Namespace

설명

사용 하 여는 DrawingContext 채우는 데는 Visual 또는 Drawing 시각적 콘텐츠를 사용 하 여 합니다.Use a DrawingContext to populate a Visual or a Drawing with visual content.

있지만 DrawingContext 그리기 메서드 그리기 메서드와 유사 합니다 System.Drawing.Graphics 형식이 작동 되도록 매우 다른 방식으로: DrawingContext 는 유지 모드 그래픽 시스템을 사용 하 여 사용를 System.Drawing.Graphics 형식은 직접 실행 모드를 사용 하 여 사용 됩니다 그래픽 시스템입니다.Although the DrawingContext draw methods appear similar to the draw methods of the System.Drawing.Graphics type, they function very differently: DrawingContext is used with a retained mode graphics system, while the System.Drawing.Graphics type is used with an immediate mode graphics system. DrawingContext 개체의 그리기 명령을 사용하는 경우 실제로 나중에 그래픽 시스템에서 사용될 렌더링 명령 집합을 저장하게 되며 (정확한 스토리지 메커니즘은 DrawingContext를 제공하는 개체의 형식에 따라 다름) 실시간으로 화면에 그리지 않습니다.When you use a DrawingContext object's draw commands, you are actually storing a set of rendering instructions (although the exact storage mechanism depends on the type of object that supplies the DrawingContext) that will later be used by the graphics system; you are not drawing to the screen in real-time. Windows Presentation Foundation (WPF) 그래픽 시스템의 작동 방식에 대 한 자세한 내용은 참조 하세요. WPF 그래픽 렌더링 개요합니다.For more information about how the Windows Presentation Foundation (WPF) graphics system works, see WPF Graphics Rendering Overview.

절대 직접 인스턴스화하지를 DrawingContext; 얻을 수 있습니다, 있지만 특정 메서드에서 그리기 컨텍스트 등 DrawingGroup.OpenDrawingVisual.RenderOpen입니다.You never directly instantiate a DrawingContext; you can, however, acquire a drawing context from certain methods, such as DrawingGroup.Open and DrawingVisual.RenderOpen.

속성

Dispatcher

Dispatcher와 연결된 DispatcherObject를 가져옵니다.Gets the Dispatcher this DispatcherObject is associated with.

(다음에서 상속됨 DispatcherObject)

메서드

CheckAccess()

호출 스레드가 이 DispatcherObject에 액세스할 수 있는지 여부를 확인합니다.Determines whether the calling thread has access to this DispatcherObject.

(다음에서 상속됨 DispatcherObject)
Close()

DrawingContext를 닫고 내용을 플러시합니다.Closes the DrawingContext and flushes the content. 이후로는 DrawingContext를 수정할 수 없습니다.Afterward, the DrawingContext cannot be modified.

DisposeCore()

DrawingContext에서 사용하는 모든 리소스를 해제합니다.Releases all resources used by the DrawingContext.

DrawDrawing(Drawing)

지정한 Drawing 개체를 그립니다.Draws the specified Drawing object.

DrawEllipse(Brush, Pen, Point, AnimationClock, Double, AnimationClock, Double, AnimationClock)

지정한 BrushPen을 사용하여 타원을 그린 다음 지정한 애니메이션 Clock을 적용합니다.Draws an ellipse with the specified Brush and Pen and applies the specified animation clocks.

DrawEllipse(Brush, Pen, Point, Double, Double)

지정한 BrushPen을 사용하여 타원을 그립니다.Draws an ellipse with the specified Brush and Pen.

DrawGeometry(Brush, Pen, Geometry)

지정한 GeometryBrush을 사용하여 지정한 Pen를 그립니다.Draws the specified Geometry using the specified Brush and Pen.

DrawGlyphRun(Brush, GlyphRun)

지정한 텍스트를 그립니다.Draws the specified text.

DrawImage(ImageSource, Rect)

지정한 Rect에서 정의한 영역에 이미지를 그립니다.Draws an image into the region defined by the specified Rect.

DrawImage(ImageSource, Rect, AnimationClock)

지정한 Rect에서 정의한 영역에 이미지를 그린 다음 지정한 애니메이션 Clock을 적용합니다.Draws an image into the region defined by the specified Rect and applies the specified animation clock.

DrawLine(Pen, Point, AnimationClock, Point, AnimationClock)

지정한 Pen을 사용하여 지정한 점 사이에 선을 그린 다음 지정한 애니메이션 Clock을 적용합니다.Draws a line between the specified points using the specified Pen and applies the specified animation clocks.

DrawLine(Pen, Point, Point)

지정된 Pen을 사용하여 지정된 점 사이에 선을 그립니다.Draws a line between the specified points using the specified Pen.

DrawRectangle(Brush, Pen, Rect)

지정한 BrushPen을 사용하여 사각형을 그립니다.Draws a rectangle with the specified Brush and Pen. 펜과 브러시는 null일 수 있습니다.The pen and the brush can be null.

DrawRectangle(Brush, Pen, Rect, AnimationClock)

지정한 BrushPen을 사용하여 사각형을 그린 다음 지정한 애니메이션 Clock을 적용합니다.Draws a rectangle with the specified Brush and Pen and applies the specified animation clocks.

DrawRoundedRectangle(Brush, Pen, Rect, AnimationClock, Double, AnimationClock, Double, AnimationClock)

지정한 BrushPen을 사용하여 모퉁이가 둥근 사각형을 그린 다음 지정한 애니메이션 Clock을 적용합니다.Draws a rounded rectangle with the specified Brush and Pen and applies the specified animation clocks.

DrawRoundedRectangle(Brush, Pen, Rect, Double, Double)

지정한 BrushPen을 사용하여 둥근 사각형을 그립니다.Draws a rounded rectangle with the specified Brush and Pen.

DrawText(FormattedText, Point)

지정한 위치에 서식 있는 텍스트를 그립니다.Draws formatted text at the specified location.

DrawVideo(MediaPlayer, Rect)

지정한 영역에 비디오를 그립니다.Draws a video into the specified region.

DrawVideo(MediaPlayer, Rect, AnimationClock)

지정한 영역에 비디오를 그린 다음 지정한 애니메이션 Clock을 적용합니다.Draws a video into the specified region and applies the specified animation clock.

Equals(Object)

지정한 개체와 현재 개체가 같은지 여부를 확인합니다.Determines whether the specified object is equal to the current object.

(다음에서 상속됨 Object)
GetHashCode()

기본 해시 함수로 작동합니다.Serves as the default hash function.

(다음에서 상속됨 Object)
GetType()

현재 인스턴스의 Type을 가져옵니다.Gets the Type of the current instance.

(다음에서 상속됨 Object)
MemberwiseClone()

현재 Object의 단순 복사본을 만듭니다.Creates a shallow copy of the current Object.

(다음에서 상속됨 Object)
Pop()

그리기 컨텍스트에 푸시된 마지막 불투명 마스크, 불투명도, 클립, 효과 또는 변환 작업을 팝합니다.Pops the last opacity mask, opacity, clip, effect, or transform operation that was pushed onto the drawing context.

PushClip(Geometry)

지정한 클립 영역을 그리기 컨텍스트에 푸시합니다.Pushes the specified clip region onto the drawing context.

PushEffect(BitmapEffect, BitmapEffectInput)

지정한 BitmapEffect을 그리기 컨텍스트에 푸시합니다.Pushes the specified BitmapEffect onto the drawing context.

PushGuidelineSet(GuidelineSet)

지정한 GuidelineSet을 그리기 컨텍스트에 푸시합니다.Pushes the specified GuidelineSet onto the drawing context.

PushOpacity(Double)

지정한 불투명도 설정을 그리기 컨텍스트에 푸시합니다.Pushes the specified opacity setting onto the drawing context.

PushOpacity(Double, AnimationClock)

지정한 불투명도 설정을 그리기 컨텍스트에 푸시한 다음 지정한 애니메이션 Clock을 적용합니다.Pushes the specified opacity setting onto the drawing context and applies the specified animation clock.

PushOpacityMask(Brush)

지정한 불투명 마스크를 그리기 컨텍스트에 푸시합니다.Pushes the specified opacity mask onto the drawing context.

PushTransform(Transform)

지정한 Transform을 그리기 컨텍스트에 푸시합니다.Pushes the specified Transform onto the drawing context.

ToString()

현재 개체를 나타내는 문자열을 반환합니다.Returns a string that represents the current object.

(다음에서 상속됨 Object)
VerifyAccess()

호출 스레드에서 이 DispatcherObject에 액세스할 수 있는지 확인합니다.Enforces that the calling thread has access to this DispatcherObject.

(다음에서 상속됨 DispatcherObject)
VerifyApiNonstructuralChange()

이 멤버는 WPFWPF 인프라를 지원하며 코드에서 직접 사용할 수 없습니다.This member supports the WPFWPF infrastructure and is not intended to be used directly from your code.

명시적 인터페이스 구현

IDisposable.Dispose()

이 멤버는 WPF(Windows Presentation Foundation)Windows Presentation Foundation (WPF) 인프라를 지원하며 코드에서 직접 사용할 수 없습니다.This member supports the WPF(Windows Presentation Foundation)Windows Presentation Foundation (WPF) infrastructure and is not intended to be used directly from your code.

적용 대상

추가 정보