InkAnalyzer.AddStrokes 方法 (StrokeCollection, Int32)

InkAnalyzer 添加 StrokeCollection,并将特定的区域设置标识符分配给每个笔画。

命名空间:  System.Windows.Ink
程序集:  IAWinFX(在 IAWinFX.dll 中)

语法

声明
Public Function AddStrokes ( _
    strokesToAdd As StrokeCollection, _
    languageId As Integer _
) As ContextNode
用法
Dim instance As InkAnalyzer
Dim strokesToAdd As StrokeCollection
Dim languageId As Integer
Dim returnValue As ContextNode

returnValue = instance.AddStrokes(strokesToAdd, _
    languageId)
public ContextNode AddStrokes(
    StrokeCollection strokesToAdd,
    int languageId
)
public:
ContextNode^ AddStrokes(
    StrokeCollection^ strokesToAdd, 
    int languageId
)
public ContextNode AddStrokes(
    StrokeCollection strokesToAdd,
    int languageId
)
public function AddStrokes(
    strokesToAdd : StrokeCollection, 
    languageId : int
) : ContextNode

参数

  • languageId
    类型:System.Int32
    分配给 strokesToAdd 集合中的笔画的区域设置标识符。

返回值

类型:System.Windows.Ink.ContextNode
已添加 strokesToAdd 的 ContextNode

备注

InkAnalyzerStrokeCollection 添加到 RootNode 属性的 SubNodes 集合中的一个 UnclassifiedInkNodeStrokeCollection 集合 strokesToAdd 中的每个笔画将被分配区域设置标识符 languageId,并添加到包含具有相同区域设置标识符的笔画的第一个 UnclassifiedInkNode。如果不存在这样的 UnclassifiedInkNode,则新建一个 UnclassifiedInkNode,并将 strokesToAdd 添加到新的 UnclassifiedInkNode 中。

此方法将 DirtyRegion 扩展为区域的当前值与所添加笔画的边界框的并集。

如果这些笔画中有任何笔画已经附加到 InkAnalyzer,则 InkAnalyzer 将引发异常。

示例

下面的示例创建一个新的 InkAnalyzer,并将 StrokesChanged 事件处理程序附加到 InkCanvas(名为 theInkCanvas)上的 Strokes 属性。

theInkAnalyzer = New InkAnalyzer()

AddHandler theInkCanvas.Strokes.StrokesChanged, AddressOf Strokes_StrokesChanged
theInkAnalyzer = new InkAnalyzer();

theInkCanvas.Strokes.StrokesChanged += 
    new StrokeCollectionChangedEventHandler(Strokes_StrokesChanged);

下面的示例定义 Strokes_StrokesChanged 事件处理程序;如果笔画已添加到 theInkCanvas,该事件处理程序会将其添加到 theInkAnalyzer 中。如果笔画已从 theInkCanvas 中移除,该事件处理程序也会将其从 theInkAnalyzer 中移除。

' This event occurs whenever a stroke is added, removed, or partially erased
' from the InkCanvas.
Sub Strokes_StrokesChanged(ByVal sender As Object, ByVal e As StrokeCollectionChangedEventArgs) 
    If e.Added.Count > 0 Then
        theInkAnalyzer.AddStrokes(e.Added)
    End If

    If e.Removed.Count > 0 Then
        theInkAnalyzer.RemoveStrokes(e.Removed)
    End If

End Sub 'Strokes_StrokesChanged
// This event occurs whenever a stroke is added, removed, or partially erased
// from the InkCanvas.
void Strokes_StrokesChanged(object sender, StrokeCollectionChangedEventArgs e)
{
    if (e.Added.Count > 0)
    {
        theInkAnalyzer.AddStrokes(e.Added);
    }

    if (e.Removed.Count > 0)
    {
        theInkAnalyzer.RemoveStrokes(e.Removed);
    }
}

平台

Windows Vista

.NET Framework 和 .NET Compact Framework 并不是对每个平台的所有版本都提供支持。有关支持的版本的列表,请参见.NET Framework 系统要求

版本信息

.NET Framework

受以下版本支持:3.0

另请参见

参考

InkAnalyzer 类

InkAnalyzer 成员

AddStrokes 重载

System.Windows.Ink 命名空间

InkAnalyzer.AddStroke

InkAnalyzerRemoveStroke()

InkAnalyzerRemoveStrokes()