StrokeCollection Class
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
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
[<System.ComponentModel.TypeConverter(typeof(System.Windows.StrokeCollectionConverter))>]
type StrokeCollection = class
inherit Collection<Stroke>
interface INotifyCollectionChanged
interface INotifyPropertyChanged
Public Class StrokeCollection
Inherits Collection(Of Stroke)
Implements INotifyCollectionChanged, INotifyPropertyChanged
- Inheritance
- 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
inkCanvas1andinkCanvas2.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
| Name | Description |
|---|---|
| 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
| Name | Description |
|---|---|
| InkSerializedFormat |
Represents the native persistence format for ink data. |
Methods
| Name | Description |
|---|---|
| Add(StrokeCollection) |
Adds the specified strokes to the StrokeCollection. |
| AddPropertyData(Guid, Object) |
Adds a custom property to the StrokeCollection. |
| 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. |
| ContainsPropertyData(Guid) |
Returns whether the specified custom property identifier is in the StrokeCollection. |
| Draw(DrawingContext) |
Draws the strokes in the StrokeCollection. |
| 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(IEnumerable<Point>) |
Removes the ink that is within the bounds of the specified area. |
| 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. |
| 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. |
| 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, Double) |
Returns a collection of strokes that intersect the specified area. |
| HitTest(Point) |
Returns a collection of strokes that intersect the specified point. |
| 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. |
| InsertItem(Int32, Stroke) |
Inserts a stroke into the StrokeCollection at the specified index. |
| 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. |
| 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, Boolean) |
Saves the StrokeCollection to the specified Stream and compresses it, when specified. |
| Save(Stream) |
Saves the StrokeCollection to the specified Stream. |
| SetItem(Int32, Stroke) |
Replaces the stroke at the specified index. |
| Transform(Matrix, Boolean) |
Modifies each of the StylusPoints and optionally the StylusTipTransform for each stroke in the StrokeCollection according to the specified Matrix. |
Events
| Name | Description |
|---|---|
| PropertyDataChanged |
Occurs when custom property is added or removed from the StrokeCollection. |
| StrokesChanged |
Occurs when a Stroke in the collection changes. |
Explicit Interface Implementations
| Name | Description |
|---|---|
| INotifyCollectionChanged.CollectionChanged |
This API supports the product infrastructure and is not intended to be used directly from your code. Occurs when the StrokeCollection changes. |
| INotifyPropertyChanged.PropertyChanged |
This API supports the product infrastructure and is not intended to be used directly from your code. Occurs when the value of any StrokeCollection property has changed. |