InkStroke InkStroke InkStroke InkStroke Class

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

Syntax

Declaration

public sealed class InkStrokepublic sealed class InkStrokePublic NotInheritable Class InkStroke

Remarks

JavaScript (usage)
var inkStrokes = GetStrokes(); var inkStroke = inkStrokes[...];
var inkStrokes = GetStrokes(); var inkStroke = inkStrokes[...];
var inkStrokes = 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).

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

Properties summary

Gets the bounding box for the InkStroke.

Gets or sets the properties associated with an InkStroke.

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

Gets whether the stroke is recognized.

Gets whether the stroke is selected.

Methods summary

Copies the InkStroke to another InkManager (or InkStrokeContainer ).

Gets the collection of @Windows.UI.Input.Inking.InkPoint.#ctor(Windows.Foundation.Point,System.Single) objects used to construct the InkStroke.

Gets the rendering segments of the stroke.

Note

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

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

    Property Value

  • 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

    Property Value

    Remarks

    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.

  • 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

    Property Value

  • Recognized
    Recognized
    Recognized
    Recognized

    Gets whether the stroke is recognized.

    public bool Recognized { get; }public bool Recognized { get; }Public ReadOnly Property Recognized As bool

    Property Value

    • bool
      bool
      bool
      bool

      True if the stroke is recognized; otherwise, false.

  • Selected
    Selected
    Selected
    Selected

    Gets whether the stroke is selected.

    public bool Selected { get; set; }public bool Selected { get; set; }Public ReadWrite Property Selected As bool

    Property Value

    • bool
      bool
      bool
      bool

      True if the stroke is selected; otherwise, false.

Methods

  • Clone()
    Clone()
    Clone()
    Clone()

    Copies the InkStroke to another InkManager (or InkStrokeContainer ).

    public InkStroke Clone()public InkStroke Clone()Public Function Clone() As InkStroke

    Returns

    Remarks

    This method must be used with AddStroke(Windows.UI.Input.Inking.InkStroke) (InkManager ) or AddStroke(Windows.UI.Input.Inking.InkStroke) (InkStrokeContainer ).

    
    inkStrokeContainer.AddStroke(stroke.Clone());
    inkManager.AddStroke(stroke.Clone());
    
    inkStrokeContainer.AddStroke(stroke.Clone());
    inkManager.AddStroke(stroke.Clone());
    
  • GetInkPoints()
    GetInkPoints()
    GetInkPoints()
    GetInkPoints()

    Gets the collection of @Windows.UI.Input.Inking.InkPoint.#ctor(Windows.Foundation.Point,System.Single) objects used to construct the InkStroke.

    public IVectorView<InkPoint> GetInkPoints()public IVectorView<InkPoint> GetInkPoints()Public Function GetInkPoints() As IVectorView( Of InkPoint )

    Returns

    • The collection of @Windows.UI.Input.Inking.InkPoint.#ctor(Windows.Foundation.Point,System.Single) objects used to construct the InkStroke.

  • 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 IVectorView<InkStrokeRenderingSegment> GetRenderingSegments()Public Function GetRenderingSegments() As IVectorView( Of InkStrokeRenderingSegment )

    Returns

    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.

Device family

Windows 10 (introduced v10.0.10240.0)

API contract

Windows.Foundation.UniversalApiContract (introduced v1)

Attributes

Windows.Foundation.Metadata.MarshalingBehaviorAttribute
Windows.Foundation.Metadata.DualApiPartitionAttribute
Windows.Foundation.Metadata.ContractVersionAttribute

Details

Assembly

Windows.UI.Input.Inking.dll