InkDrawingAttributes InkDrawingAttributes InkDrawingAttributes InkDrawingAttributes Class

Provides properties associated with the drawing of an InkStroke.

Syntax

Declaration

public sealed class InkDrawingAttributespublic sealed class InkDrawingAttributesPublic NotInheritable Class InkDrawingAttributespublic sealed class InkDrawingAttributes

Remarks

InkDrawingAttributes can be set globally through the SetDefaultDrawingAttributes(InkDrawingAttributes) method of an InkManager object or an InkStrokeBuilder object. They can also be set on an individual InkStroke object through the DrawingAttributes property.

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

The following example demonstrates how to set a default drawing attribute for all strokes managed by an InkManager object (inkManager).


var inkManager = new Windows.UI.Input.Inking.InkManager();
var drawingAttributes = 
     new Windows.UI.Input.Inking.InkDrawingAttributes();
// True is the Default value for fitToCurve.
drawingAttributes.fitToCurve = false;
// Set color to red (default is black).
drawingAttributes.color = 
     Windows.UI.ColorHelper.fromArgb(255, 255, 0, 0); 
inkManager.setDefaultDrawingAttributes(drawingAttributes);
// Create the InkManager instance.
Windows.UI.Input.Inking.InkManager inkManager = 
  new Windows.UI.Input.Inking.InkManager();
Windows.UI.Input.Inking.InkDrawingAttributes drawingAttributes = 
  new Windows.UI.Input.Inking.InkDrawingAttributes();
// True is the Default value for fitToCurve.
drawingAttributes.FitToCurve = false;
// Set color to red (default is black).
drawingAttributes.Color = Windows.UI.Colors.CornflowerBlue;
inkManager.SetDefaultDrawingAttributes(drawingAttributes);

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.

Constructors summary

Creates a new InkDrawingAttributes object that is used to specify InkStroke attributes.

Properties summary

Gets or sets a value that indicates the color of an InkStroke.

Gets or sets a value that indicates whether the InkStroke is rendered as a highlighter overlay. The stroke is typically set to a bright color, such as yellow.

Gets or sets a value that indicates whether a Bezier curve or a collection of straight line segments is used to draw an InkStroke.

Gets or sets a value that indicates whether the pressure of the contact on the digitizer surface is ignored when you draw an InkStroke.

Prerelease. Gets or sets a value that indicates whether the tilt (TiltX, TiltY ) of the contact on the digitizer surface is ignored when you draw an InkStroke.

Gets the InkDrawingAttributes that describe the characteristics of a specific type of InkStroke.

Gets an instance of an InkDrawingAttributesPencilProperties object for setting properties characteristic to a pencil stroke.

Gets or sets a value that indicates the shape of the pen tip when you draw an InkStroke.

Gets or sets an affine transformation matrix applied to the PenTipShape used for an InkStroke.

Gets or sets a value that indicates the dimensions of the pen tip (PenTip ) used to draw an InkStroke.

Methods summary

Creates an InkDrawingAttributes object for rendering an ink stroke with pencil characteristics.

Constructors

  • InkDrawingAttributes()
    InkDrawingAttributes()
    InkDrawingAttributes()
    InkDrawingAttributes()

    Creates a new InkDrawingAttributes object that is used to specify InkStroke attributes.

    public InkDrawingAttributes()public New()Public Sub New()public InkDrawingAttributes()

    Remarks

    Examples

    The following example demonstrates how to create an InkDrawingAttributes object and set a default drawing attribute for all strokes managed by an InkManager object (inkManager).

    
    var inkManager = new Windows.UI.Input.Inking.InkManager();
    var drawingAttributes = new Windows.UI.Input.Inking.InkDrawingAttributes();
    drawingAttributes.fitToCurve = true;
    inkManager.setDefaultDrawingAttributes(drawingAttributes);
    

