Partilhar via


DynamicRenderer.OnDraw Método

Definição

Desenha a tinta em tempo real para que ela pareça “fluir” da caneta eletrônica ou outro dispositivo apontador.

protected:
 virtual void OnDraw(System::Windows::Media::DrawingContext ^ drawingContext, System::Windows::Input::StylusPointCollection ^ stylusPoints, System::Windows::Media::Geometry ^ geometry, System::Windows::Media::Brush ^ fillBrush);
protected virtual void OnDraw (System.Windows.Media.DrawingContext drawingContext, System.Windows.Input.StylusPointCollection stylusPoints, System.Windows.Media.Geometry geometry, System.Windows.Media.Brush fillBrush);
abstract member OnDraw : System.Windows.Media.DrawingContext * System.Windows.Input.StylusPointCollection * System.Windows.Media.Geometry * System.Windows.Media.Brush -> unit
override this.OnDraw : System.Windows.Media.DrawingContext * System.Windows.Input.StylusPointCollection * System.Windows.Media.Geometry * System.Windows.Media.Brush -> unit
Protected Overridable Sub OnDraw (drawingContext As DrawingContext, stylusPoints As StylusPointCollection, geometry As Geometry, fillBrush As Brush)

Parâmetros

drawingContext
DrawingContext

O objeto DrawingContext no qual o traço é renderizado.

stylusPoints
StylusPointCollection

O StylusPointCollection que representa o segmento do traço a ser desenhado.

geometry
Geometry

Um Geometry que representa o caminho do ponteiro do mouse.

fillBrush
Brush

Um Pincel que especifica a aparência do traço atual.

Exemplos

O exemplo a seguir demonstra como substituir o OnDraw método para renderizar dinamicamente a tinta digital com um LinearGradientBrush.

protected override void OnDraw(DrawingContext drawingContext,
                               StylusPointCollection stylusPoints,
                               Geometry geometry, Brush fillBrush)
{
    // Create a new Brush, if necessary
    if (brush == null)
    {
        Color primaryColor;

        if (fillBrush is SolidColorBrush)
        {
            primaryColor = ((SolidColorBrush)fillBrush).Color;
        }
        else
        {
            primaryColor = Colors.Red;
        }

        brush = new LinearGradientBrush(Colors.Blue, primaryColor, 20d);
    }

    drawingContext.DrawGeometry(brush, null, geometry);
}
Protected Overrides Sub OnDraw(ByVal drawingContext As DrawingContext, _
                               ByVal stylusPoints As StylusPointCollection, _
                               ByVal geometry As Geometry, _
                               ByVal fillBrush As Brush)

    ' Create a new Brush, if necessary
    If brush Is Nothing Then

        Dim primaryColor As Color

        If TypeOf fillBrush Is SolidColorBrush Then
            primaryColor = CType(fillBrush, SolidColorBrush).Color
        Else
            primaryColor = Colors.Red
        End If

        brush = New LinearGradientBrush(Colors.Blue, primaryColor, 20.0)

    End If

    drawingContext.DrawGeometry(brush, Nothing, geometry)

End Sub

Notas aos Herdeiros

Ao substituir OnDraw(DrawingContext, StylusPointCollection, Geometry, Brush) em uma classe derivada, certifique-se de chamar o método da OnDraw(DrawingContext, StylusPointCollection, Geometry, Brush) classe base.

Aplica-se a