Stroke.Draw 方法

定義

根據 Stroke 來呈現 DrawingContext 物件。

多載

Draw(DrawingContext)

根據指定的 DrawingContext 來呈現 Stroke 物件。

Draw(DrawingContext, DrawingAttributes)

根據指定的 StrokeDrawingContext 來呈現 DrawingAttributes 物件。

Draw(DrawingContext)

根據指定的 DrawingContext 來呈現 Stroke 物件。

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 物件,筆劃將呈現於其中。

範例

下列範例示範如何使用 繪製 Stroke 物件 DrawingContext

protected DrawingVisual DrawDCOnly(Stroke myStroke)
{
    // Create new Visual context to draw on
    DrawingVisual myVisual = new DrawingVisual();
    DrawingContext myContext = myVisual.RenderOpen();

    // myMatrix is scaled by:
    // myMatrix.Scale(0.5, 0.5)
    myStroke.Transform(myMatrix, false);

    // Draw the stroke on the Visual context using DrawingContext
    myStroke.Draw(myContext);

    // Close the context
    myContext.Close();

    return myVisual;
}
Function DrawDCOnly(ByVal myStroke As Stroke) As DrawingVisual

    ' Create new Visual context to draw on
    Dim myVisual As DrawingVisual = New DrawingVisual()
    Dim myContext As DrawingContext = myVisual.RenderOpen()

    ' myMatrix is scaled by:
    ' myMatrix.Scale(0.5, 0.5)
    myStroke.Transform(myMatrix, False)

    ' Draw the stroke on the Visual context using DrawingContext
    myStroke.Draw(myContext)

    ' Close the context
    myContext.Close()

    Return myVisual

End Function

適用於

Draw(DrawingContext, DrawingAttributes)

根據指定的 StrokeDrawingContext 來呈現 DrawingAttributes 物件。

public:
 void Draw(System::Windows::Media::DrawingContext ^ drawingContext, System::Windows::Ink::DrawingAttributes ^ drawingAttributes);
public void Draw (System.Windows.Media.DrawingContext drawingContext, System.Windows.Ink.DrawingAttributes drawingAttributes);
member this.Draw : System.Windows.Media.DrawingContext * System.Windows.Ink.DrawingAttributes -> unit
Public Sub Draw (drawingContext As DrawingContext, drawingAttributes As DrawingAttributes)

參數

drawingContext
DrawingContext

DrawingContext 物件,筆劃將呈現於其中。

drawingAttributes
DrawingAttributes

定義繪製之筆劃屬性的 DrawingAttributes 物件。

範例

下列範例示範如何使用 和 DrawingAttributes 繪製 Stroke 物件 DrawingContext

protected DrawingVisual DrawDCandDA(Stroke myStroke)
{
    // Create new Visual context to draw on
    DrawingVisual myVisual = new DrawingVisual();
    DrawingContext myContext = myVisual.RenderOpen();

    // Draw stroke using DrawingContext and DrawingAttributes
    // (to make the stroke magenta)
    DrawingAttributes myDAs = new DrawingAttributes();
    myDAs.Color = Colors.Magenta;

    myStroke.Draw(myContext, myDAs);

    // Close the context
    myContext.Close();

    return myVisual;
}
Function DrawDCandDA(ByVal myStroke As Stroke) As DrawingVisual

    ' Create new Visual context to draw on
    Dim myVisual As DrawingVisual = New DrawingVisual()
    Dim myContext As DrawingContext = myVisual.RenderOpen()

    ' Draw stroke using DrawingContext and DrawingAttributes
    ' (to make the stroke magenta)
    Dim myDAs As DrawingAttributes = New DrawingAttributes()
    myDAs.Color = Colors.Magenta

    myStroke.Draw(myContext, myDAs)

    ' Close the context
    myContext.Close()

    Return myVisual

End Function

適用於