Editar

Compartir vía


DynamicRenderer.OnDraw Method

Definition

Draws the ink in real-time so it appears to "flow" from the tablet pen or other pointing device.

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)

Parameters

drawingContext
DrawingContext

The DrawingContext object onto which the stroke is rendered.

stylusPoints
StylusPointCollection

The StylusPointCollection that represents the segment of the stroke to draw.

geometry
Geometry

A Geometry that represents the path of the mouse pointer.

fillBrush
Brush

A Brush that specifies the appearance of the current stroke.

Examples

The following example demonstrates how to override the OnDraw method to dynamically render digital ink with a 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

Notes to Inheritors

When overriding OnDraw(DrawingContext, StylusPointCollection, Geometry, Brush) in a derived class, be sure to call the base class' OnDraw(DrawingContext, StylusPointCollection, Geometry, Brush) method.

Applies to