DynamicRenderer.OnDraw Methode

Definition

Zeichnet die Freihandeingabe in Echtzeit, sodass diese scheinbar aus dem Tablettstift oder einem anderen Zeigegerät "fließt".

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)

Parameter

drawingContext
DrawingContext

Das DrawingContext-Objekt, auf dem der Strich gerendert wird.

stylusPoints
StylusPointCollection

Die StylusPointCollection, die das Segment des zu zeichnenden Strichs darstellt.

geometry
Geometry

Eine Geometry, die den Pfad des Mauszeigers darstellt.

fillBrush
Brush

Ein Pinsel, der die Darstellung des aktuellen Strichs angibt.

Beispiele

Im folgenden Beispiel wird veranschaulicht, wie Sie die OnDraw Methode überschreiben, um digitale Freihand mit einem LinearGradientBrushdynamischen Rendern von Freihand zu rendern.

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

Hinweise für Vererber

Wenn sie in einer abgeleiteten Klasse außer Kraft gesetzt werden OnDraw(DrawingContext, StylusPointCollection, Geometry, Brush) , müssen Sie die Basisklasse-Methode OnDraw(DrawingContext, StylusPointCollection, Geometry, Brush) aufrufen.

Gilt für