StrokeCollection Class

Definition

Represents a collection of Stroke objects.

public ref class StrokeCollection : System::Collections::ObjectModel::Collection<System::Windows::Ink::Stroke ^>, System::Collections::Specialized::INotifyCollectionChanged, System::ComponentModel::INotifyPropertyChanged
[System.ComponentModel.TypeConverter(typeof(System.Windows.StrokeCollectionConverter))]
public class StrokeCollection : System.Collections.ObjectModel.Collection<System.Windows.Ink.Stroke>, System.Collections.Specialized.INotifyCollectionChanged, System.ComponentModel.INotifyPropertyChanged
type StrokeCollection = class
    inherit Collection<Stroke>
    interface INotifyPropertyChanged
    interface INotifyCollectionChanged
Public Class StrokeCollection
Inherits Collection(Of Stroke)
Implements INotifyCollectionChanged, INotifyPropertyChanged
Inheritance
StrokeCollection
Attributes
Implements

Examples

The following example demonstrates how to copy the ink in one InkCanvas onto another InkCanvas. This example assumes:

  • There are two InkCanvas objects called inkCanvas1 and inkCanvas2.

  • The Click event has been connected to the event handler.

// Copy the strokes from one InkCanvas to another InkCanvas.
private void CopyStrokes_Click(object sender, RoutedEventArgs e) 
{
    StrokeCollection strokes = inkCanvas1.Strokes.Clone();
    inkCanvas2.Strokes.Clear();
    inkCanvas2.Strokes.Add(strokes);

}
' Copy the strokes from one InkCanvas to another InkCanvas.
Private Sub CopyStrokes_Click(ByVal sender As Object, ByVal e As RoutedEventArgs)

    Dim strokes As StrokeCollection = inkCanvas1.Strokes.Clone()
    inkCanvas2.Strokes.Clear()
    inkCanvas2.Strokes.Add(strokes)

End Sub

Remarks

The StrokeCollection enables you to perform functions such as hit testing, clipping, and erasing strokes. The InkCanvas control performs many of these functions, but if you need more control than the InkCanvas provides, the StrokeCollection offers more options.

The following table lists where to learn about managing digital ink on a custom control.

To do this… See this article
Create a control that collects digital ink Creating an Ink Input Control
Create a control that enables the user to select ink How to: Select Ink from a Custom Control
Create a control that enables the user to point-erase ink How to: Erase Ink on a Custom Control

XAML Attribute Usage

<object StrokeCollection="isfString"/>  

XAML Object Element Usage

<object>isfString</object>  

XAML Values

Term Definition
isfString A string that represents the stroke in base-64, encoded Ink Serialized Format (ISF).

Constructors

StrokeCollection()

Initializes a new instance of the StrokeCollection class.

StrokeCollection(IEnumerable<Stroke>)

Initializes a new instance of the StrokeCollection class that contains the specified strokes.

StrokeCollection(Stream)

Initializes a StrokeCollection from the specified Stream of Ink Serialized Format (ISF).

Fields

InkSerializedFormat

Represents the native persistence format for ink data.

Properties

Count

Gets the number of elements actually contained in the Collection<T>.

(Inherited from Collection<T>)
Item[Int32]

Gets or sets the element at the specified index.

(Inherited from Collection<T>)
Items

Gets a IList<T> wrapper around the Collection<T>.

(Inherited from Collection<T>)

Methods

Add(StrokeCollection)

Adds the specified strokes to the StrokeCollection.

Add(T)

Adds an object to the end of the Collection<T>.

(Inherited from Collection<T>)
AddPropertyData(Guid, Object)

Adds a custom property to the StrokeCollection.

Clear()

Removes all elements from the Collection<T>.

(Inherited from Collection<T>)
ClearItems()

Clears all strokes from the StrokeCollection.

Clip(IEnumerable<Point>)

Removes all strokes in the StrokeCollection that are outside the bounds of the specified Point array.

Clip(Rect)

Replaces all strokes that are clipped by the specified rectangle with new strokes that do not extend beyond the specified rectangle.

Clone()

Copies the StrokeCollection.

Contains(T)

Determines whether an element is in the Collection<T>.

(Inherited from Collection<T>)
ContainsPropertyData(Guid)

Returns whether the specified custom property identifier is in the StrokeCollection.

CopyTo(T[], Int32)

Copies the entire Collection<T> to a compatible one-dimensional Array, starting at the specified index of the target array.

(Inherited from Collection<T>)
Draw(DrawingContext)

Draws the strokes in the StrokeCollection.

Equals(Object)

Determines whether the specified object is equal to the current object.

(Inherited from Object)
Erase(IEnumerable<Point>)

Removes the ink that is within the bounds of the specified area.

Erase(IEnumerable<Point>, StylusShape)

Replaces all strokes that are clipped by the region created by the specified StylusShape along the specified path with new Strokes that are not clipped by the region.

Erase(Rect)

Replaces all strokes that are clipped by the specified rectangle with new strokes that do not enter the bounds of the specified rectangle.

GetBounds()

Returns the bounds of the strokes in the collection.

GetEnumerator()

Returns an enumerator that iterates through the Collection<T>.

(Inherited from Collection<T>)
GetHashCode()

Serves as the default hash function.

(Inherited from Object)
GetIncrementalLassoHitTester(Int32)

Creates an IncrementalLassoHitTester that hit tests the StrokeCollection with a lasso (freehand) path.

GetIncrementalStrokeHitTester(StylusShape)

Creates an IncrementalStrokeHitTester that hit tests the StrokeCollection with an erasing path.

GetPropertyData(Guid)

Returns the value of the custom property associated with the specified Guid.

GetPropertyDataIds()

Returns the GUIDs of any custom properties associated with the StrokeCollection.

GetType()

Gets the Type of the current instance.

(Inherited from Object)
HitTest(IEnumerable<Point>, Int32)

Returns a collection of strokes that have at least the specified percentage of length within the specified area.

HitTest(IEnumerable<Point>, StylusShape)

Returns a collection of strokes that intersect with the specified path.

HitTest(Point)

Returns a collection of strokes that intersect the specified point.

HitTest(Point, Double)

Returns a collection of strokes that intersect the specified area.

HitTest(Rect, Int32)

Returns a collection of strokes that have at least the specified percentage of length within the specified rectangle.

IndexOf(Stroke)

Returns the index of the specified Stroke in the StrokeCollection.

IndexOf(T)

Searches for the specified object and returns the zero-based index of the first occurrence within the entire Collection<T>.

(Inherited from Collection<T>)
Insert(Int32, T)

Inserts an element into the Collection<T> at the specified index.

(Inherited from Collection<T>)
InsertItem(Int32, Stroke)

Inserts a stroke into the StrokeCollection at the specified index.

InsertItem(Int32, T)

Inserts an element into the Collection<T> at the specified index.

(Inherited from Collection<T>)
MemberwiseClone()

Creates a shallow copy of the current Object.

(Inherited from Object)
OnPropertyChanged(PropertyChangedEventArgs)

Occurs when any StrokeCollection property changes.

OnPropertyDataChanged(PropertyDataChangedEventArgs)

Raises the PropertyDataChanged event.

OnStrokesChanged(StrokeCollectionChangedEventArgs)

Raises the StrokesChanged event.

Remove(StrokeCollection)

Removes the specified strokes from the collection.

Remove(T)

Removes the first occurrence of a specific object from the Collection<T>.

(Inherited from Collection<T>)
RemoveAt(Int32)

Removes the element at the specified index of the Collection<T>.

(Inherited from Collection<T>)
RemoveItem(Int32)

Removes the stroke at the specified index from the StrokeCollection.

RemovePropertyData(Guid)

Removes the custom property associated with the specified Guid.

Replace(Stroke, StrokeCollection)

Replaces the specified Stroke with the specified StrokeCollection.

Replace(StrokeCollection, StrokeCollection)

Replaces the specified StrokeCollection with a new StrokeCollection.

Save(Stream)

Saves the StrokeCollection to the specified Stream.

Save(Stream, Boolean)

Saves the StrokeCollection to the specified Stream and compresses it, when specified.

SetItem(Int32, Stroke)

Replaces the stroke at the specified index.

SetItem(Int32, T)

Replaces the element at the specified index.

(Inherited from Collection<T>)
ToString()

Returns a string that represents the current object.

(Inherited from Object)
Transform(Matrix, Boolean)

Modifies each of the StylusPoints and optionally the StylusTipTransform for each stroke in the StrokeCollection according to the specified Matrix.

