StylusPointCollection Constructors

Definition

Initializes a new instance of the StylusPointCollection class.

Overloads

StylusPointCollection()

Initializes a new instance of the StylusPointCollection class.

StylusPointCollection(IEnumerable<StylusPoint>)

Initializes a new instance of the StylusPointCollection class with the specified StylusPoint objects.

StylusPointCollection(IEnumerable<Point>)

Initializes a new instance of the StylusPointCollection class with specified points.

StylusPointCollection(Int32)

Initializes a new instance of the StylusPointCollection class that may initially contain the specified number of StylusPoint objects.

StylusPointCollection(StylusPointDescription)

Initializes a new instance of the StylusPointCollection class that contains the properties specified in the StylusPointDescription.

StylusPointCollection(StylusPointDescription, Int32)

Initializes a new instance of the StylusPointCollection class that is the specified size and contains the properties specified in the StylusPointDescription.

StylusPointCollection()

Initializes a new instance of the StylusPointCollection class.

C#
public StylusPointCollection();

Examples

The following example collects StylusPoint objects in the OnStylusDown method of a custom control. The example creates a StylusPointCollection by specifying the StylusPointDescription and the initial size of the StylusPointCollection.

C#
StylusPointCollection stylusPoints;

protected override void OnStylusDown(StylusDownEventArgs e)
{
    base.OnStylusDown(e);

    StylusPointCollection eventPoints = e.GetStylusPoints(this);

    // Create a new StylusPointCollection using the StylusPointDescription
    // from the stylus points in the StylusDownEventArgs.
    stylusPoints = new StylusPointCollection(eventPoints.Description, eventPoints.Count);
    stylusPoints.Add(eventPoints);
}

Applies to

.NET Framework 4.8.1 and other versions
Product Versions
.NET Framework 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
Windows Desktop 3.0, 3.1, 5, 6, 7, 8, 9, 10

StylusPointCollection(IEnumerable<StylusPoint>)

Initializes a new instance of the StylusPointCollection class with the specified StylusPoint objects.

C#
public StylusPointCollection(System.Collections.Generic.IEnumerable<System.Windows.Input.StylusPoint> stylusPoints);

Parameters

stylusPoints
IEnumerable<StylusPoint>

A generic IEnumerable of type StylusPoint to add to the StylusPointCollection.

Exceptions

stylusPoints is null.

The length of points is 0.

-or-

The StylusPoint objects in stylusPoints have incompatible StylusPointDescription objects.

Examples

The following example creates a StylusPointCollection.

C#
StylusPoint stylusPoint1 =  new StylusPoint(100, 100, .5f);
StylusPoint stylusPoint2 = new StylusPoint(200, 200, .35f);

StylusPointCollection points = new StylusPointCollection(
    new StylusPoint[] { stylusPoint1, stylusPoint2 });

Applies to

.NET Framework 4.8.1 and other versions
Product Versions
.NET Framework 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
Windows Desktop 3.0, 3.1, 5, 6, 7, 8, 9, 10

StylusPointCollection(IEnumerable<Point>)

Initializes a new instance of the StylusPointCollection class with specified points.

C#
public StylusPointCollection(System.Collections.Generic.IEnumerable<System.Windows.Point> points);

Parameters

points
IEnumerable<Point>

A generic IEnumerable of type Point that specifies the StylusPoint objects to add to the StylusPointCollection.

Exceptions

points is null.

The length of points is 0.

Examples

The following example creates a StylusPointCollection.

C#
StylusPointCollection points = new StylusPointCollection(new Point[]
    {
        new Point(100, 100),
        new Point(100, 200),
        new Point(200, 250),
        new Point(300, 300)
    });

Applies to

.NET Framework 4.8.1 and other versions
Product Versions
.NET Framework 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
Windows Desktop 3.0, 3.1, 5, 6, 7, 8, 9, 10

StylusPointCollection(Int32)

Initializes a new instance of the StylusPointCollection class that may initially contain the specified number of StylusPoint objects.

C#
public StylusPointCollection(int initialCapacity);

Parameters

initialCapacity
Int32

The number of StylusPoint objects the StylusPointCollection can initially contain.

Exceptions