Properties

  • Color
    Color
    Color
    Color

    Gets or sets a value that indicates the color of an InkStroke.

    public Color Color { get; set; }public Color Color { get; set; }Public ReadWrite Property Color As Colorpublic Color Color { get; set; }

    Property Value

    Remarks

    The value of Color is an ARGB value. However, the value of the transparency component (A, or alpha channel) is ignored and the InkStroke is rendered at full opacity.

    The value of the transparency component is not discarded. It is stored with all other stroke data in the Ink Serialized Format (ISF) file when the InkStroke is saved.

    Examples

    The following example demonstrates how to set the Color property (color) of an InkStroke (stroke) using the FromArgb(Byte, Byte, Byte, Byte) method.

    
    var drawingAttributes = stroke.drawingAttributes;
    drawingAttributes.color = 
         Windows.UI.ColorHelper.fromArgb(255, 255, 0, 0);
    stroke.drawingAttributes = drawingAttributes;
    

    The following alternative demonstrates how to set the Color property (color) of an InkStroke (stroke) without using the FromArgb(Byte, Byte, Byte, Byte) method.

    var drawingAttributes = stroke.drawingAttributes;
    var color = drawingAttributes.color;
    color.a = 255;
    color.r = 255;
    color.g = 0;
    color.b = 0;
    drawingAttributes.color = color;
    stroke.drawingAttributes = drawingAttributes;
    

    For the complete example, see Ink App sample.

  • DrawAsHighlighter
    DrawAsHighlighter
    DrawAsHighlighter
    DrawAsHighlighter

    Gets or sets a value that indicates whether the InkStroke is rendered as a highlighter overlay. The stroke is typically set to a bright color, such as yellow.

    public bool DrawAsHighlighter { get; set; }public bool DrawAsHighlighter { get; set; }Public ReadWrite Property DrawAsHighlighter As boolpublic bool DrawAsHighlighter { get; set; }

    Property Value

    • bool
      bool
      bool
      bool

      true to render the stroke as a highlighter; otherwise false. The default value is false.

  • FitToCurve
    FitToCurve
    FitToCurve
    FitToCurve

    Gets or sets a value that indicates whether a Bezier curve or a collection of straight line segments is used to draw an InkStroke.

    public bool FitToCurve { get; set; }public bool FitToCurve { get; set; }Public ReadWrite Property FitToCurve As boolpublic bool FitToCurve { get; set; }

    Property Value

    • bool
      bool
      bool
      bool

      true if a Bezier curve is used; otherwise false. The default value is false.

    Remarks

    Examples

    The following example demonstrates how to set the FitToCurve attribute for all strokes managed by this InkManager object (inkManager) that are created after the SetDefaultDrawingAttributes(InkDrawingAttributes) method call.

    
    var inkManager = new Windows.UI.Input.Inking.InkManager();
    var drawingAttributes = 
         new Windows.UI.Input.Inking.InkDrawingAttributes();
    // True is the Default value for fitToCurve.
    drawingAttributes.fitToCurve = false;
    inkManager.setDefaultDrawingAttributes(drawingAttributes);
    

    For the complete example, see Ink App sample.

  • IgnorePressure
    IgnorePressure
    IgnorePressure
    IgnorePressure

    Gets or sets a value that indicates whether the pressure of the contact on the digitizer surface is ignored when you draw an InkStroke.

    public bool IgnorePressure { get; set; }public bool IgnorePressure { get; set; }Public ReadWrite Property IgnorePressure As boolpublic bool IgnorePressure { get; set; }

    Property Value

    • bool
      bool
      bool
      bool

      true if pressure is ignored; otherwise false. The default value is false.

    Remarks

    If IgnorePressure is set to false, the user can modify the thickness of a stroke by adjusting the amount of pressure applied to the digitizer surface while writing.

    The following actions may be affected by the IgnorePressure setting.

    IgnorePressureTrueFalse
    CopyNo effect. Pressure data, if present, is written to the Ink Serialized Format (ISF) stream.No effect. Pressure data, if present, is written to the Ink Serialized Format (ISF) stream.
    PasteDepending on the implementation, pressure data from Ink Serialized Format (ISF) stream may be ignored during rendering.Depending on the implementation, pressure data from Ink Serialized Format (ISF) stream may be applied during rendering.
    SaveNo effect. Pressure data, if present, is written to the Ink Serialized Format (ISF) stream.No effect. Pressure data, if present, is written to the Ink Serialized Format (ISF) stream
    LoadDepending on the implementation, pressure data from Ink Serialized Format (ISF) stream may be ignored during rendering.Depending on the implementation, pressure data from Ink Serialized Format (ISF) stream may be applied during rendering.

    Examples

    The following example demonstrates how to set the IgnorePressure attribute for all strokes managed by this InkManager object (inkManager) that are created after the SetDefaultDrawingAttributes(InkDrawingAttributes) method call.

    
    var inkManager = new Windows.UI.Input.Inking.InkManager();
    var drawingAttributes = new Windows.UI.Input.Inking.InkDrawingAttributes();
    drawingAttributes.ignorePressure = true;
    inkManager.setDefaultDrawingAttributes(drawingAttributes);
    

    For the complete example, see Ink App sample.

  • IgnoreTilt
    IgnoreTilt
    IgnoreTilt
    IgnoreTilt

    Prerelease. Gets or sets a value that indicates whether the tilt (TiltX, TiltY ) of the contact on the digitizer surface is ignored when you draw an InkStroke.

    public bool IgnoreTilt { get; set; }public bool IgnoreTilt { get; set; }Public ReadWrite Property IgnoreTilt As boolpublic bool IgnoreTilt { get; set; }

    Property Value

    • bool
      bool
      bool
      bool

      true if tilt is ignored; otherwise false. The default value is false.

    Remarks

    This property is typically set for pencil strokes.

  • Kind
    Kind
    Kind
    Kind

    Gets the InkDrawingAttributes that describe the characteristics of a specific type of InkStroke.

    public InkDrawingAttributesKind Kind { get; }public InkDrawingAttributesKind Kind { get; }Public ReadOnly Property Kind As InkDrawingAttributesKindpublic InkDrawingAttributesKind Kind { get; }

    Property Value

  • PencilProperties
    PencilProperties
    PencilProperties
    PencilProperties

    Gets an instance of an InkDrawingAttributesPencilProperties object for setting properties characteristic to a pencil stroke.

    public InkDrawingAttributesPencilProperties PencilProperties { get; }public InkDrawingAttributesPencilProperties PencilProperties { get; }Public ReadOnly Property PencilProperties As InkDrawingAttributesPencilPropertiespublic InkDrawingAttributesPencilProperties PencilProperties { get; }

    Property Value

  • PenTip
    PenTip
    PenTip
    PenTip

    Gets or sets a value that indicates the shape of the pen tip when you draw an InkStroke.

    public PenTipShape PenTip { get; set; }public PenTipShape PenTip { get; set; }Public ReadWrite Property PenTip As PenTipShapepublic PenTipShape PenTip { get; set; }

    Property Value

    Remarks

    Support various calligraphic effects using the PenTipShape property with PenTip.

    Examples

    The following example demonstrates how to set the PenTip attribute for all strokes managed by an InkManager object (inkManager).

    
    var inkManager = new Windows.UI.Input.Inking.InkManager();
    var drawingAttributes = new Windows.UI.Input.Inking.InkDrawingAttributes();
    drawingAttributes.penTip = Windows.UI.Input.Inking.PenTipShape.rectangle;
    inkManager.setDefaultDrawingAttributes(drawingAttributes);
    

    For the complete example, see Ink App sample.

  • PenTipTransform
    PenTipTransform
    PenTipTransform
    PenTipTransform

    Gets or sets an affine transformation matrix applied to the PenTipShape used for an InkStroke.

    public Matrix3x2 PenTipTransform { get; set; }public Matrix3x2 PenTipTransform { get; set; }Public ReadWrite Property PenTipTransform As Matrix3x2public Matrix3x2 PenTipTransform { get; set; }

    Property Value

    Remarks

    The M31 and M32 entries of the matrix must be zero.

    This property enables various calligraphic effects, depending on PenTip and PenTipShape.

  • Size
    Size
    Size
    Size

    Gets or sets a value that indicates the dimensions of the pen tip (PenTip ) used to draw an InkStroke.

    public Size Size { get; set; }public Size Size { get; set; }Public ReadWrite Property Size As Sizepublic Size Size { get; set; }

    Property Value

    Remarks

    Examples

    The following example includes a function that shows how to set the Size (strokeSize) of an InkStroke (stroke).

    
    function shapeStroke(stroke, width)
    {
        var att = stroke.drawingAttributes;
        var strokeSize = att.size;
        if (strokeSize.width !== width)
        {
            strokeSize.width = strokeSize.height = width;
            att.size = strokeSize;
            stroke.drawingAttributes = att;
            return true;
        }
        else
        {
            return false;
        }
    }
    

    For the complete example, see Ink App sample.

Methods

Device family

Windows 10 (introduced v10.0.10240.0)

API contract

Windows.Foundation.UniversalApiContract (introduced v1)

Attributes

Windows.Foundation.Metadata.ActivatableAttribute
Windows.Foundation.Metadata.ContractVersionAttribute
Windows.Foundation.Metadata.DualApiPartitionAttribute
Windows.Foundation.Metadata.MarshalingBehaviorAttribute
Windows.Foundation.Metadata.StaticAttribute
Windows.Foundation.Metadata.ThreadingAttribute

Details

Assembly

Windows.UI.Input.Inking.dll