Events

PropertyDataChanged

Occurs when custom property is added or removed from the StrokeCollection.

StrokesChanged

Occurs when a Stroke in the collection changes.

Explicit Interface Implementations

ICollection.CopyTo(Array, Int32)

Copies the elements of the ICollection to an Array, starting at a particular Array index.

(Inherited from Collection<T>)
ICollection.IsSynchronized

Gets a value indicating whether access to the ICollection is synchronized (thread safe).

(Inherited from Collection<T>)
ICollection.SyncRoot

Gets an object that can be used to synchronize access to the ICollection.

(Inherited from Collection<T>)
ICollection<T>.IsReadOnly

Gets a value indicating whether the ICollection<T> is read-only.

(Inherited from Collection<T>)
IEnumerable.GetEnumerator()

Returns an enumerator that iterates through a collection.

(Inherited from Collection<T>)
IList.Add(Object)

Adds an item to the IList.

(Inherited from Collection<T>)
IList.Contains(Object)

Determines whether the IList contains a specific value.

(Inherited from Collection<T>)
IList.IndexOf(Object)

Determines the index of a specific item in the IList.

(Inherited from Collection<T>)
IList.Insert(Int32, Object)

Inserts an item into the IList at the specified index.

(Inherited from Collection<T>)
IList.IsFixedSize

Gets a value indicating whether the IList has a fixed size.

(Inherited from Collection<T>)
IList.IsReadOnly

Gets a value indicating whether the IList is read-only.

(Inherited from Collection<T>)
IList.Item[Int32]

Gets or sets the element at the specified index.

(Inherited from Collection<T>)
IList.Remove(Object)

Removes the first occurrence of a specific object from the IList.

(Inherited from Collection<T>)
INotifyCollectionChanged.CollectionChanged

Occurs when the StrokeCollection changes.

INotifyPropertyChanged.PropertyChanged

Occurs when the value of any StrokeCollection property has changed.

Extension Methods

CopyToDataTable<T>(IEnumerable<T>)

Returns a DataTable that contains copies of the DataRow objects, given an input IEnumerable<T> object where the generic parameter T is DataRow.

CopyToDataTable<T>(IEnumerable<T>, DataTable, LoadOption)

Copies DataRow objects to the specified DataTable, given an input IEnumerable<T> object where the generic parameter T is DataRow.

CopyToDataTable<T>(IEnumerable<T>, DataTable, LoadOption, FillErrorEventHandler)

Copies DataRow objects to the specified DataTable, given an input IEnumerable<T> object where the generic parameter T is DataRow.

Cast<TResult>(IEnumerable)

Casts the elements of an IEnumerable to the specified type.

OfType<TResult>(IEnumerable)

Filters the elements of an IEnumerable based on a specified type.

AsParallel(IEnumerable)

Enables parallelization of a query.

AsQueryable(IEnumerable)

Converts an IEnumerable to an IQueryable.

Ancestors<T>(IEnumerable<T>)

Returns a collection of elements that contains the ancestors of every node in the source collection.

Ancestors<T>(IEnumerable<T>, XName)

Returns a filtered collection of elements that contains the ancestors of every node in the source collection. Only elements that have a matching XName are included in the collection.

DescendantNodes<T>(IEnumerable<T>)

Returns a collection of the descendant nodes of every document and element in the source collection.

Descendants<T>(IEnumerable<T>)

Returns a collection of elements that contains the descendant elements of every element and document in the source collection.

Descendants<T>(IEnumerable<T>, XName)

Returns a filtered collection of elements that contains the descendant elements of every element and document in the source collection. Only elements that have a matching XName are included in the collection.

Elements<T>(IEnumerable<T>)

Returns a collection of the child elements of every element and document in the source collection.

Elements<T>(IEnumerable<T>, XName)

Returns a filtered collection of the child elements of every element and document in the source collection. Only elements that have a matching XName are included in the collection.

InDocumentOrder<T>(IEnumerable<T>)

Returns a collection of nodes that contains all nodes in the source collection, sorted in document order.

Nodes<T>(IEnumerable<T>)

Returns a collection of the child nodes of every document and element in the source collection.

Remove<T>(IEnumerable<T>)

Removes every node in the source collection from its parent node.

Applies to