Stroke Constructor (StylusPointCollection, DrawingAttributes)

 

Initializes a new instance of the Stroke class.

Namespace:   System.Windows.Ink
Assembly:  PresentationCore (in PresentationCore.dll)

public Stroke(
	StylusPointCollection stylusPoints,
	DrawingAttributes drawingAttributes
)

Parameters

stylusPoints
Type: System.Windows.Input.StylusPointCollection

A StylusPointCollection that represents the Stroke.

drawingAttributes
Type: System.Windows.Ink.DrawingAttributes

A DrawingAttributes object that specifies the appearance of the Stroke.

Exception Condition
ArgumentNullException

stylusPoints is null.

-or-

drawingAtrributes is null.

ArgumentException

stylusPoints is empty.

The following example demonstrates how to create a Stroke from a StylusPointCollection and DrawingAttributes object. This example assumes that there is an InkPresenter called myInkPresenter.

DrawingAttributes drawingAttributes1 = new DrawingAttributes();
drawingAttributes1.Color = Colors.Green;

StylusPoint stylusPoint1 = new StylusPoint(100, 100);
StylusPoint stylusPoint2 = new StylusPoint(100, 200);
StylusPoint stylusPoint3 = new StylusPoint(200, 200);
StylusPoint stylusPoint4 = new StylusPoint(200, 100);
StylusPoint stylusPoint5 = new StylusPoint(100, 100);

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

Stroke newStroke = new Stroke(points, drawingAttributes1);

myInkPresenter.Strokes.Add(newStroke);

.NET Framework
Available since 3.0
Return to top
Show: