將多個筆劃的筆劃資料加入至筆墨分析器,並且將指定的文化特性識別項指派給筆劃。
命名空間: System.Windows.Ink.AnalysisCore
組件: IACore (在 IACore.dll 中)
語法
'宣告
Public Function AddStrokes ( _
strokeIdsToAdd As Integer(), _
strokePacketCount As Integer(), _
strokePacketData As Integer(), _
strokePacketDescription As Guid(), _
languageId As Integer _
) As ContextNodeBase
'用途
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
參數
- strokeIdsToAdd
型別:array<System.Int32[]
陣列,包含筆劃識別項。
- strokePacketCount
型別:array<System.Int32[]
陣列,包含每個筆劃中的封包數目。
- strokePacketData
型別:array<System.Int32[]
陣列,包含筆劃的封包資料。
- strokePacketDescription
型別:array<System.Guid[]
陣列,包含封包屬性識別項。
- languageId
型別:System.Int32
要指派給筆劃的文化特性識別項。
傳回值
型別:System.Windows.Ink.AnalysisCore.ContextNodeBase
筆墨分析器在其中加入筆劃的內容節點。
備註
InkAnalyzerBase 會將筆劃加入至 Type 屬性值為 UnclassifiedInk() 的 ContextNodeBase。
筆墨分析器會將指定的文化特性識別項指派給筆劃。接著會將該筆劃加入至筆墨辨識器的根節點 (包含具有相同文化特性識別項的筆劃) 下,第一個未分類的筆墨節點。如果筆墨分析器找不到具有相同文化特性識別項的節點,則會在其根節點下建立新的 ContextNodeBase,並且將筆劃加入至新的未分類筆墨節點。
strokePacketData 包含所有筆劃的封包資料。strokePacketDescription 則包含全域唯一識別項 (GUID),描述各筆劃中每個點的封包資料型別。如需完整的可用封包屬性清單,請參閱 PacketProperty 類別。
在 AddStrokes 的單一呼叫中只能加入具有相同封包描述的筆劃。
這個方法會將 DirtyRegion 擴充至區域目前值和所加入筆劃之週框方塊的聯集。
如果 InkAnalyzerBase 已經包含與要加入的其中一個筆劃具有相同識別項的筆劃,則 InkAnalyzerBase 會擲回例外狀況。
範例
這個範例會定義將 Strokes 集合轉換成封包資料,並且將筆劃加入至 InkAnalyzerBase 的方法。此方法會傳回筆墨分析器已將筆劃加入其中的 ContextNodeBase。
''' <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;
}
平台
Windows Vista, Windows XP SP2, Windows Server 2003
.NET Framework 和 .NET Compact Framework 並不支援各種平台的所有版本。如需支援平台版本的相關資訊,請參閱 .NET Framework 系統需求。
版本資訊
.NET Framework
支援版本:3.0