Sdílet prostřednictvím


InkAnalyzerBase.UpdateStrokesData Method

Updates the packet data for the specified strokes.

Namespace:  System.Windows.Ink.AnalysisCore
Assembly:  IACore (in IACore.dll)

Syntax

'Declaration
Public Sub UpdateStrokesData ( _
    strokeIds As Integer(), _
    strokePacketCounts As Integer(), _
    strokesPacketData As Integer(), _
    strokesPacketDescription As Guid() _
)
'Usage
Dim instance As InkAnalyzerBase 
Dim strokeIds As Integer()
Dim strokePacketCounts As Integer()
Dim strokesPacketData As Integer()
Dim strokesPacketDescription As Guid()

instance.UpdateStrokesData(strokeIds, _
    strokePacketCounts, strokesPacketData, _
    strokesPacketDescription)
public void UpdateStrokesData(
    int[] strokeIds,
    int[] strokePacketCounts,
    int[] strokesPacketData,
    Guid[] strokesPacketDescription
)
public:
void UpdateStrokesData(
    array<int>^ strokeIds, 
    array<int>^ strokePacketCounts, 
    array<int>^ strokesPacketData, 
    array<Guid>^ strokesPacketDescription
)
public function UpdateStrokesData(
    strokeIds : int[], 
    strokePacketCounts : int[], 
    strokesPacketData : int[], 
    strokesPacketDescription : Guid[]
)

Parameters

  • strokeIds
    Type: array<System.Int32[]

    An array containing the stroke identifiers.

  • strokePacketCounts
    Type: array<System.Int32[]

    An array containing the number of packets in each stroke.

  • strokesPacketData
    Type: array<System.Int32[]

    An array containing the packet data for the strokes.

  • strokesPacketDescription
    Type: array<System.Guid[]

    An array containing the packet property identifiers.

Remarks

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 Microsoft.Ink.PacketProperty class.

This method can update stroke data only if all the new stroke data has the same packet description.

This method does not update the ink analyzer's DirtyRegion.

If a stroke identified in strokeIds is not associated with the ink analyzer, this method ignores the identifier.

If none of the strokes identified in strokeIds identify a stroke associated with the ink analyzer, this method returns without updating the ink analyzer.

This method throws an System.ArgumentNullException when strokeIds is nulla null reference (Nothing in Visual Basic).

Examples

The following example defines a method, UpdateStrokesData, that updates stroke data for a specified InkAnalyzerBase. This method converts a Strokes collection to packet data and updates the stroke data in the ink analyzer. In practice, if your application is using a Microsoft.Ink.Ink object to store stroke data, your application should use the derived Microsoft.Ink.InkAnalyzer class.

''' <summary> 
''' Updates the packet data for the specified strokes of an InkAnalyzerBase. 
''' </summary> 
''' <param name="baseInkAnalyzer"> 
''' The analyzer that receives the strokes.</param> 
''' <param name="theStrokes"> 
''' The strokes for which to update the stroke data.</param> 
''' <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 Shared Sub MyUpdateStrokesData( _
ByVal baseInkAnalyzer As System.Windows.Ink.AnalysisCore.InkAnalyzerBase, _
ByVal theStrokes As Microsoft.Ink.Strokes)

    ' 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

    ' Update the stroke data for the base layer ink analyzer.
    baseInkAnalyzer.UpdateStrokesData( _
        DirectCast(theStrokeIdentifiers.ToArray(GetType(Integer)), Integer()), _
        DirectCast(thePacketCounts.ToArray(GetType(Integer)), Integer()), _
        DirectCast(thePacketData.ToArray(GetType(Integer)), Integer()), _
        thePacketDescription)

End Sub 'UpdateStrokesData '
/// <summary> 
/// Updates the packet data for the specified strokes of an InkAnalyzerBase. 
/// </summary> 
/// <param name="baseInkAnalyzer">
/// The analyzer that receives the strokes.</param> 
/// <param name="theStrokes">
/// The strokes for which to update the stroke data.</param> 
/// <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 void MyUpdateStrokesData(
    System.Windows.Ink.AnalysisCore.InkAnalyzerBase baseInkAnalyzer,
    Microsoft.Ink.Strokes theStrokes)
{
    // 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());
    }

    // Update the stroke data for the base layer ink analyzer.
    baseInkAnalyzer.UpdateStrokesData(
        theStrokeIdentifiers.ToArray(typeof(int)) as int[],
        thePacketCounts.ToArray(typeof(int)) as int[],
        thePacketData.ToArray(typeof(int)) as int[],
        thePacketDescription);
}

Platforms

Windows 7, Windows Vista, Windows XP SP2, Windows Server 2008 R2, Windows Server 2008, Windows Server 2003

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

InkAnalyzerBase Class

InkAnalyzerBase Members

System.Windows.Ink.AnalysisCore Namespace

InkAnalyzerBase.AddStroke

InkAnalyzerBase.AddStrokes

InkAnalyzerBase.ClearStrokeData

InkAnalyzerBase.UpdateStrokeData

InkAnalyzerBase.UpdateStrokesCacheBase