DynamicRenderer.OnDraw Method

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

Namespace:  System.Windows.Input.StylusPlugIns
Assembly:  PresentationCore (in PresentationCore.dll)

protected virtual void OnDraw(
	DrawingContext drawingContext,
	StylusPointCollection stylusPoints,
	Geometry geometry,
	Brush fillBrush
)

Parameters

drawingContext
Type: System.Windows.Media.DrawingContext

The DrawingContext object onto which the stroke is rendered.

stylusPoints
Type: System.Windows.Input.StylusPointCollection

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

geometry
Type: System.Windows.Media.Geometry

A Geometry that represents the path of the mouse pointer.

fillBrush
Type: System.Windows.Media.Brush

A Brush that specifies the appearance of the current stroke.

Notes to Inheritors

When overriding OnDraw in a derived class, be sure to call the base class’s OnDraw method.

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);

}

.NET Framework

Supported in: 4.6, 4.5, 4, 3.5, 3.0

.NET Framework Client Profile

Supported in: 4, 3.5 SP1
Was this page helpful?
(1500 characters remaining)
Thank you for your feedback
Show:
© 2015 Microsoft