StrokeCollection.Draw(DrawingContext) 메서드
정의
중요
일부 정보는 릴리스되기 전에 상당 부분 수정될 수 있는 시험판 제품과 관련이 있습니다. Microsoft는 여기에 제공된 정보에 대해 어떠한 명시적이거나 묵시적인 보증도 하지 않습니다.
StrokeCollection의 스트로크를 그립니다.
public:
void Draw(System::Windows::Media::DrawingContext ^ context);
public void Draw (System.Windows.Media.DrawingContext context);
member this.Draw : System.Windows.Media.DrawingContext -> unit
Public Sub Draw (context As DrawingContext)
매개 변수
- context
- DrawingContext
DrawingContext을 그릴 StrokeCollection입니다.
예제
다음 예제에서는 미리 보기를 표시 하는 사용자 지정 요소는 InkCanvas합니다. 사용자 지정 요소에 대 한 참조를 유지는 InkCanvas 자신을 다시 그리면 및 경우를 StrokeCollected 이벤트가 발생 합니다.
public class InkThumbnail : FrameworkElement
{
private InkCanvas sourceInkCanvas = null;
// Get the InkCanvas that the user draws on.
public InkCanvas Source
{
get
{
return sourceInkCanvas;
}
set
{
if (sourceInkCanvas != null)
{
// Detach the event handler from the former InkCanvas.
sourceInkCanvas.StrokeCollected -= new InkCanvasStrokeCollectedEventHandler(SourceChanged);
}
sourceInkCanvas = value;
if (sourceInkCanvas != null)
{
// Attach the even handler to the InkCannvas
sourceInkCanvas.StrokeCollected += new InkCanvasStrokeCollectedEventHandler(SourceChanged);
}
}
}
// Handle the StrokeCollection event of the InkCanvas.
private void SourceChanged(object sender, InkCanvasStrokeCollectedEventArgs e)
{
// Cause the thumbnail to be redrawn.
this.InvalidateVisual();
}
protected override void OnRender(DrawingContext drawingContext)
{
base.OnRender(drawingContext);
// Draw the strokes from the InkCanvas at 1/4 of their size.
drawingContext.PushTransform(new ScaleTransform(0.25, 0.25));
if (sourceInkCanvas != null)
{
sourceInkCanvas.Strokes.Draw(drawingContext);
}
}
}
Public Class InkThumbnail
Inherits FrameworkElement
Private sourceInkCanvas As InkCanvas = Nothing
' Get the InkCanvas that the user draws on.
Public Property Source() As InkCanvas
Get
Return sourceInkCanvas
End Get
Set(ByVal Value As InkCanvas)
If Not sourceInkCanvas Is Nothing Then
' Detach the event handler from the former InkCanvas.
RemoveHandler sourceInkCanvas.StrokeCollected, AddressOf SourceChanged
End If
sourceInkCanvas = Value
If Not sourceInkCanvas Is Nothing Then
' Attach the even handler to the InkCannvas
AddHandler sourceInkCanvas.StrokeCollected, AddressOf SourceChanged
End If
End Set
End Property
' Handle the StrokeCollection event of the InkCanvas.
Private Sub SourceChanged(ByVal sender As Object, ByVal e As InkCanvasStrokeCollectedEventArgs)
' Cause the thumbnail to be redrawn.
Me.InvalidateVisual()
End Sub
Protected Overrides Sub OnRender(ByVal drawingContext As DrawingContext)
MyBase.OnRender(drawingContext)
' Draw the strokes from the InkCanvas at 1/4 of their size.
drawingContext.PushTransform(New ScaleTransform(0.25, 0.25))
If Not sourceInkCanvas Is Nothing Then
sourceInkCanvas.Strokes.Draw(drawingContext)
End If
End Sub
End Class
적용 대상
GitHub에서 Microsoft와 공동 작업
이 콘텐츠의 원본은 GitHub에서 찾을 수 있으며, 여기서 문제와 끌어오기 요청을 만들고 검토할 수도 있습니다. 자세한 내용은 참여자 가이드를 참조하세요.
.NET