initialCapacity is negative.

Examples

The following example collects StylusPoint objects in the OnStylusDown method of a custom control. The example creates a StylusPointCollection by specifying both the StylusPointDescription and the initial size of the StylusPointCollection.

C#
StylusPointCollection stylusPoints;

protected override void OnStylusDown(StylusDownEventArgs e)
{
    base.OnStylusDown(e);

    StylusPointCollection eventPoints = e.GetStylusPoints(this);

    // Create a new StylusPointCollection using the StylusPointDescription
    // from the stylus points in the StylusDownEventArgs.
    stylusPoints = new StylusPointCollection(eventPoints.Description, eventPoints.Count);
    stylusPoints.Add(eventPoints);
}

Remarks

When you use the StylusPointCollection constructor to create a new StylusPointCollection, you specify it's initialCapacity. However, you can add more StylusPoint objects by calling the Add method.

Applies to

.NET Framework 4.8.1 and other versions
Product Versions
.NET Framework 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
Windows Desktop 3.0, 3.1, 5, 6, 7, 8, 9, 10

StylusPointCollection(StylusPointDescription)

Initializes a new instance of the StylusPointCollection class that contains the properties specified in the StylusPointDescription.

C#
public StylusPointCollection(System.Windows.Input.StylusPointDescription stylusPointDescription);

Parameters

stylusPointDescription
StylusPointDescription

A StylusPointDescription that specifies the additional properties stored in each StylusPoint.

Exceptions

stylusPointDescription is null.

Examples

The following example collects StylusPoint objects in the OnStylusDown method of a custom control. The example creates a StylusPointCollection by specifying the StylusPointDescription and the initial size of the StylusPointCollection.

C#
StylusPointCollection stylusPoints;

protected override void OnStylusDown(StylusDownEventArgs e)
{
    base.OnStylusDown(e);

    StylusPointCollection eventPoints = e.GetStylusPoints(this);

    // Create a new StylusPointCollection using the StylusPointDescription
    // from the stylus points in the StylusDownEventArgs.
    stylusPoints = new StylusPointCollection(eventPoints.Description, eventPoints.Count);
    stylusPoints.Add(eventPoints);
}

Remarks

All StylusPoint objects added to the StylusPointCollection must have a StylusPointDescription that is compatible with stylusPointDescription.

Applies to

.NET Framework 4.8.1 and other versions
Product Versions
.NET Framework 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
Windows Desktop 3.0, 3.1, 5, 6, 7, 8, 9, 10

StylusPointCollection(StylusPointDescription, Int32)

Initializes a new instance of the StylusPointCollection class that is the specified size and contains the properties specified in the StylusPointDescription.

C#
public StylusPointCollection(System.Windows.Input.StylusPointDescription stylusPointDescription, int initialCapacity);

Parameters

stylusPointDescription
StylusPointDescription

A StylusPointDescription that specifies the additional properties stored in each StylusPoint.

initialCapacity
Int32

The number of StylusPoint objects the StylusPointCollection can initially contain.

Exceptions

initialCapacity is negative.

stylusPointDescription is null.

Examples

The following example collects StylusPoint objects in the OnStylusDown method of a custom control. The example creates a StylusPointCollection by specifying the StylusPointDescription and the initial size of the StylusPointCollection.

C#
StylusPointCollection stylusPoints;

protected override void OnStylusDown(StylusDownEventArgs e)
{
    base.OnStylusDown(e);

    StylusPointCollection eventPoints = e.GetStylusPoints(this);

    // Create a new StylusPointCollection using the StylusPointDescription
    // from the stylus points in the StylusDownEventArgs.
    stylusPoints = new StylusPointCollection(eventPoints.Description, eventPoints.Count);
    stylusPoints.Add(eventPoints);
}

Remarks

When you use the StylusPointCollection constructor to create a new StylusPointCollection, the StylusPointCollection is created with the capacity to hold the specified number of StylusPoint objects. You can add more StylusPoint objects than initialCapacity by calling the Add method.

Applies to

.NET Framework 4.8.1 and other versions
Product Versions
.NET Framework 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
Windows Desktop 3.0, 3.1, 5, 6, 7, 8, 9, 10