Export (0) Print
Expand All

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

Windows 8.1, Windows Server 2012 R2, Windows 8, Windows Server 2012, Windows 7, Windows Vista SP2, Windows Server 2008 (Server Core Role not supported), Windows Server 2008 R2 (Server Core Role supported with SP1 or later; Itanium not supported)

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

Show:
© 2014 Microsoft