Strokes.StrokesEnumerator.Reset Method
Resets the enumerator index to the beginning of the Strokes collection.
Namespace: Microsoft.Ink
Assembly: Microsoft.Ink (in Microsoft.Ink.dll)
Syntax
'Declaration
Public Sub Reset
'Usage
Dim instance As Strokes.StrokesEnumerator
instance.Reset()
public void Reset()
public:
virtual void Reset() sealed
public final function Reset()
Implements
Remarks
The Strokes.StrokesEnumerator class supports iterating over a Strokes collection and implements the IEnumerator interface.
This method inherits from the Reset method.
Examples
These examples show two ways to enumerate the Strokes collection in order to retrieve each Stroke object contained in the collection. The Strokes collection is returned by the Ink.Strokes property.
This example obtains the IEnumerator for the Strokes collection, and uses it to traverse the collection.
Private Sub EnumerateStrokesWithEnumerator(ByVal mInk As Ink)
' access the Strokes property via using statement
' to insure that the object mStrokes is disposed when finished
' Otherwise, you will have a memory leak
Using mStrokes As Strokes = mInk.Strokes
Dim mStrokesEnumerator As IEnumerator = mStrokes.GetEnumerator()
mStrokesEnumerator.Reset()
While (mStrokesEnumerator.MoveNext())
Dim S As Stroke = DirectCast(mStrokesEnumerator.Current, Stroke)
Me.listBoxStrokeId.Items.Add(S.Id)
End While
End Using
End Sub
private void EnumerateStrokesWithEnumerator(Ink mInk)
{
// access the Strokes property via using statement
// to insure that the object mStrokes is disposed when finished
// Otherwise, you will have a memory leak
using (Strokes mStrokes = mInk.Strokes)
{
IEnumerator mStrokesEnumerator = mStrokes.GetEnumerator();
mStrokesEnumerator.Reset();
while (mStrokesEnumerator.MoveNext())
{
Stroke S = (Stroke)mStrokesEnumerator.Current;
this.listBoxStrokeId.Items.Add(S.Id);
}
}
}
This example uses the foreach statement, which calls the GetEnumerator method in internal code that the compiler generates to support the statement.
Private Sub EnumerateStrokesWithForEach(ByVal mInk As Ink)
' access the Strokes property via using statement
' to insure that the object mStrokes is disposed when finished
' Otherwise, you will have a memory leak
Using mStrokes As Strokes = mInk.Strokes
For Each S As Stroke In mStrokes
Me.listBoxStrokeId.Items.Add(S.Id)
Next
End Using
End Sub
private void EnumerateStrokesWithForEach(Ink mInk)
{
// access the Strokes property via using statement
// to insure that the object mStrokes is disposed when finished
// Otherwise, you will have a memory leak
using (Strokes mStrokes = mInk.Strokes)
{
foreach (Stroke S in mStrokes)
{
this.listBoxStrokeId.Items.Add(S.Id);
}
}
}
Platforms
Windows 7, Windows Vista, Windows Server 2008 R2, Windows Server 2008
The .NET Framework and .NET Compact Framework do not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.
Version Information
.NET Framework
Supported in: 3.0
See Also
Reference
Strokes.StrokesEnumerator Class