Język

DynamicRenderer.OnDraw Metoda

Definicja

Rysuje atrament w czasie rzeczywistym, więc wydaje się "przepływać" z pióra tabletu lub innego urządzenia wskazującego.

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)

Parametry

drawingContext
DrawingContext

Obiekt DrawingContext , na którym jest renderowany pociągnięcie.

stylusPoints
StylusPointCollection

Element StylusPointCollection reprezentujący segment pociągnięcia do rysowania.

geometry
Geometry

Element Geometry reprezentujący ścieżkę wskaźnika myszy.

fillBrush
Brush

Szczotka określająca wygląd bieżącego pociągnięcia.

Przykłady

W poniższym przykładzie pokazano, jak zastąpić metodę OnDraw dynamicznego renderowania cyfrowego pisma odręcznego za pomocą elementu 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

Notatki dotyczące dziedziczenia

Podczas zastępowania OnDraw(DrawingContext, StylusPointCollection, Geometry, Brush) klasy pochodnej należy wywołać metodę klasy OnDraw(DrawingContext, StylusPointCollection, Geometry, Brush) bazowej.

Dotyczy