InkAnalyzerBase.AddStrokes Method (Int32[], Int32[], Int32[], Guid[], Int32)
Adds stroke data for multiple strokes to the ink analyzer and assigns the specified culture identifier to the strokes.
Namespace: System.Windows.Ink.AnalysisCore
Assembly: IACore (in iacore.dll)
Syntax
'Declaration
Public Function AddStrokes ( _
strokeIdsToAdd As Integer(), _
strokePacketCount As Integer(), _
strokePacketData As Integer(), _
strokePacketDescription As Guid(), _
languageId As Integer _
) As ContextNodeBase
'Usage
Dim instance As InkAnalyzerBase
Dim strokeIdsToAdd As Integer()
Dim strokePacketCount As Integer()
Dim strokePacketData As Integer()
Dim strokePacketDescription As Guid()
Dim languageId As Integer
Dim returnValue As ContextNodeBase
returnValue = instance.AddStrokes(strokeIdsToAdd, strokePacketCount, strokePacketData, strokePacketDescription, languageId)
public ContextNodeBase AddStrokes (
int[] strokeIdsToAdd,
int[] strokePacketCount,
int[] strokePacketData,
Guid[] strokePacketDescription,
int languageId
)
public:
ContextNodeBase^ AddStrokes (
array<int>^ strokeIdsToAdd,
array<int>^ strokePacketCount,
array<int>^ strokePacketData,
array<Guid>^ strokePacketDescription,
int languageId
)
public ContextNodeBase AddStrokes (
int[] strokeIdsToAdd,
int[] strokePacketCount,
int[] strokePacketData,
Guid[] strokePacketDescription,
int languageId
)
public function AddStrokes (
strokeIdsToAdd : int[],
strokePacketCount : int[],
strokePacketData : int[],
strokePacketDescription : Guid[],
languageId : int
) : ContextNodeBase
Not applicable.
Parameters
- strokeIdsToAdd
An array containing the stroke identifiers.
- strokePacketCount
An array containing the number of packets in each stroke.
- strokePacketData
An array containing the packet data for the strokes.
- strokePacketDescription
An array containing the packet property identifiers.
- languageId
The culture identifier to assign to the stroke.
Return Value
The context node to which the ink analyzer added the strokes.
Remarks
The InkAnalyzerBase adds the strokes to a ContextNodeBase that has a Type property value of UnclassifiedInk.
The ink analyzer assigns the specified culture identifier to the strokes. It then adds the strokes to the first unclassified ink node under the ink analyzer's root node that contains strokes with the same culture identifier. If the ink analyzer cannot find a node with the same culture identifier, it creates a new ContextNodeBase under its root node and adds the strokes to the new unclassified ink node.
strokePacketData contains packet data for all of the strokes. strokePacketDescription contains the globally unique identifiers (GUIDs) that describe the types of packet data included for each point in each stroke. For a complete list of available packet properties, see the PacketProperty class.
Only strokes with the same packet descriptions can be added in a single call to AddStrokes.
This method expands the DirtyRegion to the union of the region's current value and the bounding box of the added strokes.
If the InkAnalyzerBase already contains a stroke with the same identifier as one of the strokes to be added, the InkAnalyzerBase throws an exception.
Example
This example defines a method that converts a Strokes collection to packet data and adds the strokes to an InkAnalyzerBase. The method returns the ContextNodeBase to which the ink analyzer added the strokes.
''' <summary>
''' Adds a collection of strokes to an InkAnalyzerBase and assigns a
''' language identifier to each stroke.
''' </summary>
''' <param name="baseInkAnalyzer">
''' The analyzer that receives the strokes.</param>
''' <param name="theStrokes">The strokes to add.</param>
''' <param name="languageIdentifier">
''' The language identifier to assign to the strokes.</param>
''' <returns>The node to which the analyzer added the strokes.</returns>
''' <remarks>
''' This method converts stroke data to packet data for example only.
''' The InkAnalyzerBase is used when your application is handling packet
''' data. If your application uses stroke data from an Ink object, then
''' you would use InkAnalyzer.
''' </remarks>
Public Overloads Shared Function MyAddStrokes( _
ByVal baseInkAnalyzer As System.Windows.Ink.AnalysisCore.InkAnalyzerBase, _
ByVal theStrokes As Microsoft.Ink.Strokes, _
ByVal languageIdentifier As Integer) _
As System.Windows.Ink.AnalysisCore.ContextNodeBase
' Check that the parameters are valid
If Nothing Is baseInkAnalyzer Then
Throw New ArgumentNullException("baseInkAnalyzer")
End If
If Nothing Is theStrokes Then
Throw New ArgumentNullException("theStrokes")
End If
If 0 = theStrokes.Count Then
Throw New ArgumentException("Empty strokes collection.")
End If
' Only strokes that have the same packet description GUIDs
' can be added in one call to InkAnalyzerBase.AddStrokes.
Dim thePacketDescription As Guid() = theStrokes(0).PacketDescription
' Accumulate the stroke data in collections.
Dim theStrokeIdentifiers As New ArrayList()
Dim thePacketCounts As New ArrayList()
Dim thePacketData As New ArrayList()
Dim aStroke As Microsoft.Ink.Stroke
For Each aStroke In theStrokes
If Not InkAnalyzerHelper.AreElementwiseEquivalent( _
aStroke.PacketDescription, thePacketDescription) Then
Throw New ApplicationException( _
"The strokes collection contains strokes with different packet descriptions.")
End If
' Add the stroke data to the collections.
theStrokeIdentifiers.Add(aStroke.Id)
thePacketCounts.Add(aStroke.PacketCount)
thePacketData.AddRange(aStroke.GetPacketData())
Next aStroke
' Add the stroke data to the base layer ink analyzer.
Dim result As System.Windows.Ink.AnalysisCore.ContextNodeBase = baseInkAnalyzer.AddStrokes( _
DirectCast(theStrokeIdentifiers.ToArray(GetType(Integer)), Integer()), _
DirectCast(thePacketCounts.ToArray(GetType(Integer)), Integer()), _
DirectCast(thePacketData.ToArray(GetType(Integer)), Integer()), _
thePacketDescription)
Return result
End Function 'AddStrokes
/// <summary>
/// Adds a collection of strokes to an InkAnalyzerBase and assigns a
/// language identifier to each stroke.
/// </summary>
/// <param name="baseInkAnalyzer">
/// The analyzer that receives the strokes.</param>
/// <param name="theStrokes">The strokes to add.</param>
/// <param name="languageIdentifier">
/// The language identifier to assign to the strokes.</param>
/// <returns>The node to which the analyzer added the strokes.</returns>
/// <remarks>
/// This method converts stroke data to packet data for example only.
/// The InkAnalyzerBase is used when your application is handling packet
/// data. If your application uses stroke data from an Ink object, then
/// you would use InkAnalyzer.
/// </remarks>
public static System.Windows.Ink.AnalysisCore.ContextNodeBase MyAddStrokes(
System.Windows.Ink.AnalysisCore.InkAnalyzerBase baseInkAnalyzer,
Microsoft.Ink.Strokes theStrokes,
int languageIdentifier)
{
// Check that the parameters are valid
if (null == baseInkAnalyzer)
{
throw new ArgumentNullException("baseInkAnalyzer");
}
if (null == theStrokes)
{
throw new ArgumentNullException("theStrokes");
}
if (0 == theStrokes.Count)
{
throw new ArgumentException("Empty strokes collection.");
}
// Only strokes that have the same packet description GUIDs
// can be added in one call to InkAnalyzerBase.AddStrokes.
Guid[] thePacketDescription = theStrokes[0].PacketDescription;
// Accumulate the stroke data in collections.
ArrayList theStrokeIdentifiers = new ArrayList();
ArrayList thePacketCounts = new ArrayList();
ArrayList thePacketData = new ArrayList();
foreach (Microsoft.Ink.Stroke aStroke in theStrokes)
{
if (!InkAnalyzerHelper.AreElementwiseEquivalent(
aStroke.PacketDescription, thePacketDescription))
{
throw new ApplicationException(
"The strokes collection contains strokes with different packet descriptions.");
}
// Add the stroke data to the collections.
theStrokeIdentifiers.Add(aStroke.Id);
thePacketCounts.Add(aStroke.PacketCount);
thePacketData.AddRange(aStroke.GetPacketData());
}
// Add the stroke data to the base layer ink analyzer.
System.Windows.Ink.AnalysisCore.ContextNodeBase result = baseInkAnalyzer.AddStrokes(
theStrokeIdentifiers.ToArray(typeof(int)) as int[],
thePacketCounts.ToArray(typeof(int)) as int[],
thePacketData.ToArray(typeof(int)) as int[],
thePacketDescription,
languageIdentifier);
return result;
}
Platforms
Windows 98, Windows Server 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
The Microsoft .NET Framework 3.0 is supported on Windows Vista, Microsoft Windows XP SP2, and Windows Server 2003 SP1.
Version Information
.NET Framework
Supported in: 3.0
See Also
Reference
InkAnalyzerBase Class
InkAnalyzerBase Members
System.Windows.Ink.AnalysisCore Namespace
System.Windows.Ink.AnalysisCore.InkAnalyzerBase.AddStroke
InkAnalyzerBase.RemoveStroke
InkAnalyzerBase.RemoveStrokes