InkStroke InkStroke InkStroke InkStroke Class

Definition

A single ink stroke, including the Bézier curve parameters used for final rendering of the stroke.

public : sealed class InkStroke : IInkStroke, IInkStroke2, IInkStroke3
public sealed class InkStroke : IInkStroke, IInkStroke2, IInkStroke3
Public NotInheritable Class InkStroke Implements IInkStroke, IInkStroke2, IInkStroke3
// This class does not provide a public constructor.
Attributes
Windows 10 requirements
Device family
Windows 10 (introduced v10.0.10240.0 - for Xbox, see UWP features that aren't yet supported on Xbox)
API contract
Windows.Foundation.UniversalApiContract (introduced v1)

Examples

Here we iterate through each stroke in an InkManager and process them for final rendering using Bézier curves.

// Iterate through each stroke.
inkManager.getStrokes().forEach(
    function (stroke)
    {
        inkContext.beginPath();
        if (stroke.selected) {
            inkContext.lineWidth = stroke.drawingAttributes.size.width * 2;
            inkContext.strokeStyle = "green";
        } else {
            inkContext.lineWidth = stroke.drawingAttributes.size.width;
            inkContext.strokeStyle = "black";
        }

        // Enumerate through each line segment of the stroke.
        var first = true;

        stroke.getRenderingSegments().forEach(
            function (segment)
            {
                // Move to the starting screen location of the stroke.
                if (first)
                {
                    inkContext.moveTo(segment.position.x, segment.position.y);
                    first = false;
                }
                // Calculate the bezier curve for the segment.
                else
                {
                    inkContext.bezierCurveTo(segment.bezierControlPoint1.x,
                                             segment.bezierControlPoint1.y,
                                             segment.bezierControlPoint2.x,
                                             segment.bezierControlPoint2.y,
                                             segment.position.x, segment.position.y);
                }
            }
        );
        
        // Draw the stroke.
        inkContext.stroke();
        inkContext.closePath();
    }

Remarks

JavaScript (usage)
var inkStrokes = Windows.UI.Input.Inking.InkManager.getStrokes; var inkStroke = inkStrokes[...];
var inkStrokes = Windows.UI.Input.Inking.inkRecognitionResult.getStrokes; var inkStroke = inkStrokes[...];
var inkStrokes = Windows.UI.Input.Inking.inkStrokeContainer.getStrokes; var inkStroke = inkStrokes[...];

Note

: This class is not agile, which means that you need to consider its threading model and marshaling behavior. For more info, see Threading and Marshaling (C++/CX) and Using Windows Runtime objects in a multithreaded environment (.NET).

Properties

BoundingRect BoundingRect BoundingRect BoundingRect

Gets the bounding box for the InkStroke.

public : Rect BoundingRect { get; }
public Rect BoundingRect { get; }
Public ReadOnly Property BoundingRect As Rect
var rect = inkStroke.boundingRect;
Value
Rect Rect Rect Rect

The bounding box.

See Also

DrawingAttributes DrawingAttributes DrawingAttributes DrawingAttributes

Gets or sets the properties associated with an InkStroke.

public : InkDrawingAttributes DrawingAttributes { get; set; }
public InkDrawingAttributes DrawingAttributes { get; set; }
Public ReadWrite Property DrawingAttributes As InkDrawingAttributes
var inkDrawingAttributes = inkStroke.drawingAttributes;
inkStroke.drawingAttributes = inkDrawingAttributes;

Examples

The following example demonstrates how to set a drawing attribute for a specific stroke.

Note

You cannot set the DrawingAttributes property of the stroke directly. You must create a copy of the InkDrawingAttributes of the stroke, set the desired values for that InkDrawingAttributes object, and then assign the new InkDrawingAttributes to the DrawingAttributes of the stroke, as shown here.

inkManager.getStrokes().forEach(function (stroke)
{
  var drawingAttributes = stroke.drawingAttributes;
  drawingAttributes.penTip = 
       Windows.UI.Input.Inking.PenTipShape.rectangle;
  stroke.drawingAttributes = drawingAttributes;
}

// Get the InkStroke objects.
IReadOnlyList<InkStroke> inkStrokes = inkManager.GetStrokes();
Windows.UI.Input.Inking.InkStroke cloneStroke = 
  inkStrokes.GetAt(index).Clone();
Windows.UI.Input.Inking.InkDrawingAttributes drawingAttributes = 
  cloneStroke.DrawingAttributes;
drawingAttributes.PenTip = Windows.UI.Input.Inking.PenTipShape.Rectangle;
cloneStroke.DrawingAttributes = drawingAttributes;

For the complete example, see Ink App sample.

See Also

Id Id Id Id

Gets the the ink stroke identifier.

A unique identifier is assigned to each ink stroke managed by the InkPresenter.

public : unsigned int Id { get; }
public uint Id { get; }
Public ReadOnly Property Id As uint
var uint = inkStroke.id;
Value
unsigned int uint uint uint

The identifier for the ink stroke.

Additional features and requirements
Device family
Windows 10 Creators Update (introduced v10.0.15063.0)
API contract
Windows.Foundation.UniversalApiContract (introduced v4)

Remarks

This identifier does not persist through serialization/deserialization of the ink stroke. After deserialization, a new identifer is assigned.

Calling the Clone method also generates a new identifier for the cloned stroke.

PointTransform PointTransform PointTransform PointTransform

Gets or sets an affine transformation matrix to apply to the InkStroke object.

public : Matrix3x2 PointTransform { get; set; }
public Matrix3x2 PointTransform { get; set; }
Public ReadWrite Property PointTransform As Matrix3x2
var matrix3x2 = inkStroke.pointTransform;
inkStroke.pointTransform = matrix3x2;
Value
Matrix3x2 Matrix3x2 Matrix3x2 Matrix3x2

The 2-D transformation matrix.

See Also

Recognized Recognized Recognized Recognized

Gets whether the stroke is recognized.

public : Platform::Boolean Recognized { get; }
public bool Recognized { get; }
Public ReadOnly Property Recognized As bool
var bool = inkStroke.recognized;
Value
Platform::Boolean bool bool bool

True if the stroke is recognized; otherwise, false.

See Also

Selected Selected Selected Selected

Gets whether the stroke is selected.

public : Platform::Boolean Selected { get; set; }
public bool Selected { get; set; }
Public ReadWrite Property Selected As bool
var bool = inkStroke.selected;
inkStroke.selected = bool;
Value
Platform::Boolean bool bool bool

True if the stroke is selected; otherwise, false.

See Also

StrokeDuration StrokeDuration StrokeDuration StrokeDuration

Gets or sets the time taken by the user to draw a single ink stroke.

public : IReference<TimeSpan> StrokeDuration { get; set; }
public Nullable<TimeSpan> StrokeDuration { get; set; }
Public ReadWrite Property StrokeDuration As Nullable<TimeSpan>
var nullable = inkStroke.strokeDuration;
inkStroke.strokeDuration = nullable;
Value
IReference<TimeSpan> Nullable<TimeSpan> Nullable<TimeSpan> Nullable<TimeSpan>

The time period expressed in 100-nanosecond units.

Additional features and requirements
Device family
Windows 10 Creators Update (introduced v10.0.15063.0)
API contract
Windows.Foundation.UniversalApiContract (introduced v4)

StrokeStartedTime StrokeStartedTime StrokeStartedTime StrokeStartedTime

Gets or sets the date and time when the InkStroke was started.

public : IReference<DateTime> StrokeStartedTime { get; set; }
public Nullable<DateTimeOffset> StrokeStartedTime { get; set; }
Public ReadWrite Property StrokeStartedTime As Nullable<DateTimeOffset>
var nullable = inkStroke.strokeStartedTime;
inkStroke.strokeStartedTime = nullable;
Value
IReference<DateTime> Nullable<DateTimeOffset> Nullable<DateTimeOffset> Nullable<DateTimeOffset>

The date and time of day.

Additional features and requirements
Device family
Windows 10 Creators Update (introduced v10.0.15063.0)
API contract
Windows.Foundation.UniversalApiContract (introduced v4)

Methods

Clone() Clone() Clone() Clone()

Copies the InkStroke to another InkManager (or InkStrokeContainer ).

public : InkStroke Clone()
public InkStroke Clone()
Public Function Clone() As InkStroke
var inkStroke = inkStroke.clone();
Returns

Remarks

This method must be used with AddStroke (InkManager ) or AddStroke (InkStrokeContainer ).


inkStrokeContainer.AddStroke(stroke.Clone());
inkManager.AddStroke(stroke.Clone());
inkStrokeContainer.AddStroke(stroke.Clone());
inkManager.AddStroke(stroke.Clone());
See Also

GetInkPoints() GetInkPoints() GetInkPoints() GetInkPoints()

Gets the collection of InkPoint objects used to construct the InkStroke.

public : IVectorView<InkPoint> GetInkPoints()
public IReadOnlyList<InkPoint> GetInkPoints()
Public Function GetInkPoints() As IReadOnlyList<InkPoint>( Of InkPoint )
var iVectorView = inkStroke.getInkPoints();
Returns
IVectorView<InkPoint> IReadOnlyList<InkPoint> IReadOnlyList<InkPoint> IReadOnlyList<InkPoint>

The collection of InkPoint objects used to construct the InkStroke.

See Also

GetRenderingSegments() GetRenderingSegments() GetRenderingSegments() GetRenderingSegments()

Gets the rendering segments of the stroke.

Note

For Universal Windows app using Extensible Application Markup Language (XAML), use GetInkPoints (see remarks).

public : IVectorView<InkStrokeRenderingSegment> GetRenderingSegments()
public IReadOnlyList<InkStrokeRenderingSegment> GetRenderingSegments()
Public Function GetRenderingSegments() As IReadOnlyList<InkStrokeRenderingSegment>( Of InkStrokeRenderingSegment )
var iVectorView = inkStroke.getRenderingSegments();
Returns
IVectorView<InkStrokeRenderingSegment> IReadOnlyList<InkStrokeRenderingSegment> IReadOnlyList<InkStrokeRenderingSegment> IReadOnlyList<InkStrokeRenderingSegment>

The collection of InkStrokeRenderingSegment objects.

Remarks

If FitToCurve is set to true, this method returns an InkStrokeRenderingSegment that approximates the Bezier curve of the stroke.

If FitToCurve is set to false, this method returns a collection of InkStrokeRenderingSegment objects that represent the original raw pointer data as line segments.

For Universal Windows app using Extensible Application Markup Language (XAML), avoid changing the state of an ink stroke to retrieve the raw pointer data by using GetInkPoints instead.

See Also

See Also